Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F772924
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Feb 1, 9:00 PM
Size
46 KB
Mime Type
text/x-diff
Expires
Mon, Feb 3, 9:00 PM (1 d, 12 h)
Engine
blob
Format
Raw Data
Handle
556203
Attached To
rINP In-Portal
in-portal
View Options
Index: trunk/kernel/include/emailmessage.php
===================================================================
--- trunk/kernel/include/emailmessage.php (revision 293)
+++ trunk/kernel/include/emailmessage.php (revision 294)
@@ -1,884 +1,888 @@
<?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;
//$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 = $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,NULL,$this->headers);
}
else
{
$body = nl2br($body);
$body = str_replace("<br />","\n",$body);
$objEmailQueue->SendMail($FromAddr,$FromName,$to_addr,$To,$subject,$body,"",$charset,NULL,$this->headers);
}
return TRUE;
}
return FALSE;
}
function SendToUser($UserId)
{
global $objUsers, $objEmailQueue, $objConfig;
//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 = $objConfig->Get("Site_Name");
$FromAddr = $objConfig->Get("Smtp_AdminMailFrom");
}
if($this->Get("MessageType")=="html")
{
$objEmailQueue->SendMail($FromAddr,$FromName,$to_addr,$To,$subject,"",$body,$charset,NULL,$this->headers);
}
else
{
$body = nl2br($body);
$body = str_replace("<br />","\n",$body);
$objEmailQueue->SendMail($FromAddr,$FromName,$to_addr,$To,$subject,$body,"",$charset,NULL,$this->headers);
}
return TRUE;
}
return FALSE;
}
function SendAdmin()
{
global $objUsers, $objConfig, $objEmailQueue;
$this->recipient = $objUsers->GetUser($this->Get("FromUserId"));
$this->recipient->TagPrefix="touser";
if($this->recipient->Get("PortalUserId")==$this->Get("FromUserId"))
{
$to_addr = $this->recipient->Get("Email");
$To = trim($this->recipient->Get("FirstName")." ".$this->recipient->Get("LastName"));
$this->ReadTemplate();
$subject = $this->ParseSection($this->subject);
$body = $this->ParseSection($this->body);
$FromName = "System Event";
$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,NULL,$this->headers);
}
else
{
$body=nl2br($body);
$body = str_replace("<br />","\n",$body);
$objEmailQueue->SendMail($FromAddr,$FromName,$to_addr,$To,$subject,$body,"",$charset,NULL,$this->headers);
}
return TRUE;
}
}
return FALSE;
}
function ParseTemplateText($text)
{
$html = $text;
$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)) {
$output = $this->Item->ParseObject($tag);
}
else {
$output = $this->ParseObject($tag);
}
//echo $output."<br>";
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 &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)
{
global $objSession;
$edit_table = $objSession->GetEditTable($this->SourceTable);
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
$query = "SELECT * FROM ".$this->SourceTable." WHERE $idfield = -1";
$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();
}
function CopyFromEditTable()
{
global $objSession;
$idfield = "EmailMessageId";
$edit_table = $objSession->GetEditTable($this->SourceTable);
$sql = "SELECT * FROM $edit_table";
$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");
}
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,$Overwite=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;
function clsEmailQueue($SourceTable=NULL,$MessagesAtOnce=NULL)
{
global $objConfig;
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++;
/* ensure headers are using \r\n instead of \n */
//$headers = str_replace("\r\n","\n",$headers);
//$headers = str_replace("\n","\r\n",$headers);
$headers = "Date: ".date("r")."\n".$headers;
$headers = "Return-Path: ".$objConfig->Get("Smtp_AdminMailFrom")."\n".$headers;
//$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 = "Subject: ".trim($Subject)."\r\n".$headers;
-
+
$send_params['recipients'] = array($To); // The recipients (can be multiple)
$send_params['headers'] = explode("\r\n",$headers);
$send_params['from'] = $From; // This is used as in the MAIL FROM: cmd
// 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['helo'] = '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 = 0;
$connected = $SmtpServer->connect();
+
+
+
if($connected)
{
if($this->LogLevel>1)
{
$this->WriteToMailLog("Connected to ".$params['host']);
}
- $res = $SmtpServer->send($send_params);
+ $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;
$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,
$FileName="",$FileLoc="",$QueueOnly=0,$extra_headers = array())
{
$HasFile = FALSE;
$HasFile = (strlen($FileName)>0);
$OB="----=_OuterBoundary_000";
$boundary = "-----=".md5( uniqid (rand()));
$f = "\"$FromName\" <".$From.">";
$headers = "From: $f\n";
$headers .= "MIME-Version: 1.0\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";
}
else
$headers .= "Content-Type: multipart/alternative; boundary=\"$boundary\"";
if(is_array($extra_headers))
{
for($i=0;$i<count($extra_headers);$i++);
{
$headers .= $extra_headers[$i]."\n";
}
}
$msg .="This is a multi-part message in MIME format.\n\n";
$msg .= "--" . $boundary . "\n";
$msg .= "Content-Type: text/plain; charset=\"$charset\"\r\n";
$msg .= "Content-Transfer-Encoding: 8bit\r\n";
$msg .= stripslashes($Text);
$msg .= "\r\n\r\n";
if(strlen($Html)>0)
{
$msg .= "--" . $boundary . "\n";
$msg .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$msg .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
$msg .= stripslashes($Html);
$msg .= "\r\n\r\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."\"\r\n";
$msg.="Content-Transfer-Encoding: base64\n";
$msg.="Content-Disposition: attachment;\n\tfilename=\"".$FileName."\"\r\n\r\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;
$msg .= "--".$OB."\n";
}
if(strlen($ToName)>0)
{
$To = "\"$ToName\" <$ToAddr>";
}
else
$To = "<".$ToAddr.">";
//$headers.="To: $To\r\n";
if($this->MessagesSent>$this->MessagesAtOnce || $QueueOnly==1)
{
$this->EnqueueMail($To,$f,$Subject,$msg,$headers);
}
else
{
$this->DeliverMail($To,$f,$Subject,$msg,$headers);
}
}
}
?>
Property changes on: trunk/kernel/include/emailmessage.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.23
\ No newline at end of property
+1.24
\ No newline at end of property
Index: trunk/admin/include/elements.php
===================================================================
--- trunk/admin/include/elements.php (revision 293)
+++ trunk/admin/include/elements.php (revision 294)
@@ -1,612 +1,612 @@
<?php
##############################################################
##In-portal :: Administration Interfaces :: Common Elements ##
##############################################################
## In-portal ##
## Intechnic Corporation ##
## All Rights Reserved, 1998-2002 ##
## ##
## No portion of this code may be copied, reproduced or ##
## otherwise redistributed without proper written ##
## consent of Intechnic Corporation. Violation will ##
## result in revocation of the license and support ##
## privileges along maximum prosecution allowed by law. ##
##############################################################
if( !isset($is_install) ) $is_install = false;
if(!$is_install)
{
if (!admin_login())
{
if(!headers_sent()) {
setcookie("sid"," ",time()-3600);
echo "Test";
}
$objSession->Logout();
header("Location: ".$adminURL."/login.php");
die();
//require_once($pathtoroot."admin/login.php");
}
}
global $admin,$pathtoroot, $objConfig;
if(!strlen($admin))
{
$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
{
$admin = "admin";
}
}
require_once($pathtoroot.$admin."/include/sections.php");
$envar = "env=" . BuildEnv();
/* this function loads the javascript for each module's toolbar */
-function load_module_javascript($sectionname)
+function load_module_javascript($sectionname, $skip_modules = Array() )
{
global $adminURL, $pathtoroot;
echo "<SCRIPT LANGUAGE=JavaScript1.2 src=\"".$adminURL."/browse/fw_menu.js\"></SCRIPT>\n";
echo "<SCRIPT LANGUAGE=JavaScript1.2 src=\"".$adminURL."/include/tabs.js\"></SCRIPT>\n";
echo "<script language=\"JavaScript1.2\" src=\"$adminURL/include/checkarray.js\"></script>\n";
global $objConfig, $ItemTabs;
$m = GetModuleArray("admin");
echo "<!-- ".count($m)."-->";
foreach($m as $key=>$value)
{
$path = $pathtoroot. $value."admin/include/toolbar/".$sectionname.".php";
-
- if(file_exists($path))
+ if( !in_array($value, $skip_modules) && file_exists($path) )
{
echo "\n<!-- $path -->\n";
include_once($path);
}
else
echo "\n<!-- $path not found -->\n";
}
}
function load_module_styles()
{
global $objConfig, $ItemTabs,$rootURL,$pathtoroot;
$m = GetModuleArray("admin");
echo "<!-- module styles (".count($m).")-->";
foreach($m as $key=>$value)
{
$path = $pathtoroot.$value."admin/include/style.css";
if(file_exists($path))
{
$inc = $rootURL.$value."admin/include/style.css";
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$inc\">\n";
}
}
}
//***********************************
//Page Header
-function int_header($toolbar=NULL,$NavBarText=NULL,$ExtraTitle=NULL,$onLoad=NULL, $ExtraHead=NULL)
+function int_header($toolbar=NULL,$NavBarText=NULL,$ExtraTitle=NULL,$onLoad=NULL, $ExtraHead=NULL,$skip_modules=Array())
{
global $pathtoroot;
global $pathtolocal;
global $section;
global $objSections;
global $rootURL;
global $localURL;
global $adminURL;
global $envar;
global $admin;
global $metatag;
-
+
$style_sheet_global = $adminURL."/include/style.css";
$style_sheet_local = $localURL."admin/include/style.css";
$ExtraTitle = htmlentities($ExtraTitle);
if (is_object($toolbar))
{
if(file_exists($pathtolocal."admin/include/toolbar.php"))
require_once ($pathtolocal."admin/include/toolbar.php");
//Aray of the preloaded elems
//$int_toolbar_preload = array();
print "<html><head><title>In-portal</title>\n";
if(strlen($metatag))
{
print $metatag."\n";
}
else
{
print "<meta http-equiv=\"content-type\" content=\"text/html;charset=iso-8859-1\">\n";
print "<meta http-equiv=\"Pragma\" content=\"no-cache\">\n";
}
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$style_sheet_global\">\n";
load_module_styles();
require_once($pathtoroot.$admin."/include/mainscript.php");
//require_once($pathtolocal."admin/include/script.js");
print $ExtraHead;
$sectionname = explode(":", $section);
$sectionname = $sectionname[sizeof($sectionname)-1];
- load_module_javascript($sectionname);
+
+ load_module_javascript($sectionname, $skip_modules);
if(is_object($toolbar))
print $toolbar->GetInitScript();
print "</head><body topmargin=\"0\" leftmargin=\"8\" marginheight=\"8\" marginwidth=\"8\" bgcolor=\"#FFFFFF\"";
//*** Preload toolbar images
if(strlen($onLoad))
{
print $onLoad;
}
else
print " ONLOAD=\"clear_list_checkboxes();\"";
//*** Preload toolbar images
if(is_object($toolbar))
{
if (strlen($toolbar->Get("CheckClass")))
{
print $toolbar->onLoadString().">";
}
else
print " >";
$menufunc = $toolbar->Get("load_menu_func");
if (strlen($menufunc))
{
print "<script language=\"JavaScript1.2\">$menufunc</script>";
}
}
else
print " >";
}
else
{
print "<html><head><title>In-Portal </title>";
print "<meta http-equiv=\"content-type\" content=\"text/html;charset=iso-8859-1\">";
print "<meta http-equiv=\"Pragma\" content=\"no-cache\">";
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$style_sheet_global\">";
load_module_styles();
require_once ($pathtoroot.$admin."/include/mainscript.php");
//require_once ($pathtolocal."admin/include/script.js");
$sectionname = explode(":", $section);
$sectionname = $sectionname[sizeof($sectionname)-1];
load_module_javascript($sectionname);
print "</head><body topmargin=\"0\" leftmargin=\"8\" marginheight=\"8\" marginwidth=\"8\" bgcolor=\"#FFFFFF\">";
}
if(strlen($section)>0)
{
$objSections->SetCurrentSection($section);
$sec = $objSections->GetCurrentSection();
if ($sec->Get("notitle") != 1) print $objSections->page_title();
print $objSections->page_tabs($envar);
if ($sec->Get("nonavbar") != 1) //Section Navigatior
print $objSections->section_header($envar,$NavBarText,$ExtraTitle);
//Toolbar if appropriate
if ( isset($sections[$section]) && ($sections[$section]['toolbar']==1) || ( is_object($toolbar) ) )
print $toolbar->Build();
}
}//Page Header
// HELP Page Header
function int_help_header()
{
global $pathtoroot;
global $pathtolocal;
global $section;
global $objSections;
global $rootURL;
global $localURL;
global $adminURL;
global $envar;
global $admin;
global $metatag;
$style_sheet_global = $adminURL."/include/style.css";
$style_sheet_local = $localURL."admin/include/style.css";
$ExtraTitle = htmlentities($ExtraTitle);
// TOOLBAR:
print "<html><head><title>In-Portal - Help</title>";
print "<meta http-equiv=\"content-type\" content=\"text/html;charset=iso-8859-1\">";
print "<meta http-equiv=\"Pragma\" content=\"no-cache\">";
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$style_sheet_global\">";
load_module_styles();
require_once ($pathtoroot.$admin."/include/mainscript.php");
print "</head><body topmargin=\"0\" leftmargin=\"8\" marginheight=\"8\" marginwidth=\"8\" bgcolor=\"#FFFFFF\">";
if(strlen($section)>0)
{
$objSections->SetCurrentSection($section);
$sec = $objSections->GetCurrentSection();
if ($sec->Get("notitle") != 1) print $objSections->page_title();
if ($sec->Get("nonavbar") != 1) //Section Navigatior
print $objSections->section_header($envar,$NavBarText,$ExtraTitle, true);
}
}// HELP Page Header
function int_SectionHeader($toolbar=NULL,$onLoad=NULL,$NavBarText=NULL,$ExtraTitle=NULL)
{
global $pathtoroot;
global $pathtolocal;
global $section, $sections;
global $objSections;
global $rootURL;
global $adminURL,$admin;
global $localURL;
global $envar;
global $b_topmargin;
if (!isset($b_topmargin))
$b_topmargin = 8;
$sectionname = explode(":", $section);
$sectionname = $sectionname[sizeof($sectionname)-1];
load_module_javascript($sectionname);
if(is_object($toolbar))
print $toolbar->GetInitScript();
print "</head><body topmargin=\"$b_topmargin\" leftmargin=\"8\" marginheight=\"$b_topmargin\" marginwidth=\"8\" bgcolor=\"#FFFFFF\"";
//*** Preload toolbar images
if(strlen($onLoad))
{
print $onLoad;
}
else
print " onload=\"if (clear_checkboxes) clear_checkboxes();\"";
print ">";
global $b_header_addon;
if (isset($b_header_addon)) echo $b_header_addon;
if(strlen($section)>0)
{
$objSections->SetCurrentSection($section);
$sec = $objSections->GetCurrentSection();
if ($sec->Get("notitle")!=1)
print $objSections->page_title();
print $objSections->page_tabs($envar);
//Section Navigatior
if ($sec->Get("nonavbar")!=1)
{
if (is_null($ExtraTitle))
$ExtraTitle = "";
print $objSections->section_header($envar,$NavBarText,$ExtraTitle);
}
//Toolbar if appropriate
if( isset($sections[$section]) )
if($sections[$section]['toolbar'] == 1 || (is_object($toolbar)) )
print $toolbar->Build();
}
}//Section Page Header
//***********************************
//SubSection Title
function int_subsection_title($caption)
{
int_table_color(1);
print <<<END
<!-- Subsection Title -->
<tr class="subsectiontitle">
<td colspan="5">$caption</td>
</tr>
END;
}
function int_subsection_title_install($caption)
{
int_table_color(1);
print <<<END
<!-- Subsection Title -->
<tr class="subsectiontitle">
<td colspan="3">$caption</td>
</tr>
END;
}
function int_subsection_title_ret($caption)
{
int_table_color_ret(1);
$o = "<!-- Subsection Title --><tr class=\"subsectiontitle\"><td colspan=\"5\">$caption</td></tr>";
return $o;
}
//SubSection Title
//***********************************
//Table Alternating colors
function int_table_color($reset_color=0, $return_result = false)
{
static $colorset;
if($reset_color)
{ $colorset="table_color2";
return;
}
if ($colorset == "table_color1")
$colorset = "table_color2";
else
$colorset = "table_color1";
$ret = "class=\"".$colorset."\"";
if($return_result)
return $ret;
else
print $ret;
}//Table Alternating colors
//Table Alternating colors with return
function int_table_color_ret($reset_color=0)
{
static $colorset;
if($reset_color)
{ $colorset="table_color2";
return;
}
if ($colorset == "table_color1")
$colorset = "table_color2";
else
$colorset = "table_color1";
return "class=\"".$colorset."\"";
}//Table Alternating colors
//***********************************
//Hint
function int_hint($caption)
{
global $imagesURL;
print <<<END
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td>
<span class="hint"><img src="$imagesURL/smicon7.gif" width="14" height="14" align="absmiddle">$caption</span>
<td>
</tr>
</table>
END;
}//Hint
function int_hint_red($caption)
{
global $imagesURL;
print <<<END
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td>
<span class="hint_red">$caption</span>
<td>
</tr>
</table>
END;
}//Hint
//***********************************
//Navigation String
function int_nav($caption)
{
global $pathtoroot;
global $imagespath;
print <<<END
<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#f0f0f0">
<tr>
<td><b class="text"><span class="navbar"><a class="navbar" href="">$caption</a></span></b></td>
</tr>
</table>
END;
}//Navigation String
//***********************************
//Print Out Images
function int_img($img)
{
global $images;
global $pathtoroot;
global $imagesURL;
$src = $imagesURL."/".$images[$img]['file'];
$alt = $images[$img]['alt'];
$width = $images[$img]['width'];
$height = $images[$img]['height'];
$name = $img;
//Set ID if needed
if ($img == 'img:tool:view')
$id = "ID=\"viewbutton\"";
print "<img alt=\"$alt\" name=\"$name\" src=\"$src\" width=\"$width\" height=\"$height\" $id border=\"0\" align=\"absmiddle\">";
}//Print Out Images
//***********************************
//Page Footer
function int_footer()
{
global $objSession;
if($objSession->HasSystemPermission("DEBUG.INFO"))
{
//phpinfo();
}
print <<<END
</body>
</html>
END;
}//Page Footer
function HomeEnv()
{
global $m_var_list_update;
$m_var_list_update["cat"]=0;
return BuildEnv();
}
function UpEnv()
{
global $m_var_list_update,$objCatList;
$current = $objCatList->CurrentCat();
$parent = $current->Get("ParentId");
$m_var_list_update["cat"]=$parent;
return BuildEnv();
}
function ModuleInclude($file)
{
global $pathtoroot;
$m = GetModuleArray();
foreach($m as $key=>$value)
{
$path = $pathtoroot.$value.$file;
if(file_exists($path))
{
echo "<!-- $path -->";
@include_once($path);
}
}
}
function MultiEditButtons(&$ToolBar,$next,$prev,$Form,$StatusField, $url,$onClick, $ExtraVar="", $prev_phrase = 'Phrase Not Passed', $next_phrase = 'Phrase Not Passed')
{
global $adminURL;
$ToolBar->Add("divider");
if($prev>-1)
{
$MouseOver="swap('moveleft','toolbar/tool_prev_f2.gif');";
$MouseOut="swap('moveleft', 'toolbar/tool_prev.gif');";
$var="env=".BuildEnv()."&en=$prev&lpn=".GetVar('lpn');
if (strlen($ExtraVar))
$var.= $ExtraVar;
if ($onClick != 'LangSubmitMove') {
$link = "javascript:edit_submit('$Form','$StatusField','$url',0,'$var');";
}
else {
$link = "javascript:$onClick('$url', '$prev')";
}
$ToolBar->Add("moveleft",$prev_phrase,$link,$MouseOver,$MouseOut,"","toolbar/tool_prev.gif");
}
else
{
$MouseOver="";
$MouseOut="";
//$onClick="";
$link="#";
$ToolBar->Add("moveleft",$prev_phrase,"#","","","","toolbar/tool_prev_f3.gif");
}
if($next>-1)
{
$MouseOver="swap('moveright','toolbar/tool_next_f2.gif');";
$MouseOut="swap('moveright', 'toolbar/tool_next.gif');";
$var="env=".BuildEnv()."&en=$next".( isset($_REQUEST['lpn']) ? '&lpn='.$_REQUEST['lpn'] : '');
if (strlen($ExtraVar))
$var.= $ExtraVar;
if ($onClick != 'LangSubmitMove') {
$link = "javascript:edit_submit('$Form','$StatusField','$url',0,'$var');";
}
else {
$link = "javascript:$onClick('$url', '$next')";
}
$ToolBar->Add("moveright",$next_phrase,$link,$MouseOver,$MouseOut,"","toolbar/tool_next.gif");
}
else
{
$ToolBar->Add("moveright",$next_phrase,"#","","","","toolbar/tool_next_f3.gif");
}
}
function InsertButtons(&$ToolBar, $Buttons = Array(), $params = Array() )
{
foreach($Buttons as $button)
switch($button)
{
case 'save':
$ToolBar->Add( "img_save", "la_Save", "#",
"swap('img_save','toolbar/tool_select_f2.gif');",
"swap('img_save', 'toolbar/tool_select.gif');",
"edit_submit('".$params['form']."','".$params['status_field']."','".$params['url']."',1,'&lpn=".$_REQUEST['lpn']."');","tool_select.gif");
break;
case 'cancel':
$ToolBar->Add( "img_cancel", "la_Cancel", "#",
"swap('img_cancel','toolbar/tool_cancel_f2.gif');",
"swap('img_cancel', 'toolbar/tool_cancel.gif');",
"edit_submit('".$params['form']."','".$params['status_field']."','".$params['url']."',2,'&lpn=".$_REQUEST['lpn']."');","tool_cancel.gif");
break;
case 'edit':
break;
case 'delete':
break;
}
}
function GetTitle($item_phrase, $tab_phrase, $id)
{
// gets correct caption for editing windows with tabs
//echo "In: $item_phrase, $tab_phrase, $id";
$is_new = ($_REQUEST['new'] == 1) ? 1 : 0;
$text = $is_new ? 'la_Text_Adding' : 'la_Text_Editing';
$text = admin_language($text).' '.admin_language($item_phrase);
if($is_new == 0) $text .= ' #'.$id;
$text .= ' - '.admin_language($tab_phrase);
return $text;
}
function MarkFields($form_name)
{
// mark specified form fields as required
?> <script language="JavaScript">MarkAsRequired(document.getElementById("<?php echo $form_name; ?>"));</script> <?php
}
?>
Property changes on: trunk/admin/include/elements.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Event Timeline
Log In to Comment