aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/configuration.php36
-rw-r--r--include/config.inc.php4
-rw-r--r--include/functions.inc.php48
-rw-r--r--language/francais.php11
-rw-r--r--picture.php9
-rw-r--r--upload.php5
6 files changed, 110 insertions, 3 deletions
diff --git a/admin/configuration.php b/admin/configuration.php
index d2cdda12c..786abdba1 100644
--- a/admin/configuration.php
+++ b/admin/configuration.php
@@ -43,7 +43,8 @@ array( 'prefix_thumbnail','webmaster','mail_webmaster','access',
'show_comments','nb_comment_page','upload_available',
'upload_maxfilesize', 'upload_maxwidth','upload_maxheight',
'upload_maxwidth_thumbnail','upload_maxheight_thumbnail','log',
- 'comments_validation','comments_forall','authorize_cookies' );
+ 'comments_validation','comments_forall','authorize_cookies',
+ 'mail_notification' );
$default_user_infos =
array( 'nb_image_line','nb_line_page','language','maxwidth',
'maxheight','expand','show_nb_comments','short_period','long_period',
@@ -403,6 +404,39 @@ $vtp->setVar( $sub, 'param_line.def',
$lang['conf_general_log_info'] );
$vtp->closeSession( $sub, 'param_line' );
$vtp->closeSession( $sub, 'line' );
+// mail notification for admins
+$vtp->addSession( $sub, 'line' );
+$vtp->addSession( $sub, 'param_line' );
+$vtp->setVar( $sub, 'param_line.name',
+ $lang['conf_general_mail_notification'] );
+$vtp->addSession( $sub, 'group' );
+$vtp->addSession( $sub, 'radio' );
+$vtp->setVar( $sub, 'radio.name', 'mail_notification' );
+$vtp->setVar( $sub, 'radio.value', 'true' );
+$vtp->setVar( $sub, 'radio.option', $lang['yes'] );
+$checked = '';
+if ( $mail_notification == 'true' )
+{
+ $checked = ' checked="checked"';
+}
+$vtp->setVar( $sub, 'radio.checked', $checked );
+$vtp->closeSession( $sub, 'radio' );
+$vtp->addSession( $sub, 'radio' );
+$vtp->setVar( $sub, 'radio.name', 'mail_notification' );
+$vtp->setVar( $sub, 'radio.value', 'false' );
+$vtp->setVar( $sub, 'radio.option', $lang['no'] );
+$checked = '';
+if ( $mail_notification == 'false' )
+{
+ $checked = ' checked="checked"';
+}
+$vtp->setVar( $sub, 'radio.checked', $checked );
+$vtp->closeSession( $sub, 'radio' );
+$vtp->closeSession( $sub, 'group' );
+$vtp->setVar( $sub, 'param_line.def',
+ $lang['conf_general_mail_notification_info'] );
+$vtp->closeSession( $sub, 'param_line' );
+$vtp->closeSession( $sub, 'line' );
$vtp->addSession( $sub, 'line' );
$vtp->addSession( $sub, 'space_line' );
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
diff --git a/language/francais.php b/language/francais.php
index 3f32f0628..ae9ffd0b6 100644
--- a/language/francais.php
+++ b/language/francais.php
@@ -241,6 +241,15 @@ $lang['upload_creation_date'] = 'Date de création (JJ/MM/AAAA)';
$lang['upload_comment'] = 'Commentaire';
// end version 1.3
+// start version 1.3
+// mails
+$lang['mail_hello'] = 'Bonjour,';
+$lang['mail_new_upload_subject'] = 'Nouvelle image sur le site';
+$lang['mail_new_upload_content'] = 'Une nouvelle image a été placée sur la galerie. Elle est en attente de validation. RDV dans la section d\'administration pour valider ou supprimer cette image.';
+$lang['mail_new_comment_subject'] = 'Nouveau commentaire sur le site';
+$lang['mail_new_comment_content'] = 'Un nouveau commentaire a été posté sur la galerie. Si vous avez activé la validation des commentaires, il faut d\'abord valider le commentaire dans la zone d\'administration pour le voir apparaître.'."\n\n".'Vous avez accès aux derniers commentaires dans la zone d\'administration.';
+// end version 1.3
+
//----------------------------------administration
if ( $isadmin )
{
@@ -343,6 +352,8 @@ if ( $isadmin )
// $lang['conf_general_expand_info'] = 'développer toutes les catégories par défaut dans le menu ?';
$lang['conf_general_log'] = 'historique';
$lang['conf_general_log_info'] = 'historiser les visites sur le site ? Les visites seront visibles dans l\'historique de l\'administration';
+ $lang['conf_general_mail_notification'] = 'Notification par mail';
+ $lang['conf_general_mail_notification_info'] = 'Notification automatique par mail des administrateurs (seuls les administrateurs) lors de l\'ajout d\'un commentaire, ou lors de l\'ajout d\'une image.';
// end version 1.3
$lang['conf_comments'] = 'commentaires utilisateurs';
$lang['conf_comments_title'] = 'Configuration des '.$lang['conf_comments'];
diff --git a/picture.php b/picture.php
index 403301de7..4af9ce5ed 100644
--- a/picture.php
+++ b/picture.php
@@ -605,6 +605,15 @@ if ( $conf['show_comments'] )
}
$vtp->setVar( $handle, 'information.content', $message );
$vtp->closeSession( $handle, 'information' );
+ // notification to the administrators
+ if ( $conf['mail_notification'] )
+ {
+ $cat_name = get_cat_display_name( $page['cat_name'], ' > ', '' );
+ $cat_name = strip_tags( $cat_name );
+ if ( $page['name'] == '' ) $picture = $page['file'];
+ else $picture = $page['name'];
+ notify( 'comment', $cat_name.' > '.$picture );
+ }
}
else
{
diff --git a/upload.php b/upload.php
index 5e683f4d4..735faa49c 100644
--- a/upload.php
+++ b/upload.php
@@ -213,6 +213,11 @@ if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) )
$query.= ';';
mysql_query( $query );
$page['waiting_id'] = mysql_insert_id();
+ // mail notification for administrators
+ if ( $conf['mail_notification'] )
+ {
+ notify( 'comment' );
+ }
}
}
//------------------------------------------------------------ thumbnail upload