Ja, habe nach dem Versenden diese Info bekommen.
Habe nun gerade eben nochmal die class.newsletter.php durch die alte ersetzt, gespeichert, hochgeladen und mal einen newsletter verschickt.
Dann kommt er an, ersetze ich die erste paar Sachen, funktioniert auch noch alles bis zu diesem:
Danach funktioniert nichts mehr.
Anbei sende ich mal meinen quellcode der class.newsletter.php vielleicht findet ihr dort etwas komisches!
Code: Alles auswählen
<?php
/*****************************************
* File : $RCSfile: class.newsletter.php,v $
* Project : Contenido
* Descr : Newsletter recipient class
* Modified : $Date: 2005/12/04 14:25:47 $
*
* © four for business AG, www.4fb.de, generated by HerrB (01.08.2004)
*
* $Id: class.newsletter.php,v 1.7 2005/12/04 14:25:47 timo.hummel Exp $
******************************************/
cInclude("classes", "class.properties.php");
cInclude("classes", "class.newsletter.recipients.php");
cInclude("classes", "class.newsletter.groups.php");
cInclude("classes", "class.phpmailer.php");
/**
* Newsletter management class
*/
class NewsletterCollection extends ItemCollection
{
/**
* Constructor Function
* @param none
*/
function NewsletterCollection()
{
global $cfg;
parent :: ItemCollection($cfg["tab"]["news"], "idnews");
$this->_setItemClass("Newsletter");
}
/**
* Loads an item by its ID (primary key)
* @param $itemID integer Specifies the item ID to load
*/
function loadItem($itemID)
{
$item = new Newsletter();
$item->loadByPrimaryKey($itemID);
return ($item);
}
/**
* Creates a new newsletter
* @param $name string specifies the newsletter name
*/
function create($name)
{
global $client, $lang, $auth;
$item = parent :: create();
/* Check if the newsletter name already exists */
$this->select("idclient='$client' AND idlang='$lang' AND name='".urlencode($name)."'");
if ($this->next())
{
return $this->create($name."_".substr(md5(rand()), 0, 10));
}
$item->set("idart", 0);
$item->set("idclient", $client);
$item->set("idlang", $lang);
$item->set("name", $name);
$item->set("created", date("Y-m-d H:i:s"), false);
$item->set("author", $auth->auth["uid"]);
/* subject, message, newsfrom, newsdate, lastmodified not set*/
$item->store();
return $item;
}
/**
* Duplicates the newsletter specified by $itemID
* @param $itemID integer specifies the newsletter id
*/
function duplicate($itemID)
{
global $client, $lang, $auth;
$base = new Newsletter();
$base->loadByPrimaryKey($itemID);
$item = parent :: create();
$item->set("idart", 0);
$item->set("idclient", $client);
$item->set("idlang", $lang);
$item->set("welcome", 0);
$item->set("name", $base->get("name")."_".substr(md5(rand()), 0, 10));
$item->set("subject", $base->get("subject"));
$item->set("message", $base->get("message"));
$item->set("newsfrom", $base->get("newsfrom"));
$item->set("newsdate", date("Y-m-d H:i:s"), false);
$item->set("author", $auth->auth["uid"]);
$item->set("created", date("Y-m-d H:i:s"), false);
$item->store();
return $item;
}
}
/**
* Single Newsletter Item
*/
class Newsletter extends Item
{
/**
* Constructor Function
* @param string $table The table to use as information source
*/
function Newsletter()
{
global $cfg;
parent :: Item($cfg["tab"]["news"], "idnews");
}
function store()
{
global $auth;
$this->set("modified", date("Y-m-d H:i:s"), false);
$this->set("modifiedby", $auth->auth["uid"]);
parent :: store();
}
/**
* Sends a newsletter
* @param $idcatart integer specifies id of the 'BlackBox'-acrticle containing the 'BlackBox'-module for management
* @param $destination string specifies, who will receive the newsletter ("all", "default" = defaultgroup,
* "selection" = selected groups, "single" = one recepient [e.g. Welcome-Newsletter])
* @param $to array specifies, which group of recipients shall receive the
* newsletter ("all", "default" = defaultgroup, "4,5,6" = group IDs)
* @param $chunksize integer specifies size of chunks when sending in chunks, 0 = don't send in chunks
* @param $chunk integer specifies current chunk number when sending in chunks
* result array array of recipient names/e-mails
*/
function send($idcatart, $destination = "other", $to = "", $chunksize = 0, $chunk = 0)
{
global $cfg, $cfgClient, $client, $lang, $auth;
// Not used: $recipients = new RecipientCollection;
switch ($destination)
{
case "all" :
$recipients = new RecipientCollection;
$recipients->select("deactivated='0' AND confirmed='1' AND idclient='$client' AND idlang='$lang'");
break;
case "default" :
/* Not used: The following query would work, but on the wrong object (RecipientGroupMemberCollection, not RecipientCollection).
* It would be possible to get the needed object using fetchObject, but only as single items, not as
* RecipientCollection-object-list - If I have understood anything correctly... HerrB */
/* $recipients = new RecipientGroupMemberCollection;
$recipients->link('RecipientCollection');
$recipients->link('RecipientGroupCollection');
$recipients->setWhere('RecipientCollection.idclient',$client);
$recipients->setWhere('RecipientCollection.idlang',$lang);
$recipients->setWhere('RecipientCollection.deactivated','0');
$recipients->setWhere('RecipientCollection.confirmed','1');
$recipients->setWhere('RecipientGroupCollection.defaultgroup','1');
$recipients->setWhere('RecipientGroupCollection.idclient',$client);
$recipients->setWhere('RecipientGroupCollection.idlang',$lang);
$recipients->query(); */
// The following needs a hack in genericdb (flexSelect)
$recipients = new RecipientCollection;
$recipients->flexSelect("distinct", $cfg["tab"]["news_groups"]." AS groups, ".$cfg["tab"]["news_groupmembers"]." AS groupmembers ", "recipientcollection.idclient = '".$client."' AND "."recipientcollection.idlang = '".$lang."' AND "."recipientcollection.deactivated = '0' AND "."recipientcollection.confirmed = '1' AND "."recipientcollection.idnewsrcp = groupmembers.idnewsrcp AND "."groupmembers.idnewsgroup = groups.idnewsgroup AND "."groups.defaultgroup = '1' AND groups.idclient = '".$client."' AND "."groups.idlang = '".$lang."'");
break;
case "selection" :
$recipients = new RecipientCollection;
if (is_array($to) && count($to) > 0)
{
$groups = "'";
foreach ($to as $group)
{
if ($groups != "'")
{
$groups .= "','";
}
/* SQL-Injection - not used
$group = str_replace (";","",$group);
$group = str_replace ("--","",$group);
$group = str_replace ("'","",$group);
$group = htmlentities($group); */
$groups .= urlencode($group);
}
$groups .= "'";
// The following needs a hack in genericdb (flexSelect)
$recipients->flexSelect("distinct", $cfg["tab"]["news_groupmembers"]." AS groupmembers ", "recipientcollection.idclient = '".$client."' AND "."recipientcollection.idlang = '".$lang."' AND "."recipientcollection.deactivated = '0' AND "."recipientcollection.confirmed = '1' AND "."recipientcollection.idnewsrcp = groupmembers.idnewsrcp AND "."groupmembers.idnewsgroup IN (".$groups.")");
} else
{
$destination = "other";
}
break;
case "single" :
$recipients = new RecipientCollection;
if (is_numeric($to))
{
$recipients->select("idnewsrcp = '".$to."'");
} else
{
$destination = "other";
}
break;
default :
$destination = "other";
}
unset ($result);
$result = array ();
if ($destination == "other")
{
$result[] = 0;
$result[] = i18n("No recipients found");
} else
{
$recipientcount = $recipients->count();
if ($recipientcount == 0)
{
$result[] = 0;
$result[] = i18n("No recipients found");
} else
{
$from = $this->get("newsfrom");
$subject = $this->get("subject");
$message = $this->get("message");
$messageHTML = $this->get("messageHTML");
/* Not used, old functionality
$date = $this->get("newsdate");
$dateday = strftime("%d.%m.%Y", strtotime($date));
$time = strftime("%H:%M", strtotime($date)); */
$dateday = strftime("%d.%m.%Y"); // Format should be replaced by a user variable...
$time = strftime("%H:%M"); // Format should be replaced by a user variable...
$message = str_replace("MAIL_NUMBER", "$recipientcount", $message);
$message = str_replace("MAIL_DATE", "$dateday", $message);
$message = str_replace("MAIL_TIME", "$time", $message);
$messageHTML = str_replace("MAIL_NUMBER", "$recipientcount", $messageHTML);
$messageHTML = str_replace("MAIL_DATE", "$dateday", $messageHTML);
$messageHTML = str_replace("MAIL_TIME", "$time", $messageHTML);
$messageHTML = str_replace("\"upload", "\"".$cfgClient[$client]["htmlpath"]["frontend"]."/upload", $messageHTML);
$messageHTML = "<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"".$cfgClient[$client]["htmlpath"]["frontend"]."/css/newsletter.css\" /></head><body>".$messageHTML;
// Preventing double lines in mail, you may wish to disable this function on windows servers
if (!getSystemProperty("newsletter", "disablernreplacement"))
{
$message = str_replace("\r\n", "\n", $message);
}
$path = $cfgClient[$client]["path"]["htmlpath"]."front_content.php?changelang=".$lang."&idcatart=".$idcatart."&";
$counter = 0;
if ($chunksize == 0)
{
$lowborder = 0;
$highborder = $recipientcount +1;
} else
{
$lowborder = $chunksize * $chunk;
$highborder = $lowborder + $chunksize;
}
if ($lowborder >= $recipientcount)
{
$result[] = 0;
$result[] = i18n("No (more) recipients found");
} else
{
$result[] = $recipientcount;
while (($recipient = $recipients->next()) && $counter < $highborder)
{
if ($chunksize == 0 || $counter >= $lowborder)
{
$to = $recipient->get("email");
$name = $recipient->get("name");
if (empty ($name))
{
$name = $to;
}
$key = $recipient->get("hash");
if (strlen($key) == 30)
{ // Prevents sending without having a key
$message2 = str_replace("MAIL_NAME", "$name", $message);
$message2 = str_replace("MAIL_UNSUBSCRIBE", $path."unsubscribe=".$key, $message2);
$message2 = str_replace("MAIL_CHANGE", $path."change=".$key, $message2);
$message2 = str_replace("MAIL_STOP", $path."stop=".$key, $message2);
$message2 = str_replace("MAIL_GOON", $path."goon=".$key, $message2);
$messageHTML2 = str_replace("MAIL_NAME", "$name", $messageHTML);
$messageHTML2 = str_replace("MAIL_UNSUBSCRIBE", "<a href=\"".$path."unsubscribe=".$key."\">".$path."unsubscribe=".$key."</a>", $messageHTML2);
$messageHTML2 = str_replace("MAIL_CHANGE", "<a href=\"".$path."change=".$key."\">".$path."change=".$key."</a>", $messageHTML2);
$messageHTML2 = str_replace("MAIL_STOP", "<a href=\"".$path."stop=".$key."\">".$path."stop=".$key."</a>", $messageHTML2);
$messageHTML2 = str_replace("MAIL_GOON", "<a href=\"".$path."goon=".$key."\">".$path."goon=".$key."</a>", $messageHTML2);
$boundary = md5(uniqid(time()));
$headers = 'From: ' . $from . "\n";
$headers .= 'To: ' . $to . "\n";
$headers .= 'Return-Path: ' . $from . "\n";
$headers .= 'MIME-Version: 1.0' ."\n";
$headers .= 'Content-Type: multipart/alternative; boundary="' . $boundary . '"' . "\n\n";
$headers .= $message2."\n\n".$foot . "\n";
$headers .= '--' . $boundary . "\n";
$headers .= 'Content-Type: text/plain; charset=ISO-8859-1' ."\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
$headers .= $message2."\n\n".$foot . "\n";
$headers .= '--' . $boundary . "\n";
$headers .= 'Content-Type: text/HTML; charset=ISO-8859-1' ."\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
$headers .= $messageHTML2."<p>".$foot."</p></body></html>\n";
$headers .= '--' . $boundary . "--\n";
$mailOk=mail('', $subject,'', $headers);
if ($mailOk) {
$result[] = $name . " (" . $to . "): " . i18n("Sent successfully");
} else {
$result[] = $name . " (" . $to . "): " . sprintf(i18n("Newsletter to %s could not be sent"), $to);
}
} else
{
$result[] = $name." (".$to."): ".sprintf(i18n("Newsletter to %s could not be sent (recipient has an incompatible or empty key)."), $to);
}
}
$counter ++;
}
}
}
}
return $result;
}
}
?>