Ignore:
Timestamp:
Sep 11, 2003, 12:24:03 AM (21 years ago)
Author:
z0rglub
Message:

Mail notification for admins

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions.inc.php

    r61 r85  
    351351}
    352352
     353// format_date returns a formatted date for display. The date given in
     354// argument can be a unixdate (number of seconds since the 01.01.1970) or an
     355// american format (2003-09-15). By option, you can show the time. The
     356// output is internationalized.
     357//
     358// format_date( "2003-09-15", 'us', true ) -> "Monday 15 September 2003 21:52"
    353359function format_date( $date, $type = 'us', $show_time = false )
    354360{
     
    376382  return $formated_date;
    377383}
     384
     385// notify sends a email to every admin of the gallery
     386function notify( $type, $infos = '' )
     387{
     388  global $conf;
     389
     390  $headers = 'From: '.$conf['webmaster'].' <'.$conf['mail_webmaster'].'>'."\n";
     391  $headers.= 'Reply-To: '.$conf['mail_webmaster']."\n";
     392  $headers.= 'X-Mailer: PhpWebGallery, PHP '.phpversion();
     393
     394  $options = '-f '.$conf['mail_webmaster'];
     395  // retrieving all administrators
     396  $query = 'SELECT username,mail_address,language';
     397  $query.= ' FROM '.PREFIX_TABLE.'users';
     398  $query.= " WHERE status = 'admin'";
     399  $query.= ' AND mail_address IS NOT NULL';
     400  $query.= ';';
     401  $result = mysql_query( $query );
     402  while ( $row = mysql_fetch_array( $result ) )
     403  {
     404    $to = $row['mail_address'];
     405    include( PREFIX_INCLUDE.'./language/'.$row['language'].'.php' );
     406    $content = $lang['mail_hello']."\n\n";
     407    switch ( $type )
     408    {
     409    case 'upload' :
     410      $subject = $lang['mail_new_upload_subject'];
     411      $content.= $lang['mail_new_upload_content'];
     412      break;
     413    case 'comment' :
     414      $subject = $lang['mail_new_comment_subject'];
     415      $content.= $lang['mail_new_comment_content'];
     416      break;
     417    }
     418    $infos = str_replace( '&nbsp;',  ' ', $infos );
     419    $infos = str_replace( '&minus;', '-', $infos );
     420    $content.= "\n\n".$infos;
     421    $content.= "\n\n-- \nPhpWebGallery ".$conf['version'];
     422    $content = wordwrap( $content, 72 );
     423    @mail( $to, $subject, $content, $headers, $options );
     424  }
     425}
    378426?>
Note: See TracChangeset for help on using the changeset viewer.