mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-03-28 17:42:57 +01:00
[NBM] Step 1: Create new include files with current notification/mail fonctions (with improvement)
git-svn-id: http://piwigo.org/svn/trunk@1018 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
192
feed.php
192
feed.php
@@ -2,7 +2,7 @@
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
@@ -27,200 +27,12 @@
|
||||
|
||||
define('PHPWG_ROOT_PATH','./');
|
||||
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
||||
include_once(PHPWG_ROOT_PATH.'include/functions_notification.inc.php');
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | functions |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* new comments between two dates, according to authorized categories
|
||||
*
|
||||
* @param string start (mysql datetime format)
|
||||
* @param string end (mysql datetime format)
|
||||
* @param string forbidden categories (comma separated)
|
||||
* @return array comment ids
|
||||
*/
|
||||
function new_comments($start, $end)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$query = '
|
||||
SELECT DISTINCT c.id AS comment_id
|
||||
FROM '.COMMENTS_TABLE.' AS c
|
||||
, '.IMAGE_CATEGORY_TABLE.' AS ic
|
||||
WHERE c.image_id = ic.image_id
|
||||
AND c.validation_date > \''.$start.'\'
|
||||
AND c.validation_date <= \''.$end.'\'
|
||||
AND category_id NOT IN ('.$user['forbidden_categories'].')
|
||||
;';
|
||||
return array_from_query($query, 'comment_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* unvalidated at a precise date
|
||||
*
|
||||
* Comments that are registered and not validated yet on a precise date
|
||||
*
|
||||
* @param string date (mysql datetime format)
|
||||
* @return array comment ids
|
||||
*/
|
||||
function unvalidated_comments($date)
|
||||
{
|
||||
$query = '
|
||||
SELECT DISTINCT id
|
||||
FROM '.COMMENTS_TABLE.'
|
||||
WHERE date <= \''.$date.'\'
|
||||
AND (validated = \'false\'
|
||||
OR validation_date > \''.$date.'\')
|
||||
;';
|
||||
return array_from_query($query, 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* new elements between two dates, according to authorized categories
|
||||
*
|
||||
* @param string start (mysql datetime format)
|
||||
* @param string end (mysql datetime format)
|
||||
* @param string forbidden categories (comma separated)
|
||||
* @return array element ids
|
||||
*/
|
||||
function new_elements($start, $end)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$query = '
|
||||
SELECT DISTINCT image_id
|
||||
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id
|
||||
WHERE date_available > \''.$start.'\'
|
||||
AND date_available <= \''.$end.'\'
|
||||
AND category_id NOT IN ('.$user['forbidden_categories'].')
|
||||
;';
|
||||
return array_from_query($query, 'image_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* updated categories between two dates, according to authorized categories
|
||||
*
|
||||
* @param string start (mysql datetime format)
|
||||
* @param string end (mysql datetime format)
|
||||
* @param string forbidden categories (comma separated)
|
||||
* @return array element ids
|
||||
*/
|
||||
function updated_categories($start, $end)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$query = '
|
||||
SELECT DISTINCT category_id
|
||||
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id
|
||||
WHERE date_available > \''.$start.'\'
|
||||
AND date_available <= \''.$end.'\'
|
||||
AND category_id NOT IN ('.$user['forbidden_categories'].')
|
||||
;';
|
||||
return array_from_query($query, 'category_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* new registered users between two dates
|
||||
*
|
||||
* @param string start (mysql datetime format)
|
||||
* @param string end (mysql datetime format)
|
||||
* @return array user ids
|
||||
*/
|
||||
function new_users($start, $end)
|
||||
{
|
||||
$query = '
|
||||
SELECT user_id
|
||||
FROM '.USER_INFOS_TABLE.'
|
||||
WHERE registration_date > \''.$start.'\'
|
||||
AND registration_date <= \''.$end.'\'
|
||||
;';
|
||||
return array_from_query($query, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* currently waiting pictures
|
||||
*
|
||||
* @return array waiting ids
|
||||
*/
|
||||
function waiting_elements()
|
||||
{
|
||||
$query = '
|
||||
SELECT id
|
||||
FROM '.WAITING_TABLE.'
|
||||
WHERE validated = \'false\'
|
||||
;';
|
||||
|
||||
return array_from_query($query, 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* What's new between two dates ?
|
||||
*
|
||||
* Informations : number of new comments, number of new elements, number of
|
||||
* updated categories. Administrators are also informed about : number of
|
||||
* unvalidated comments, number of new users (TODO : number of unvalidated
|
||||
* elements)
|
||||
*
|
||||
* @param string start date (mysql datetime format)
|
||||
* @param string end date (mysql datetime format)
|
||||
*/
|
||||
function news($start, $end)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$news = array();
|
||||
|
||||
$nb_new_comments = count(new_comments($start, $end));
|
||||
if ($nb_new_comments > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d new comments'), $nb_new_comments));
|
||||
}
|
||||
|
||||
$nb_new_elements = count(new_elements($start, $end));
|
||||
if ($nb_new_elements > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d new elements'), $nb_new_elements));
|
||||
}
|
||||
|
||||
$nb_updated_categories = count(updated_categories($start, $end));
|
||||
if ($nb_updated_categories > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d categories updated'),
|
||||
$nb_updated_categories));
|
||||
}
|
||||
|
||||
if ('admin' == $user['status'])
|
||||
{
|
||||
$nb_unvalidated_comments = count(unvalidated_comments($end));
|
||||
if ($nb_unvalidated_comments > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d comments to validate'),
|
||||
$nb_unvalidated_comments));
|
||||
}
|
||||
|
||||
$nb_new_users = count(new_users($start, $end));
|
||||
if ($nb_new_users > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d new users'), $nb_new_users));
|
||||
}
|
||||
|
||||
$nb_waiting_elements = count(waiting_elements());
|
||||
if ($nb_waiting_elements > 0)
|
||||
{
|
||||
array_push(
|
||||
$news,
|
||||
sprintf(
|
||||
l10n('%d waiting elements'),
|
||||
$nb_waiting_elements
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $news;
|
||||
}
|
||||
|
||||
/**
|
||||
* explodes a MySQL datetime format (2005-07-14 23:01:37) in fields "year",
|
||||
* "month", "day", "hour", "minute", "second".
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
@@ -182,6 +182,10 @@ $conf['users_page'] = 20;
|
||||
// "options" parameter missing on mail() function execution.
|
||||
$conf['mail_options'] = false;
|
||||
|
||||
// Send bcc mail to webmaster
|
||||
// Set true for debug or test
|
||||
$conf['send_bcc_mail_webmaster'] = false;
|
||||
|
||||
// check_upgrade_feed: check if there are database upgrade required. Set to
|
||||
// true, a message will strongly encourage you to upgrade your database if
|
||||
// needed.
|
||||
|
||||
36
password.php
36
password.php
@@ -2,7 +2,7 @@
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
@@ -31,37 +31,7 @@
|
||||
|
||||
define('PHPWG_ROOT_PATH','./');
|
||||
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | functions |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* sends an email, using PhpWebGallery specific informations
|
||||
*/
|
||||
function pwg_mail($to, $from, $infos = '')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$headers = 'From: <'.$from.'>'."\n";
|
||||
$headers.= 'Reply-To: '.$from."\n";
|
||||
|
||||
$options = '-f '.$from;
|
||||
|
||||
$subject = l10n('password updated');
|
||||
|
||||
$content = $infos;
|
||||
$content.= "\n\n-- \nPhpWebGallery ".PHPWG_VERSION;
|
||||
|
||||
if ($conf['mail_options'])
|
||||
{
|
||||
return mail($to, $subject, $content, $headers, $options);
|
||||
}
|
||||
else
|
||||
{
|
||||
return mail($to, $subject, $content, $headers);
|
||||
}
|
||||
}
|
||||
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | send a new password |
|
||||
@@ -118,7 +88,7 @@ SELECT '.$conf['user_fields']['id'].' AS id
|
||||
."\n".l10n('Password').': '.$new_password
|
||||
;
|
||||
|
||||
if (pwg_mail($row['email'], $mail_webmaster, $infos))
|
||||
if (pwg_mail($row['email'], $mail_webmaster, l10n('password updated'), $infos))
|
||||
{
|
||||
$data =
|
||||
array(
|
||||
|
||||
Reference in New Issue
Block a user