Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Fri, Jul 18, 10:24 PM

in-portal

Index: trunk/kernel/include/emailmessage.php
===================================================================
--- trunk/kernel/include/emailmessage.php (revision 3519)
+++ trunk/kernel/include/emailmessage.php (revision 3520)
@@ -1,988 +1,980 @@
<?php
class clsEmailMessage extends clsParsedItem
{
var $Event = "";
var $Item;
var $headers = array();
var $subject = "";
var $body = "";
var $TemplateParsed = FALSE;
var $recipient = NULL;
var $fromuser = NULL;
function clsEmailMessage($MessageId=NULL,$Item=NULL)
{
$this->clsParsedItem();
$this->tablename = GetTablePrefix()."EmailMessage";
$this->Item = $Item;
$this->BasePermission = "EMAIL";
$this->id_field = "EmailMessageId";
$this->TagPrefix = "email";
$this->NoResourceId=1;
if($MessageId)
$this->LoadFromDatabase($MessageId);
}
function LoadEvent($event,$language=NULL)
{
global $objConfig, $objLanguages;
if(!strlen($language))
$language = $objLanguages->GetPrimary();
$sql = "SELECT * FROM ".$this->tablename." WHERE EventId = $event AND LanguageId=$language";
$rs = $this->adodbConnection->Execute($sql);
if($rs && !$rs->EOF)
{
$data = $rs->fields;
$this->SetFromArray($data);
$this->Clean();
return TRUE;
}
else
return FALSE;
}
function LoadFromDatabase($MessageId)
{
global $Errors;
$sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ".$this->IdField()." = '%s'",$MessageId);
$result = $this->adodbConnection->Execute($sql);
if ($result === FALSE)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromDatabase");
return FALSE;
}
$data = $result->fields;
$this->SetFromArray($data);
return TRUE;
}
function EditTemplate()
{
}
/* read the template, split into peices */
function ReadTemplate()
{
if(!$this->TemplateParsed)
{
$this->headers = array();
$lines = explode("\n",$this->Get("Template"));
$header_end = FALSE;
$i = 0;
while(!$header_end && $i<count($lines))
{
$h = $lines[$i];
if(strlen(trim($h))==0 || ($h=="."))
{
$header_end = TRUE;
}
else
{
$parts = explode(":",$h,2);
if(strtolower($parts[0])=="subject")
{
$this->subject = $h;
}
else
$this->headers[] = $h;
}
$i++;
}
while($i<count($lines))
{
$this->body .= $lines[$i++];
}
$this->TemplateParsed=TRUE;
}
}
function ParseSection($text, $parser=null)
{
global $objUsers, $objTemplate;
$res = $this->ParseTemplateText($text);
/* parse email class tags */
if(!is_object($this->fromuser))
{
$this->fromuser = $objUsers->GetItem($this->Get("FromUserId"));
$this->fromuser->TagPrefix = "fromuser";
}
/* parse from user object */
if(is_object($this->fromuser))
{
$res = $this->fromuser->ParseTemplateText($res);
}
/* parse recipient user object */
if(is_object($this->recipient))
{
$res = $this->recipient->ParseTemplateText($res);
}
//print_pre($this->Item);
if(is_object($this->Item))
{
$res = $this->Item->ParseTemplateText($res);
}
else
{
if(!is_object($objTemplate))
$objTemplate = new clsTemplateList(" ");
$res = $objTemplate->ParseTemplateText($res);
}
return $res;
}
function SendToGroup($GroupId)
{
global $objUsers;
$users = $objUsers->Query_GroupPortalUser("GroupId=$GroupId");
if(is_array($users))
{
foreach($users as $u)
{
$this->SendToUser($u->Get("PortalUserId"));
}
}
}
function SendToAddress($EmailAddress,$name="")
{
global $objUsers, $objEmailQueue,$objConfig;
$conn = &GetADODBConnection();
//$this->recipient = $objUsers->GetUser($UserId);
//$this->recipient->TagPrefix="touser";
if(strlen($EmailAddress))
{
$to_addr = $EmailAddress;
$this->ReadTemplate();
$subject = $this->ParseSection($this->subject);
$body = $this->ParseSection($this->body);
if(is_object($this->fromuser))
{
$FromAddr = $this->fromuser->Get("Email");
$FromName = trim($this->fromuser->Get("FirstName")." ".$this->fromuser->Get("LastName"));
}
if(!strlen($FromAddr))
{
$FromName = strip_tags( $objConfig->Get('Site_Name') );
$FromAddr = $objConfig->Get("Smtp_AdminMailFrom");
}
$charset = "ascii-us";
if($this->Get("MessageType")=="html")
{
$objEmailQueue->SendMail($FromAddr,$FromName,$to_addr,$To,$subject,"",$body,$charset, $this->Get("Event"),NULL,$this->headers);
}
else
{
$body = nl2br($body);
$body = str_replace("<br />","\n",$body);
$objEmailQueue->SendMail($FromAddr,$FromName,$to_addr,$To,$subject,$body,"",$charset, $this->Get("Event"),NULL,$this->headers);
}
/*$time = adodb_mktime();
$sql = "INSERT INTO ".GetTablePrefix()."EmailLog VALUES ('', '$FromName', '$To', '$subject', $time, '')";
$conn->Execute($sql); */
return TRUE;
}
return FALSE;
}
function SendToUser($UserId)
{
global $objUsers, $objEmailQueue, $objConfig;
$conn = &GetADODBConnection();
//echo "Handling Event ".$this->Get("Event")." for user $UserId <br>\n";
$this->recipient = new clsPortalUser($UserId); // $objUsers->GetItem($UserId);
//echo "<PRE>";print_r($this->recipient); echo "</PRE>";
$this->recipient->TagPrefix="touser";
if($this->recipient->Get("PortalUserId")==$UserId)
{
$to_addr = $this->recipient->Get("Email");
$To = trim($this->recipient->Get("FirstName")." ".$this->recipient->Get("LastName"));
$this->ReadTemplate();
$subject = $this->ParseSection($this->subject, $this->recipient);
$body = $this->ParseSection($this->body);
if(!is_object($this->fromuser))
{
$this->fromuser = $objUsers->GetItem($this->Get("FromUserId"));
}
if(is_object($this->fromuser))
{
$FromAddr = $this->fromuser->Get("Email");
$FromName = trim($this->fromuser->Get("FirstName")." ".$this->fromuser->Get("LastName"));
$charset = "ascii-us";
}
if(!strlen($FromAddr))
{
$FromName = strip_tags( $objConfig->Get('Site_Name') );
$FromAddr = $objConfig->Get("Smtp_AdminMailFrom");
}
// echo $this->Event;
if($this->Get("MessageType")=="html")
{
$objEmailQueue->SendMail($FromAddr,$FromName,$to_addr,$To,$subject,"",$body,$charset, $this->Get("Event"),NULL,$this->headers);
}
else
{
$body = nl2br($body);
$body = str_replace("<br />","\n",$body);
$objEmailQueue->SendMail($FromAddr,$FromName,$to_addr,$To,$subject,$body,"",$charset, $this->Get("Event"),NULL,$this->headers);
}
/*$time = adodb_mktime();
$sql = "INSERT INTO ".GetTablePrefix()."EmailLog VALUES ('', '$FromName', '$To ($to_addr)', '$subject', $time, '')";
$conn->Execute($sql); */
return TRUE;
}
return FALSE;
}
function SendAdmin()
{
global $objUsers, $objConfig, $objEmailQueue;
$conn = &GetADODBConnection();
$this->recipient = $objUsers->GetUser($this->Get("FromUserId"));
$this->recipient->TagPrefix="touser";
if($this->recipient->Get("PortalUserId")==$this->Get("FromUserId") || strlen($this->recipient->Get("PortalUserId")) == 0)
{
$to_addr = $this->recipient->Get("Email");
$To = trim($this->recipient->Get("FirstName")." ".$this->recipient->Get("LastName"));
$this->ReadTemplate();
if (strlen($to_addr) == 0) {
$to_addr = $objConfig->Get("Smtp_AdminMailFrom");
}
$subject = $this->ParseSection($this->subject);
$body = $this->ParseSection($this->body);
$FromName = strip_tags( $objConfig->Get('Site_Name') );
$FromAddr = $objConfig->Get("Smtp_AdminMailFrom");
if(strlen($FromAddr))
{
$charset = "ascii-us";
if($this->Get("MessageType")=="html")
{
$objEmailQueue->SendMail($FromAddr,$FromName,$to_addr,$To,$subject,"",$body,$charset,$this->Get("Event"),NULL,$this->headers);
}
else
{
$body=nl2br($body);
$body = str_replace("<br />","\n",$body);
$objEmailQueue->SendMail($FromAddr,$FromName,$to_addr,$To,$subject,$body,"",$charset, $this->Get("Event"),NULL,$this->headers);
}
/* $time = adodb_mktime();
$sql = "INSERT INTO ".GetTablePrefix()."EmailLog VALUES ('', '$FromName', '$To ($to_addr)', '$subject', $time, '')";
$conn->Execute($sql);
*/
return TRUE;
}
}
return FALSE;
}
function ParseTemplateText($text)
{
$html = $text;
$search = "<inp:";
//$search = "<inp:".$this->TagPrefix;
//$next_tag = strpos($html,"<inp:");
$next_tag = strpos($html,$search);
while($next_tag)
{
$closer = strpos(strtolower($html),">",$next_tag);
$end_tag = strpos($html,"/>",$next_tag);
if($end_tag < $closer || $closer == 0)
{
$tagtext = substr($html,$next_tag,($end_tag - $next_tag)+2);
$pre = substr($html,0,$next_tag);
$post = substr($html,$end_tag+2);
$inner = $this->ParseElement($tagtext);
$html = $pre.$inner.$post;
}
else
{
$OldTagStyle = "</inp>";
## Try to find end of TagName
$TagNameEnd = strpos($html, " ", $next_tag);
## Support Old version
// $closer = strpos(strtolower($html),"</inp>",$next_tag);
if ($TagNameEnd)
{
$Tag = strtolower(substr($html, $next_tag, $TagNameEnd-$next_tag));
$TagName = explode(":", $Tag);
if (strlen($TagName[1]))
$CloserTag = "</inp:".$TagName[1].">";
}
else
{
$CloserTag = $OldTagStyle;
}
$closer = strpos(strtolower($html), $CloserTag, $next_tag);
## Try to find old tag closer
if (!$closer && ($CloserTag != $OldTagStyle))
{
$CloserTag = $OldTagStyle;
$closer = strpos(strtolower($html), $CloserTag, $next_tag);
}
$end_tag = strpos($html,">",$next_tag);
$tagtext = substr($html,$next_tag,($end_tag - $next_tag)+1);
$pre = substr($html,0,$next_tag);
$inner = substr($html,$end_tag+1,$closer-($end_tag+1));
$post = substr($html,$end_tag+1+strlen($inner) + strlen($CloserTag));
//echo "PRE:". htmlentities($pre,ENT_NOQUOTES);
//echo "INNER:". htmlentities($inner,ENT_NOQUOTES);
//echo "POST:". htmlentities($post,ENT_NOQUOTES);
$parsed = $this->ParseElement($tagtext);
if(strlen($parsed))
{
$html = $pre.$this->ParseTemplateText($inner).$post;
}
else
$html = $pre.$post;
}
$next_tag = strpos($html,$search);
}
return $html;
}
function ParseElement($raw, $inner_html ="")
{
$tag = new clsHtmlTag($raw);
$tag->inner_html = $inner_html;
if($tag->parsed)
{
if($tag->name=="include" || $tag->name=="perm_include" || $tag->name=="lang_include")
{
$output = $this->Parser->IncludeTemplate($tag);
}
else
{
if (is_object($this->Item)) {
$this->Item->TagPrefix = $tag->name;
$output = $this->Item->ParseObject($tag);
}
else {
$output = $this->ParseObject($tag);
}
if(substr($output,0,9)=="Undefined")
{
$output = $tag->Execute();
// if(substr($output,0,8)="{Unknown")
// $output = $raw;
} return $output;
}
}
else
return "";
}
}
class clsEmailMessageList extends clsItemCollection
{
function clsEmailMessageList()
{
$this->clsItemCollection();
$this->classname = "clsEmailMessage";
$this->SourceTable = GetTablePrefix()."EmailMessage";
$this->PerPageVar = "Perpage_EmailEvents";
$this->AdminSearchFields = array("Template","Description", "Module","Event");
}
function LoadLanguage($LangId=NULL)
{
global $objLanguages;
if(!$LangId)
$LangId = $objLanguages->GetPrimary();
$sql = "SELECT * FROM ".$this->SourceTable." WHERE LanguageId=$LangId";
$this->Clear();
return $this->Query_Item($sql);
}
function &AddEmailEvent($Template, $Type, $LangId, $EventId)
{
$e = new clsEmailMessage();
$e->tablename = $this->SourceTable;
$e->Set(array("Template","MessageType","LanguageId","EventId"),
array($Template,$Type,$LangId,$EventId));
$e->Dirty();
$e->Create();
return $e;
}
function DeleteLanguage($LangId)
{
$sql = "DELETE FROM ".$this->SourceTable." WHERE LanguageId=$LangId OR LanguageId = 0";
if( $GLOBALS['debuglevel'] ) echo $sql."<br>\n";
$this->adodbConnection->Execute($sql);
}
function &GetMessage($EventId,$LangId,$LoadFromDB=TRUE)
{
$found=FALSE;
if(is_array($this->Items))
{
for($x=0;$x<count($this->Items);$x++)
{
$i =& $this->GetItemRefByIndex($x);
if(is_object($i))
{
if($i->Get("EventId")==$EventId && $i->Get("LanguageId")==$LangId)
{
$found=TRUE;
break;
}
}
}
}
if(!$found)
{
if($LoadFromDB)
{
$n = NULL;
$n = new $this->classname();
$n->tablename = $this->SourceTable;
if($n->LoadEvent($EventId,$LangId))
{
array_push($this->Items, $n);
$i =& $this->Items[count($this->Items)-1];
}
else
$i = FALSE;
}
else
$i = FALSE;
}
return $i;
}
function CreateEmptyEditTable($IdList, $use_parent = false)
{
global $objSession;
if (!$use_parent) {
$edit_table = $objSession->GetEditTable($this->SourceTable);
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
$query = "SELECT * FROM ".$this->SourceTable." WHERE 0";
$insert = "CREATE TABLE ".$edit_table." ".$query;
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($insert,ENT_NOQUOTES)."<br>\n";
$this->adodbConnection->Execute($insert);
$this->LoadLanguage();
$idvalue = -1;
for($i=0;$i<$this->NumItems();$i++)
{
$e =& $this->Items[$i];
$e->SourceTable = $edit_table;
if(is_array($IdList))
{
foreach($IdList as $id)
{
$e->UnsetIdField();
$e->Set("EmailMessageId",$idvalue--);
$e->Set("LanguageId",$id);
// $e->Set("Description",admin_language("la_desc_emailevent_".$e->Get("Event"),$id));
$e->Create();
}
}
else
{
$e->UnsetIdField();
$e->Set("EmailMessageId",$idvalue--);
$e->Set("LanguageId",$IdList);
// $e->Set("Description",admin_language("la_desc_emailevent_".$e->Get("Event"),$LangId));
$e->Create();
}
}
$this->Clear();
}
else {
parent::CreateEmptyEditTable($IdList);
}
}
function CopyFromEditTable()
{
global $objSession;
$GLOBALS['_CopyFromEditTable']=1;
$idfield = "EmailMessageId";
$edit_table = $objSession->GetEditTable($this->SourceTable);
$sql = "SELECT * FROM $edit_table WHERE LanguageId <> 0";
$rs = $this->adodbConnection->Execute($sql);
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$c = new $this->classname;
$c->SetFromArray($data);
//$c->idfield = $idfield;
if($c->Get($idfield)<1)
{
$old_id = $c->Get($idfield);
$c->Dirty();
$c->UnsetIdField();
$c->Create();
}
else
{
$c->Dirty();
$c->Update();
}
$rs->MoveNext();
}
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
unset($GLOBALS['_CopyFromEditTable']);
}
function PurgeEditTable()
{
global $objSession;
$edit_table = $objSession->GetEditTable($this->SourceTable);
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
}
function &GetEmailEventObject($EventName,$Type=0,$LangId=NULL)
{
global $objLanguages;
if(!$LangId)
$LangId = $objLanguages->GetPrimary();
$EmailTable = $this->SourceTable;
$EventTable = GetTablePrefix()."Events";
$sql = "SELECT * FROM $EventTable INNER JOIN $EmailTable ON ($EventTable.EventId = $EmailTable.EventId) ";
$sql .="WHERE Event='$EventName' AND LanguageId=$LangId AND Type=$Type";
$result = $this->adodbConnection->Execute($sql);
if ($result === FALSE)
{
//$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"","clsEvent","GetEmailEventObject");
return FALSE;
}
$data = $result->fields;
$e = new clsEmailMessage();
$e->SetFromArray($data);
$e->Clean();
return $e;
}
function ReadImportTable($TableName,$Overwrite=FALSE, $MaxInserts=100,$Offset=0)
{
$eml = new clsEmailMessageList();
$this->Clear();
$Inserts = 0;
$sql = "SELECT * FROM $TableName LIMIT $Offset,$MaxInserts";
$this->Query_Item($sql);
if($this->NumItems()>0)
{
foreach($this->Items as $i)
{
$e = $eml->GetMessage($i->Get("EventId"),$i->Get("LanguageId"));
if(is_object($e))
{
if($Overwrite)
{
$e->Set("MessageType",$i->Get("MessageType"));
$e->Set("Template",$i->Get("Template"));
$e->Update();
}
}
else
{
$i->Create();
}
$Inserts++;
}
}
$Offset = $Offset + $Inserts;
return $Offset;
}
}
function EventEnabled($e)
{
global $objConfig;
$var = "Email_".$e."_Enabled";
return ($objConfig->Get($var)=="1");
}
class clsEmailQueue
{
var $SourceTable;
var $MessagesAtOnce;
var $MessagesSent=0;
var $LogLevel = 0;
var $HLB = "\n"; // Headers Line Break
var $BLB = "\n"; // Body Line Break
function clsEmailQueue($SourceTable=NULL,$MessagesAtOnce=NULL)
{
global $objConfig;
$this->HLB = chr(10);
$this->BLB = chr(10);
if($SourceTable)
{
$this->SourceTable=$SourceTable;
}
else
$this->SourceTable = GetTablePrefix()."EmailQueue";
if(!$MessagesAtOnce)
$MessagesAtOnce = (int)$objConfig->Get("Email_MaxSend");
if($MessagesAtOnce<1)
$MessagesAtOnce=1;
$this->MessagesAtOnce = $MessagesAtOnce;
$this->LogLevel = (int)$objConfig->Get("Smtp_LogLevel");
}
function WriteToMailLog($text)
{
global $pathtoroot,$admin;
//echo htmlentities($text)."<br>\n";
if($this->LogLevel>0)
{
$Logfile = $pathtoroot.$admin."/email/log.txt";
if(is_writable($Logfile))
{
$fp = fopen($Logfile,"a");
if($fp)
{
fputs($fp,$text."\n");
fclose($fp);
}
}
}
}
function AllowSockets()
{
$minver = explode(".", "4.3.0");
$curver = explode(".", phpversion());
if (($curver[0] < $minver[0])
|| (($curver[0] == $minver[0])
&& ($curver[1] < $minver[1]))
|| (($curver[0] == $minver[0]) && ($curver[1] == $minver[1])
&& ($curver[2][0] < $minver[2][0])))
return false;
else
return true;
}
function DeliverMail($To,$From,$Subject,$Msg,$headers, $ForceSend=0)
{
global $MessagesSent,$objConfig;
if(($this->MessagesSent >$this->MessagesAtOnce) && !$ForceSend)
{
$this->EnqueueMail($To,$From,$Subject,$Msg,$headers);
return TRUE;
}
else
{
$this->MessagesSent++;
$time = adodb_mktime();
$conn = &GetADODBConnection();
/* $sql = "INSERT INTO ".GetTablePrefix()."EmailLog VALUES ('', '".htmlspecialchars($From)."', '".htmlspecialchars($To)."', '$Subject', $time, '')";
$conn->Execute($sql);*/
$headers = "Date: ".adodb_date("r")."\n".$headers;
$headers = "Return-Path: ".$objConfig->Get("Smtp_AdminMailFrom")."\n".$headers;
/* ensure headers are using \r\n instead of \n */
$headers = str_replace("\n\n","\r\n\r\n",$headers);
$headers = str_replace("\r\n","\n",$headers);
$headers = str_replace("\n","\r\n",$headers);
// if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
$Msg = str_replace("\n\n","\r\n\r\n",$Msg);
$Msg = str_replace("\r\n","\n",$Msg);
$Msg = str_replace("\n","\r\n",$Msg);
// }
//echo "<PRE>"; print_r(htmlentities($headers)); echo "</PRE>";
//echo "<PRE>"; print_r(htmlentities($Msg)); echo "</PRE>";
$ver = phpversion();
if(substr($Subject,0,9)=="Subject: ")
$Subject = substr($Subject,9);
if(!strlen($objConfig->Get("Smtp_Server")) || !$this->AllowSockets())
{
return mail($To,trim($Subject),$Msg, $headers);
}
+ $headers = "To: <".$To.">"."\n".$headers;
$headers = "Subject: ".trim($Subject)."\r\n".$headers;
$send_params['recipients'] = array($To); // The recipients (can be multiple)
$send_params['from'] = $From; // This is used as in the MAIL FROM: cmd
$send_params['headers'] = explode("\r\n",$headers);
// It should end up as the Return-Path: header
$send_params['body'] = $Msg; // The body of the email
$params['host'] = $objConfig->Get("Smtp_Server"); // The smtp server host/ip
$params['port'] = 25; // The smtp server port
$params['hello'] = 'INPORTAL'; // What to use when sending the helo command. Typically, your domain/hostname
if($objConfig->Get("Smtp_Authenticate")) // Whether to use basic authentication or not
{
$params['auth'] = TRUE;
$params['user'] = $objConfig->Get("Smtp_User");
$params['pass'] = $objConfig->get("Smtp_Pass");
}
else
$params['auth'] = FALSE;
$this->LogLevel=0;
$SmtpServer = new smtp($params);
if($this->LogLevel>0)
{
$SmtpServer->debug=1;
foreach($params as $key=>$value)
{
$this->WriteToMailLog($key."=".$value);
}
}
else
{
//$SmtpServer->debug = 1;
}
$connected = $SmtpServer->connect();
if($connected)
{
if($this->LogLevel>1)
{
$this->WriteToMailLog("Connected to ".$params['host']);
}
$res = $SmtpServer->send($send_params);
}
$SmtpServer->disconnect();
if($this->LogLevel>1)
{
foreach($SmtpServer->buffer as $l)
{
$this->WriteToMailLog($l);
}
}
if($this->LogLevel>0)
{
if(count($SmtpServer->errors)>0)
{
foreach($SmtpServer->errors as $e)
{
$this->WriteToMailLog($e);
}
}
else
$this->WriteToMailLog("Message to $From Delivered Successfully");
}
unset($SmtpServer);
return $res;
}
}
function EnqueueMail($To,$From,$Subject,$Msg,$headers)
{
global $objSession;
$ado = &GetADODBConnection();
$To = mysql_escape_string($To);
$From = mysql_escape_string($From);
$Msg = mysql_escape_string($Msg);
$headers = mysql_escape_string($headers);
$Subject = mysql_escape_string($Subject);
$sql = "INSERT INTO ".$this->SourceTable." (toaddr,fromaddr,subject,message,headers) VALUES ('$To','$From','$Subject','$Msg','$headers')";
$ado->Execute($sql);
}
function SendMailQeue()
{
global $objConfig, $objSession, $TotalMessagesSent;
$ado = &GetADODBConnection();
$MaxAllowed = $this->MessagesAtOnce;
$del_sql = array();
$NumToSend = $MaxAllowed - $this->MessagesSent;
if($NumToSend < 0) $NumToSend=1; // Don't really know why, but this could happend, so issued this temp fix
$sql = "SELECT * FROM ".$this->SourceTable." ORDER BY queued ASC LIMIT $NumToSend";
$rs = $ado->Execute($sql);
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$this->DeliverMail($data["toaddr"],$data["fromaddr"],$data["Subject"],$data["headers"],$data["message"],1);
$del_sql[] = "DELETE FROM ".$this->SourceTable." WHERE queued='".$data["queued"]."'";
$rs->MoveNext();
}
$numdel = count($del_sql);
for($i=0;$i<$numdel;$i++)
{
$sql = $del_sql[$i];
if(strlen($sql))
$ado->Execute($sql);
if($objSession->HasSystemPermission("DEBUG.ITEM"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
}
}
function SendMail($From, $FromName, $ToAddr, $ToName, $Subject, $Text, $Html, $charset, $SendEvent,
$FileName="",$FileLoc="",$QueueOnly=0,$extra_headers = array())
{
$HasFile = FALSE;
$HasFile = (strlen($FileName)>0);
$OB="----=_OuterBoundary_000".md5( uniqid (rand()));
$boundary = "-----=".md5( uniqid (rand()));
$f = "\"$FromName\" <".$From.">";
$headers = "From: $f"."\n";
- if(strlen($ToName)>0)
- {
- $To = "\"$ToName\" <$ToAddr>";
- }
- else {
- $To = "<".$ToAddr.">";
- }
-
- $headers.="To: $To"."\n";
$headers .= "MIME-Version: 1.0"."\n";
$conn = &GetADODBConnection();
$time = adodb_mktime();
$sendTo = $ToName;
if (strlen($sendTo) > 0) {
$sendTo .= "($ToAddr)";
}
else {
$sendTo = $ToAddr;
}
$sendTo=addslashes($sendTo);
$sql = "INSERT INTO ".GetTablePrefix()."EmailLog VALUES ('', ".$conn->qstr($FromName).", ".$conn->qstr($sendTo).", ".$conn->qstr( str_replace("Subject:", "", $Subject) ).", $time, '$SendEvent')";
$conn->Execute($sql);
$msg .="This is a multi-part message in MIME format."."\n"."\n";
if($HasFile)
{
//Messages start with text/html alternatives in OB
$headers.="Content-Type: multipart/mixed;"."\n"."\tboundary=\"".$OB."\""."\n"."\n";
$msg.="--".$OB."\n";
$msg.="Content-Type: multipart/alternative; boundary=\"$boundary\""."\n"."\n"."\n";
}
else {
$headers .= "Content-Type: multipart/alternative; boundary=\"$boundary\""."\n";
}
if(is_array($extra_headers))
{
for($i=0;$i<count($extra_headers);$i++);
{
$headers .= $extra_headers[$i]."\n";
}
}
if(!$Text)
{
$Text=strip_tags($Html);
}
$msg .= "--" . $boundary . "\n";
$msg .= "Content-Type: text/plain; charset=\"$charset\""."\n";
$msg .= "Content-Transfer-Encoding: 8bit"."\n"."\n";
$msg .= stripslashes($Text);
$msg .= "\n"."\n";
if(strlen($Html)>0)
{
$msg .= "--" . $boundary . "\n";
$msg .= "Content-Type: text/html; charset=\"iso-8859-1\""."\n";
$msg .= "Content-Transfer-Encoding: 8bit"."\n"."\n";
$msg .= stripslashes($Html);
$msg .= "\n"."\n";
}
$msg .= "--" . $boundary . "--"."\n";
if($HasFile)
{
if(!strlen($FileLoc)) {
$FileLoc = $FileName;
}
$FileName = basename($FileName);
$msg .= "\n"."--".$OB."\n";
$msg.="Content-Type: application/octetstream;"."\n"."\tname=\"".$FileName."\""."\n";
$msg.="Content-Transfer-Encoding: base64"."\n";
$msg.="Content-Disposition: attachment;"."\n"."\tfilename=\"".$FileName."\""."\n"."\n";
//file goes here
$fd=fopen ($FileLoc, "r");
if($fd)
{
$FileContent=fread($fd,filesize($FileLoc));
fclose ($fd);
}
$FileContent=chunk_split(base64_encode($FileContent));
$msg .= $FileContent."\n";
$msg .= "--".$OB."--"."\n";
}
if($this->MessagesSent>$this->MessagesAtOnce || $QueueOnly==1)
{
$this->EnqueueMail($ToAddr,$From,$Subject,$msg,$headers);
}
else
{
$this->DeliverMail($ToAddr,$From,$Subject,$msg,$headers);
}
}
}
?>
Property changes on: trunk/kernel/include/emailmessage.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.51
\ No newline at end of property
+1.52
\ No newline at end of property
Index: trunk/admin/install/upgrades/changelog_1_1_5.txt
===================================================================
--- trunk/admin/install/upgrades/changelog_1_1_5.txt (revision 3519)
+++ trunk/admin/install/upgrades/changelog_1_1_5.txt (revision 3520)
@@ -1,261 +1,268 @@
File in-portal/admin/include/elements.php changed
File in-portal/admin/install/inportal_data.sql changed
File in-portal/admin/install/langpacks/english.lang changed
File in-portal/admin/install/upgrades/changelog_1_1_5.txt is new
File in-portal/admin/install/upgrades/inportal_upgrade_v1.1.4.php changed
File in-portal/admin/install/upgrades/inportal_upgrade_v1.1.5.sql is new
File in-portal/admin/install/upgrades/readme_1_1_5.txt is new
File in-portal/admin/listview/listview.php changed
File in-portal/kernel/action.php changed
File in-portal/kernel/admin/include/help/configure_general.txt changed
+File in-portal/kernel/include/emailmessage.php changed
File in-portal/kernel/include/image.php changed
File in-portal/kernel/include/itemreview.php changed
File in-portal/kernel/include/parseditem.php changed
File in-portal/kernel/include/relationship.php changed
+File in-portal/kernel/include/smtp.php changed
+File in-portal/kernel/include/usersession.php changed
File in-portal/kernel/units/categories/categories_event_handler.php changed
+File in-portal/kernel/units/general/inp_ses_storage.php changed
File in-portal/kernel/units/users/users_event_handler.php changed
File in-portal/themes/inlink2/access_denied.tpl is removed
File in-portal/themes/inlink2/add_link.tpl is removed
File in-portal/themes/inlink2/add_review.tpl is removed
File in-portal/themes/inlink2/box_search.tpl is removed
File in-portal/themes/inlink2/box_subscribe.tpl is removed
File in-portal/themes/inlink2/box_suggest.tpl is removed
File in-portal/themes/inlink2/confirm.tpl is removed
File in-portal/themes/inlink2/custom_field.tpl is removed
File in-portal/themes/inlink2/details.tpl is removed
File in-portal/themes/inlink2/display_cat_search.tpl is removed
File in-portal/themes/inlink2/display_link_search.tpl is removed
File in-portal/themes/inlink2/display_search_results.tpl is removed
File in-portal/themes/inlink2/error.tpl is removed
File in-portal/themes/inlink2/favorites.tpl is removed
File in-portal/themes/inlink2/footer.tpl is removed
File in-portal/themes/inlink2/header.tpl is removed
File in-portal/themes/inlink2/index.tpl is removed
File in-portal/themes/inlink2/list_cats.tpl is removed
File in-portal/themes/inlink2/list_fav_links.tpl is removed
File in-portal/themes/inlink2/list_feature_links.tpl is removed
File in-portal/themes/inlink2/list_links.tpl is removed
File in-portal/themes/inlink2/list_rel_cats.tpl is removed
File in-portal/themes/inlink2/list_reviews.tpl is removed
File in-portal/themes/inlink2/login.tpl is removed
File in-portal/themes/inlink2/menu_navigation.tpl is removed
File in-portal/themes/inlink2/menu_user.tpl is removed
File in-portal/themes/inlink2/modify.tpl is removed
File in-portal/themes/inlink2/modify_link.tpl is removed
File in-portal/themes/inlink2/new.tpl is removed
File in-portal/themes/inlink2/pick.tpl is removed
File in-portal/themes/inlink2/pop.tpl is removed
File in-portal/themes/inlink2/profile.tpl is removed
File in-portal/themes/inlink2/rate.tpl is removed
File in-portal/themes/inlink2/registration.tpl is removed
File in-portal/themes/inlink2/reviews.tpl is removed
File in-portal/themes/inlink2/search_advanced_cats.tpl is removed
File in-portal/themes/inlink2/search_advanced_links.tpl is removed
File in-portal/themes/inlink2/send_password.tpl is removed
File in-portal/themes/inlink2/send_password_confirm.tpl is removed
File in-portal/themes/inlink2/show_cats.tpl is removed
File in-portal/themes/inlink2/show_links.tpl is removed
File in-portal/themes/inlink2/show_related_cats.tpl is removed
File in-portal/themes/inlink2/sort_cats.tpl is removed
File in-portal/themes/inlink2/sort_links.tpl is removed
File in-portal/themes/inlink2/statistics.tpl is removed
File in-portal/themes/inlink2/style.css is removed
File in-portal/themes/inlink2/sub_pages.tpl is removed
File in-portal/themes/inlink2/subscribe.tpl is removed
File in-portal/themes/inlink2/suggest_cat.tpl is removed
File in-portal/themes/inlink2/top.tpl is removed
File in-portal/themes/inlink2/addreview/review_confirm.tpl is removed
File in-portal/themes/inlink2/addreview/review_confirm_new.tpl is removed
File in-portal/themes/inlink2/addreview/review_confirm_pending.tpl is removed
File in-portal/themes/inlink2/addreview/review_form.tpl is removed
File in-portal/themes/inlink2/advsearch/adv_searchtype_options.tpl is removed
File in-portal/themes/inlink2/advsearch/advsearch_item.tpl is removed
File in-portal/themes/inlink2/advsearch/advsearch_type.tpl is removed
File in-portal/themes/inlink2/advsearch/alt_item_form.tpl is removed
File in-portal/themes/inlink2/advsearch/alt_item_form_last.tpl is removed
File in-portal/themes/inlink2/advsearch/item_form.tpl is removed
File in-portal/themes/inlink2/advsearch/item_form_last.tpl is removed
File in-portal/themes/inlink2/edit_link/modify_confirm.tpl is removed
File in-portal/themes/inlink2/edit_link/modify_confirm_pending.tpl is removed
File in-portal/themes/inlink2/edit_link/modify_link_element.tpl is removed
File in-portal/themes/inlink2/edit_link/modify_link_form.tpl is removed
File in-portal/themes/inlink2/favorites/list_favorites.tpl is removed
File in-portal/themes/inlink2/favorites/no_favorites.tpl is removed
File in-portal/themes/inlink2/images/arrow.gif is removed
File in-portal/themes/inlink2/images/brand_logo.gif is removed
File in-portal/themes/inlink2/images/chinese_big5.gif is removed
File in-portal/themes/inlink2/images/chinese_gb.gif is removed
File in-portal/themes/inlink2/images/default.gif is removed
File in-portal/themes/inlink2/images/dice.gif is removed
File in-portal/themes/inlink2/images/dutch.gif is removed
File in-portal/themes/inlink2/images/english.gif is removed
File in-portal/themes/inlink2/images/finnish.gif is removed
File in-portal/themes/inlink2/images/folder.gif is removed
File in-portal/themes/inlink2/images/french.gif is removed
File in-portal/themes/inlink2/images/german.gif is removed
File in-portal/themes/inlink2/images/icon1.gif is removed
File in-portal/themes/inlink2/images/icon10.gif is removed
File in-portal/themes/inlink2/images/icon11.gif is removed
File in-portal/themes/inlink2/images/icon2.gif is removed
File in-portal/themes/inlink2/images/icon3.gif is removed
File in-portal/themes/inlink2/images/icon4.gif is removed
File in-portal/themes/inlink2/images/icon5.gif is removed
File in-portal/themes/inlink2/images/icon6.gif is removed
File in-portal/themes/inlink2/images/icon7.gif is removed
File in-portal/themes/inlink2/images/icon8.gif is removed
File in-portal/themes/inlink2/images/icon9.gif is removed
File in-portal/themes/inlink2/images/inlink2_logo.gif is removed
File in-portal/themes/inlink2/images/italian.gif is removed
File in-portal/themes/inlink2/images/polish.gif is removed
File in-portal/themes/inlink2/images/portuguese.gif is removed
File in-portal/themes/inlink2/images/right_logo.gif is removed
File in-portal/themes/inlink2/images/romanian.gif is removed
File in-portal/themes/inlink2/images/russian.gif is removed
File in-portal/themes/inlink2/images/spacer.gif is removed
File in-portal/themes/inlink2/images/spanish.gif is removed
File in-portal/themes/inlink2/images/star.gif is removed
File in-portal/themes/inlink2/images/star_rate.gif is removed
File in-portal/themes/inlink2/images/swedish.gif is removed
File in-portal/themes/inlink2/images/thai.gif is removed
File in-portal/themes/inlink2/images/ticon0.gif is removed
File in-portal/themes/inlink2/images/ticon1.gif is removed
File in-portal/themes/inlink2/images/ticon10.gif is removed
File in-portal/themes/inlink2/images/ticon11.gif is removed
File in-portal/themes/inlink2/images/ticon12.gif is removed
File in-portal/themes/inlink2/images/ticon13.gif is removed
File in-portal/themes/inlink2/images/ticon14.gif is removed
File in-portal/themes/inlink2/images/ticon15.gif is removed
File in-portal/themes/inlink2/images/ticon16.gif is removed
File in-portal/themes/inlink2/images/ticon17.gif is removed
File in-portal/themes/inlink2/images/ticon18.gif is removed
File in-portal/themes/inlink2/images/ticon19.gif is removed
File in-portal/themes/inlink2/images/ticon2.gif is removed
File in-portal/themes/inlink2/images/ticon20.gif is removed
File in-portal/themes/inlink2/images/ticon21.gif is removed
File in-portal/themes/inlink2/images/ticon3.gif is removed
File in-portal/themes/inlink2/images/ticon4.gif is removed
File in-portal/themes/inlink2/images/ticon5.gif is removed
File in-portal/themes/inlink2/images/ticon6.gif is removed
File in-portal/themes/inlink2/images/ticon7.gif is removed
File in-portal/themes/inlink2/images/ticon8.gif is removed
File in-portal/themes/inlink2/images/ticon9.gif is removed
File in-portal/themes/inlink2/images/tr.gif is removed
File in-portal/themes/inlink2/lang_menu/lang_menu_element.tpl is removed
File in-portal/themes/inlink2/login/box_login.tpl is removed
File in-portal/themes/inlink2/login/loggedin.tpl is removed
File in-portal/themes/inlink2/login/login.tpl is removed
File in-portal/themes/inlink2/login/notloggedin.tpl is removed
File in-portal/themes/inlink2/mailing_list/confirm_subscribe.tpl is removed
File in-portal/themes/inlink2/mailing_list/confirm_unsubscribe.tpl is removed
File in-portal/themes/inlink2/mailing_list/error.tpl is removed
File in-portal/themes/inlink2/mailing_list/subscribe.tpl is removed
File in-portal/themes/inlink2/mailing_list/unsubscribe.tpl is removed
File in-portal/themes/inlink2/misc/form_error.tpl is removed
File in-portal/themes/inlink2/misc/form_prompt.tpl is removed
File in-portal/themes/inlink2/misc/form_prompt_error.tpl is removed
File in-portal/themes/inlink2/profile/english_countries.tpl is removed
File in-portal/themes/inlink2/profile/myinfo_dob.tpl is removed
File in-portal/themes/inlink2/rate/rate_confirm.tpl is removed
File in-portal/themes/inlink2/rate/rate_duplicate.tpl is removed
File in-portal/themes/inlink2/rate/rate_form.tpl is removed
File in-portal/themes/inlink2/rating/0.gif is removed
File in-portal/themes/inlink2/rating/0_half.gif is removed
File in-portal/themes/inlink2/rating/1.gif is removed
File in-portal/themes/inlink2/rating/1_half.gif is removed
File in-portal/themes/inlink2/rating/2.gif is removed
File in-portal/themes/inlink2/rating/2_half.gif is removed
File in-portal/themes/inlink2/rating/3.gif is removed
File in-portal/themes/inlink2/rating/3_half.gif is removed
File in-portal/themes/inlink2/rating/4.gif is removed
File in-portal/themes/inlink2/rating/4_half.gif is removed
File in-portal/themes/inlink2/rating/5.gif is removed
File in-portal/themes/inlink2/register/english_countries.tpl is removed
File in-portal/themes/inlink2/register/register_confirm.tpl is removed
File in-portal/themes/inlink2/register/register_dob.tpl is removed
File in-portal/themes/inlink2/register/register_notallowed.tpl is removed
File in-portal/themes/inlink2/register/register_pending.tpl is removed
File in-portal/themes/inlink2/relevance/0.gif is removed
File in-portal/themes/inlink2/relevance/1.gif is removed
File in-portal/themes/inlink2/relevance/10.gif is removed
File in-portal/themes/inlink2/relevance/2.gif is removed
File in-portal/themes/inlink2/relevance/3.gif is removed
File in-portal/themes/inlink2/relevance/4.gif is removed
File in-portal/themes/inlink2/relevance/5.gif is removed
File in-portal/themes/inlink2/relevance/6.gif is removed
File in-portal/themes/inlink2/relevance/7.gif is removed
File in-portal/themes/inlink2/relevance/8.gif is removed
File in-portal/themes/inlink2/relevance/9.gif is removed
File in-portal/themes/inlink2/search_results/cat_search_results.tpl is removed
File in-portal/themes/inlink2/search_results/error.tpl is removed
File in-portal/themes/inlink2/search_results/link_search_results.tpl is removed
File in-portal/themes/inlink2/search_results/list_search_cats.tpl is removed
File in-portal/themes/inlink2/search_results/list_search_links.tpl is removed
File in-portal/themes/inlink2/search_results/search_count.tpl is removed
File in-portal/themes/inlink2/suggest_cat/suggest_cat_confirm.tpl is removed
File in-portal/themes/inlink2/suggest_cat/suggest_cat_confirm_pending.tpl is removed
File in-portal/themes/inlink2/suggest_cat/suggest_cat_form.tpl is removed
File in-portal/themes/inlink2/suggest_link/suggest_confirm.tpl is removed
File in-portal/themes/inlink2/suggest_link/suggest_confirm_pending.tpl is removed
File in-portal/themes/inlink2/suggest_link/suggest_link_form.tpl is removed
File in-portal/themes/inlink2/theme_menu/theme_menu_element.tpl is removed
File kernel4_dev/kernel4/application.php changed
File kernel4_dev/kernel4/parser/tags.php changed
File kernel4_dev/kernel4/processors/main_processor.php changed
File kernel4_dev/kernel4/session/session.php changed
+File kernel4_dev/kernel4/utility/email.php changed
+File kernel4_dev/kernel4/utility/formatters.php changed
+File cmseditor/fckconfig.js changed
Changes in phrases and events:
Added label "la_config_use_js_redirect" of type "1"
Changed label "la_Description_in-link:inlink_paid_listings" of type "1"
Changed label "la_Description_in-link:inlink_paid_listings" of type "1"
Changed label "la_Description_in-portal:configure_styles" of type "1"
Changed label "la_Description_in-portal:configure_styles" of type "1"
Changed label "la_event_user.membership_expiration_notice" of type "1"
Changed label "la_event_user.membership_expired" of type "1"
Changed label "la_event_user.membership_expiration_notice" of type "1"
Changed label "la_event_user.membership_expired" of type "1"
Changed label "la_MembershipExpirationReminder" of type "1"
Changed label "la_MembershipExpirationReminder" of type "1"
Changed label "la_promt_ReferrerCheck" of type "1"
Changed label "la_promt_ReferrerCheck" of type "1"
Changed label "la_users_assign_all_to" of type "1"
Changed label "la_users_assign_all_to" of type "1"
Changed label "lu_fieldcustom__a" of type "2"
Changed label "lu_fieldcustom__a" of type "2"
Changed label "lu_fieldcustom__samplefield" of type "2"
Changed label "lu_fieldcustom__samplefield" of type "2"
Added label "lu_fieldcustom__user_from" of type "2"
Changed event "USER.VALIDATE" of type "1"
Changed event "USER.APPROVE" of type "0"
Changed event "USER.UNSUBSCRIBE" of type "0"
Changed event "CATEGORY.ADD.PENDING" of type "0"
Added event "USER.PSWD" of type "0"
Changed event "USER.SUBSCRIBE" of type "1"
Changed event "USER.APPROVE" of type "0"
Changed event "USER.DENY" of type "1"
Changed event "USER.UNSUBSCRIBE" of type "0"
Changed event "USER.VALIDATE" of type "0"
Changed event "CATEGORY.ADD.PENDING" of type "1"
Changed event "USER.ADD" of type "1"
Changed event "USER.SUBSCRIBE" of type "1"
Removed event "USER.ADD" of type "1"
Removed event "CATEGORY.APPROVE" of type "1"
Removed event "USER.DENY" of type "1"
Removed event "CATEGORY.ADD.PENDING" of type "1"
Removed event "CATEGORY.DENY" of type "0"
Removed event "CATEGORY.APPROVE" of type "0"
Added event "CATEGORY.APPROVE" of type "1"
Added event "USER.VALIDATE" of type "0"
Changed event "CATEGORY.ADD" of type "0"
Changed event "CATEGORY.APPROVE" of type "0"
Changed event "CATEGORY.DENY" of type "0"
Changed event "USER.PSWDC" of type "0"
Changed event "CATEGORY.ADD.PENDING" of type "0"
Changed event "CATEGORY.ADD" of type "0"
Added event "USER.PSWDC" of type "0"
Removed event "USER.ADD.PENDING" of type "0"
Removed event "USER.PSWD" of type "0"
Added event "USER.ADD.PENDING" of type "0"
Added event "USER.VALIDATE" of type "1"
Property changes on: trunk/admin/install/upgrades/changelog_1_1_5.txt
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7
\ No newline at end of property
+1.8
\ No newline at end of property

Event Timeline