Well.. here is a small plug-in that I use to send the news letters to all my user on weekly basis.. May be you can use it..
Please follow below steps to install this news letter functionality..
Files needs to be changed / Created
1.
image_notification.php ==> new file 2.
batch_upload_not.html ==> new file 3.
\includes\email.php ==> Old file Step 1: 1.1==>Save the below code as image_notification.php
1.2==> Find "
www.yourdomain.com" on the 29th line and change it to your own domain name.
1.3==> Upload this file in
\admin\plugins folder.
<?php // PLUGIN_TITLE: Image Notification
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: image_notification.php *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7.x *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (Lizenz.txt) für weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (Licence.txt) for further information. *
* *
*************************************************************************/
$nozip = 1;
define('IN_CP', 1);
$root_path = (!eregi("\/plugins\/", $_SERVER['PHP_SELF'])) ? "./../" : "./../../";
define('ROOT_PATH', $root_path);
define('ROOT', 'http://www.yourdomain.com/');
require(ROOT_PATH.'admin/admin_global.php');
//-----------------------------------------------------------------------------------
if ($action == "") {
$action = "intro";
}
show_admin_header();
if ($action == "intro") {
show_form_header("image_notification.php", "notify");
show_table_header("Image Notification", 2);
$new_cutoff = time() - 60 * 60 * 24 * 2;
$num_new_images = 9;
$sql = "SELECT IF(i.image_date >= $new_cutoff,RAND()+1,1) as random_no, i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").") AND cat_parent_id IN (152,1,2,110)
ORDER BY random_no DESC, i.image_date DESC
LIMIT $num_new_images";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
if (!$num_rows) {
echo "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
echo $lang['no_new_images'];
echo "</td></tr></table>";
}
else {
echo "<table width=\"100%\">";
$count = 0;
$bgcounter = 0;
while ($image_row = $site_db->fetch_array($result)){
if ($count == 0) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 2 : '';
echo "<tr class=\"tablerow".$row_bg_number."\">\n";
}
echo "<td width=25% valign=\"top\">\n";
$file_src = ROOT_PATH."".THUMB_DIR."/".$image_row['cat_id']."/".$image_row['image_thumb_file']." \n";
$image_path = ROOT_PATH."details.php?image_id=".$image_row['image_id']." \n";
echo "<a href=\"".$image_path."\" target=\"_blank\"><img src=\"".$file_src."\" border=\"0\" ></a>";
echo "\n</td>\n";
$count++;
if ($count == 3) {
echo "</tr>\n";
$count = 0;
}
} // end while
if ($count > 0) {
$leftover = (3 - $count);
if ($leftover >= 1) {
for ($f = 0; $f < $leftover; $f++) {
echo "<td width=\">\n \n</td>\n";
}
echo "</tr>\n";
}
}
echo "</table>\n";
} // end else
show_form_footer($lang['submit'],'');
echo "<center>Plugin Designed by: <b><a href=\"http:/\/\www.bhwallpapers.com/\">Free Celebrity wallpapers</a></b></center>";
}
if ($action == "notify")
{
// show_table_header("Image Notification", 2);
echo "Processing your request\n \n<br />";
$new_cutoff = time() - 60 * 60 * 24 * 2;
$num_new_images = 9;
$sql = "SELECT IF(i.image_date >= $new_cutoff,RAND()+1,1) as random_no, i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").") AND cat_parent_id IN (152,1,2,110)
ORDER BY random_no DESC, i.image_date DESC
LIMIT $num_new_images";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
if (!$num_rows) {
$message .= "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
$message .= $lang['no_new_images'];
$message .= "</td></tr></table>";
}
else {
// $message .= "<html>\n";
// $message .= "<head> Celebrity News Letter </head>";
$message .= "<table width=\"80%\">";
$count = 0;
$bgcounter = 0;
while ($image_row = $site_db->fetch_array($result)){
if ($count == 0) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 2 : '';
// echo "<tr class=\"".get_row_bg()."\">";
$message .= "<tr class=\"tablerow".$row_bg_number."\">\n";
}
$message .= "<td bgcolor=\"#d4dded\" width=25% valign=\"top\" align=\"center\">\n";
$file_src = ROOT."".THUMB_DIR."/".$image_row['cat_id']."/".$image_row['image_thumb_file']." \n";
$image_path = ROOT."details.php?image_id=".$image_row['image_id']." \n";
$message .= "$image_row[image_name]<br /><a href=\"".$image_path."\" target=\"_blank\"><img src=\"".$file_src."\" border=\"0\" ><br />$image_row[image_description]</a>";
$message .= "\n</td>\n";
$count++;
if ($count == 3) {
$message .= "</tr>\n";
$count = 0;
}
} // end while
if ($count > 0) {
$leftover = (3 - $count);
if ($leftover >= 1) {
for ($f = 0; $f < $leftover; $f++) {
$message .= "<td width=\">\n \n</td>\n";
}
$message .= "</tr>\n";
}
}
$message .= "</table>\n";
// $message .= "</html>\n";
} // end else
//-----------------------------------------
// send email
//-------------------------------------------
if ($user_info['user_level'] == ADMIN ) {
$sql = "SELECT ".get_user_table_field("", "user_id").get_user_table_field(", ", "user_level").get_user_table_field(", ", "user_name").get_user_table_field(", ", "user_email")."
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_id")." <> ".GUEST." AND ".get_user_table_field("", "user_allowemails")." = 1
ORDER BY ".get_user_table_field("", "user_level")." DESC";
$result = $site_db->query($sql);
@set_time_limit(1200);
include(ROOT_PATH.'includes/email.php');
while ($row = $site_db->fetch_array($result)) {
$user_email = $row[$user_table_fields['user_email']];
$site_email = new Email();
$site_email->set_to($user_email);
$site_email->register_vars(array(
"message" => $message,
"site_name" => $config['site_name']
));
$site_email->set_subject($lang['newsletter_emails']);
$site_email->set_body("batch_upload_not", $config['language_dir_default']);
$site_email->send_email();
}
}
echo "Notification sent to all the users";
show_admin_footer();
}
?>
Step 2: 2.1 Create a new file called
batch_upload_not.html and place the below content on it.
Dear member, <br/>
These are your weekly new celebrity wallpapers/images.<br /><br /><br />
<center>
{message}
</center>
</br></br></br>
<b>Best regards,</b> <br/>
{site_name}</br><br/>
<!-- YOUR EMAIL ADDS GOES HERE -->
<!-- YOUR EMAIL ADDS GOES HERE -->
<!-- YOUR EMAIL ADDS GOES HERE -->
<b>P.N.</b> This is not a SPAM. You are getting this email, because you are a registered member at yourwebsite.com. <br/>
We care your privacy. Please read our Privacy Policy for more details.<br/>
To cancel this new wallpaper notification, please send your request to admin@yourwebsite.com<br/>
2.2: Now put this file in
lang\english\email\ folder
Step 3: 3.1 : Open \includes\email.php file and find
if (!empty($this->bcc) && !$this->use_smtp) {
insert above
$header .= 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
Now you are done..
After adding new images.. you can go to your plugin section of your ACP, it will show you randomly selected lastest uploaded 9 images. you need to hit the submit.. then it will start sending the emails to the user. Email sending process will take time depending on the total number of users.
Please respect the users privacy and don't SPAM there inbox..
Let me know if you are facing any issues..