aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2003-09-10 22:24:03 +0000
committerz0rglub <z0rglub@piwigo.org>2003-09-10 22:24:03 +0000
commit637cdd1e23a6faadfea3988da80ee3648cf8999a (patch)
tree4b86f1e1ed353fb1f9c5a390b3e98f2396525b1b /include
parent122ac485f7330a9544504e2355fbdf53124e5702 (diff)
Mail notification for admins
git-svn-id: http://piwigo.org/svn/trunk@85 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/config.inc.php4
-rw-r--r--include/functions.inc.php48
2 files changed, 50 insertions, 2 deletions
diff --git a/include/config.inc.php b/include/config.inc.php
index 14ae8a1bc..9f5b84a07 100644
--- a/include/config.inc.php
+++ b/include/config.inc.php
@@ -49,7 +49,7 @@ $conf['site_url'] = 'http://www.phpwebgallery.net';
$conf['forum_url'] = 'http://forum.phpwebgallery.net';
$conf['picture_ext'] = array('jpg','JPG','gif','GIF','png','PNG');
$conf['document_ext'] = array('doc','pdf','zip');
-$conf['top_number'] = 20;
+$conf['top_number'] = 5;
$conf['anti-flood_time'] = 60; // seconds between 2 comments : 0 to disable
database_connection();
@@ -64,7 +64,7 @@ $infos = array( 'prefix_thumbnail', 'webmaster', 'mail_webmaster', 'access',
'upload_available', 'upload_maxfilesize', 'upload_maxwidth',
'upload_maxheight', 'upload_maxwidth_thumbnail',
'upload_maxheight_thumbnail','log','comments_validation',
- 'comments_forall','authorize_cookies' );
+ 'comments_forall','authorize_cookies','mail_notification' );
$query = 'SELECT ';
foreach ( $infos as $i => $info ) {
diff --git a/include/functions.inc.php b/include/functions.inc.php
index e28515e91..f62846ce8 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -350,6 +350,12 @@ function templatize_array( $array, $global_array_name, $handle )
}
}
+// format_date returns a formatted date for display. The date given in
+// argument can be a unixdate (number of seconds since the 01.01.1970) or an
+// american format (2003-09-15). By option, you can show the time. The
+// output is internationalized.
+//
+// format_date( "2003-09-15", 'us', true ) -> "Monday 15 September 2003 21:52"
function format_date( $date, $type = 'us', $show_time = false )
{
global $lang;
@@ -375,4 +381,46 @@ function format_date( $date, $type = 'us', $show_time = false )
return $formated_date;
}
+
+// notify sends a email to every admin of the gallery
+function notify( $type, $infos = '' )
+{
+ global $conf;
+
+ $headers = 'From: '.$conf['webmaster'].' <'.$conf['mail_webmaster'].'>'."\n";
+ $headers.= 'Reply-To: '.$conf['mail_webmaster']."\n";
+ $headers.= 'X-Mailer: PhpWebGallery, PHP '.phpversion();
+
+ $options = '-f '.$conf['mail_webmaster'];
+ // retrieving all administrators
+ $query = 'SELECT username,mail_address,language';
+ $query.= ' FROM '.PREFIX_TABLE.'users';
+ $query.= " WHERE status = 'admin'";
+ $query.= ' AND mail_address IS NOT NULL';
+ $query.= ';';
+ $result = mysql_query( $query );
+ while ( $row = mysql_fetch_array( $result ) )
+ {
+ $to = $row['mail_address'];
+ include( PREFIX_INCLUDE.'./language/'.$row['language'].'.php' );
+ $content = $lang['mail_hello']."\n\n";
+ switch ( $type )
+ {
+ case 'upload' :
+ $subject = $lang['mail_new_upload_subject'];
+ $content.= $lang['mail_new_upload_content'];
+ break;
+ case 'comment' :
+ $subject = $lang['mail_new_comment_subject'];
+ $content.= $lang['mail_new_comment_content'];
+ break;
+ }
+ $infos = str_replace( '&nbsp;', ' ', $infos );
+ $infos = str_replace( '&minus;', '-', $infos );
+ $content.= "\n\n".$infos;
+ $content.= "\n\n-- \nPhpWebGallery ".$conf['version'];
+ $content = wordwrap( $content, 72 );
+ @mail( $to, $subject, $content, $headers, $options );
+ }
+}
?> \ No newline at end of file