aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof <ports@bsdserwis.com>2023-11-14 17:09:14 +0000
committerMuhammad Moinur Rahman <bofh@FreeBSD.org>2023-11-15 11:54:06 +0000
commit070336bc5567aa8f8e1bdc2c2474890280b17e80 (patch)
treebfdeb619d5b27234a1e76e870ce85b60499a3279
parentc061bb27af2e36396388f7a472bf83a9e4c42069 (diff)
downloadports-070336bc5567aa8f8e1bdc2c2474890280b17e80.tar.gz
ports-070336bc5567aa8f8e1bdc2c2474890280b17e80.zip
security/mailzu: Add support for php80
PR: 263614 Approved by: submitter is maintainer
-rw-r--r--security/mailzu/Makefile2
-rw-r--r--security/mailzu/files/patch-config_langs.php4
-rw-r--r--security/mailzu/files/patch-lib-DBEngine.class.php9
-rw-r--r--security/mailzu/files/patch-lib_AmavisdEngine.class.php11
-rw-r--r--security/mailzu/files/patch-lib_DBAuth.class.php11
-rw-r--r--security/mailzu/files/patch-lib_ExchAuth.class.php11
-rw-r--r--security/mailzu/files/patch-lib_IMAPAuth.class.php11
-rw-r--r--security/mailzu/files/patch-lib_LDAPEngine.class.php9
-rw-r--r--security/mailzu/files/patch-lib_Link.class.php11
-rw-r--r--security/mailzu/files/patch-lib_MailEngine.class.php11
-rw-r--r--security/mailzu/files/patch-lib_MailMime.class.php27
-rw-r--r--security/mailzu/files/patch-lib_PHPMailer.class.php3085
-rw-r--r--security/mailzu/files/patch-lib_Pager.class.php1262
-rw-r--r--security/mailzu/files/patch-lib_Template.class.php9
-rw-r--r--security/mailzu/files/patch-lib_htmlfilter.php140
15 files changed, 4603 insertions, 10 deletions
diff --git a/security/mailzu/Makefile b/security/mailzu/Makefile
index f1ce3496e73a..c80c527092e2 100644
--- a/security/mailzu/Makefile
+++ b/security/mailzu/Makefile
@@ -1,6 +1,6 @@
PORTNAME= mailzu
DISTVERSION= 0.8rc3
-PORTREVISION= 10
+PORTREVISION= 11
CATEGORIES= security
MASTER_SITES= SF/${PORTNAME}/${PORTNAME}/MailZu%200.8RC3
PKGNAMESUFFIX= ${PHP_PKGNAMESUFFIX}
diff --git a/security/mailzu/files/patch-config_langs.php b/security/mailzu/files/patch-config_langs.php
index acda9c7f41de..21b04fafea08 100644
--- a/security/mailzu/files/patch-config_langs.php
+++ b/security/mailzu/files/patch-config_langs.php
@@ -6,7 +6,7 @@
'it' => array('it([-_][[:alpha:]]{2})?|italian', 'it.lang.php', 'it', 'Italiano'),
- 'pt_BR' => array('pt([-_]br)?|portuguese', 'pt_BR.lang.php', 'pt', 'Portuguese Brazilian')
+ 'pt_BR' => array('pt([-_]br)?|portuguese', 'pt_BR.lang.php', 'pt', 'Portuguese Brazilian'),
-+ 'pl' => array('cs([-_][[:alpha:]]{2})?|polish', 'pl.lang.php', 'pl', 'Polski')
++ 'pl' => array('pl([-_][[:alpha:]]{2})?|polish', 'pl.lang.php', 'pl', 'Polski')
);
// Language files directory
@@ -19,7 +19,7 @@
for ($i = 0; $i < count($http_accepted); $i++) {
foreach ($languages as $lang => $vals) {
- if (eregi($vals[0], $http_accepted[$i]))
-+ if (preg_match($vals[0], $http_accepted[$i]))
++ if (preg_match("/".$vals[0]."/", $http_accepted[$i]))
return $lang;
}
}
diff --git a/security/mailzu/files/patch-lib-DBEngine.class.php b/security/mailzu/files/patch-lib-DBEngine.class.php
index 88c09dd2ed75..b859eca89497 100644
--- a/security/mailzu/files/patch-lib-DBEngine.class.php
+++ b/security/mailzu/files/patch-lib-DBEngine.class.php
@@ -1,5 +1,14 @@
--- lib/DBEngine.class.php.orig 2007-06-14 19:00:15 UTC
+++ lib/DBEngine.class.php
+@@ -67,7 +67,7 @@ class DBEngine {
+ * DBEngine constructor to initialize object
+ * @param none
+ */
+- function DBEngine() {
++ function __construct() {
+ global $conf;
+
+ $this->dbType = $conf['db']['dbType'];
@@ -133,35 +133,35 @@ class DBEngine {
MAX(stattable.pending) AS pending
FROM (
diff --git a/security/mailzu/files/patch-lib_AmavisdEngine.class.php b/security/mailzu/files/patch-lib_AmavisdEngine.class.php
new file mode 100644
index 000000000000..230f813c3942
--- /dev/null
+++ b/security/mailzu/files/patch-lib_AmavisdEngine.class.php
@@ -0,0 +1,11 @@
+--- lib/AmavisdEngine.class.php.orig 2007-06-14 19:00:15 UTC
++++ lib/AmavisdEngine.class.php
+@@ -48,7 +48,7 @@ class AmavisdEngine {
+ * $param none
+ * $return object Amavisd object
+ */
+- function AmavisdEngine($host) {
++ function __construct($host) {
+
+ $this->socket = new Net_Socket();
+ $this->port = $GLOBALS['conf']['amavisd']['spam_release_port'];
diff --git a/security/mailzu/files/patch-lib_DBAuth.class.php b/security/mailzu/files/patch-lib_DBAuth.class.php
new file mode 100644
index 000000000000..fa63252d7358
--- /dev/null
+++ b/security/mailzu/files/patch-lib_DBAuth.class.php
@@ -0,0 +1,11 @@
+--- lib/DBAuth.class.php.orig 2007-06-14 19:00:15 UTC
++++ lib/DBAuth.class.php
+@@ -81,7 +81,7 @@ class DBAuth {
+ * DBEngine constructor to initialize object
+ * @param none
+ */
+- function DBAuth() {
++ function __construct() {
+ global $conf;
+
+ $this->dbType = $conf['auth']['dbType'];
diff --git a/security/mailzu/files/patch-lib_ExchAuth.class.php b/security/mailzu/files/patch-lib_ExchAuth.class.php
new file mode 100644
index 000000000000..38cfbaad464d
--- /dev/null
+++ b/security/mailzu/files/patch-lib_ExchAuth.class.php
@@ -0,0 +1,11 @@
+--- lib/ExchAuth.class.php.orig 2007-06-14 19:00:15 UTC
++++ lib/ExchAuth.class.php
+@@ -55,7 +55,7 @@ class ExchAuth {
+ * @param string $domain
+ * @return boolean
+ */
+- function authUser($username, $password, $domain) {
++ function __construct($username, $password, $domain) {
+
+ $fulluser = $domain.'/'.$username;
+ $mbox = imap_open('{'.$this->exchHost.'/imap}Inbox', $fulluser, $password);
diff --git a/security/mailzu/files/patch-lib_IMAPAuth.class.php b/security/mailzu/files/patch-lib_IMAPAuth.class.php
new file mode 100644
index 000000000000..db38328ffa02
--- /dev/null
+++ b/security/mailzu/files/patch-lib_IMAPAuth.class.php
@@ -0,0 +1,11 @@
+--- lib/IMAPAuth.class.php.orig 2007-06-14 19:00:15 UTC
++++ lib/IMAPAuth.class.php
+@@ -36,7 +36,7 @@ class IMAPAuth {
+ * Constructor to initialize object
+ * @param none
+ */
+- function IMAPAuth() {
++ function __construct() {
+ global $conf;
+
+ $this->imapHosts = $conf['auth']['imap_hosts'];
diff --git a/security/mailzu/files/patch-lib_LDAPEngine.class.php b/security/mailzu/files/patch-lib_LDAPEngine.class.php
index 05783036ec9c..aad40967fa14 100644
--- a/security/mailzu/files/patch-lib_LDAPEngine.class.php
+++ b/security/mailzu/files/patch-lib_LDAPEngine.class.php
@@ -1,5 +1,14 @@
--- lib/LDAPEngine.class.php.orig 2007-06-14 19:00:15 UTC
+++ lib/LDAPEngine.class.php
+@@ -93,7 +93,7 @@ class LDAPEngine {
+ /**
+ * LDAPEngine constructor to initialize object
+ */
+- function LDAPEngine() {
++ function __construct() {
+ global $conf;
+
+ $this->serverType = strtolower($conf['auth']['serverType']);
@@ -283,6 +283,7 @@ class LDAPEngine {
*/
function searchUserDN($searchFilter) {
diff --git a/security/mailzu/files/patch-lib_Link.class.php b/security/mailzu/files/patch-lib_Link.class.php
new file mode 100644
index 000000000000..f7ecebd0d5b5
--- /dev/null
+++ b/security/mailzu/files/patch-lib_Link.class.php
@@ -0,0 +1,11 @@
+--- lib/Link.class.php.orig 2007-06-14 19:00:15 UTC
++++ lib/Link.class.php
+@@ -29,7 +29,7 @@ class Link {
+ * @param string $text_on_over text to display in status bar onmouseover
+ * @param string $on_over javascript to call onmouseover
+ */
+- function Link($url=null, $text=null, $class=null, $style=null, $text_on_over=null) {
++ function __construct($url=null, $text=null, $class=null, $style=null, $text_on_over=null) {
+ $this->url = $url;
+ $this->text = $text;
+ $this->_class = $class;
diff --git a/security/mailzu/files/patch-lib_MailEngine.class.php b/security/mailzu/files/patch-lib_MailEngine.class.php
new file mode 100644
index 000000000000..4ad9fcc9cbc0
--- /dev/null
+++ b/security/mailzu/files/patch-lib_MailEngine.class.php
@@ -0,0 +1,11 @@
+--- lib/MailEngine.class.php.orig 2007-06-14 19:00:15 UTC
++++ lib/MailEngine.class.php
+@@ -48,7 +48,7 @@ class MailEngine {
+ * $param string The mail addr of the reader
+ * $return object MailEngine object
+ */
+- function MailEngine($mail_id, $recip) {
++ function __construct($mail_id, $recip) {
+ $this->recipient = $recip;
+ $this->getRawContent($mail_id);
+ $this->msg_error = false;
diff --git a/security/mailzu/files/patch-lib_MailMime.class.php b/security/mailzu/files/patch-lib_MailMime.class.php
index b44eb75f73fd..d8c05a9b0ebd 100644
--- a/security/mailzu/files/patch-lib_MailMime.class.php
+++ b/security/mailzu/files/patch-lib_MailMime.class.php
@@ -1,6 +1,24 @@
--- lib/MailMime.class.php.orig 2007-06-14 19:00:15 UTC
+++ lib/MailMime.class.php
-@@ -94,8 +94,14 @@ function MsgParseBody($struct) {
+@@ -59,9 +59,15 @@ function MsgParseBody($struct) {
+
+ global $filelist;
+ global $errors;
+- $ctype_p = strtolower(trim($struct->ctype_primary));
+- $ctype_s = strtolower(trim($struct->ctype_secondary));
+
++ if ( is_object( $struct) ) {
++ $ctype_p = strtolower(trim($struct->ctype_primary));
++ $ctype_s = strtolower(trim($struct->ctype_secondary));
++ } else {
++ $ctype_p = $struct;
++ $ctype_s = "";
++ }
++
+ switch ($ctype_p) {
+ case "multipart":
+ switch ($ctype_s) {
+@@ -94,8 +100,14 @@ function MsgParseBody($struct) {
case "text":
// Do not display attached text types
@@ -17,7 +35,7 @@
array_push($filelist, $attachment);
break;
}
-@@ -117,7 +123,9 @@ function MsgParseBody($struct) {
+@@ -117,7 +129,9 @@ function MsgParseBody($struct) {
default:
// Save the listed filename or notify the
// reader that this mail is not displayed completely
@@ -28,7 +46,7 @@
$attachment ? array_push($filelist, $attachment) : $errors['Unsupported MIME objects present'] = true;
}
-@@ -137,9 +145,9 @@ function FindMultiAlt($parts) {
+@@ -137,9 +151,9 @@ function FindMultiAlt($parts) {
foreach ($parts as $cur_part) {
$type = GetCtype($cur_part);
if ($type == 'multipart/related') {
@@ -41,11 +59,12 @@
}
$altCount = count($alt_pref);
for ($j = $best_view; $j < $altCount; ++$j) {
-@@ -163,7 +171,7 @@ function FindMultiAlt($parts) {
+@@ -163,7 +177,8 @@ function FindMultiAlt($parts) {
*/
function FindMultiRel($struct) {
$entities = array();
- $type = $struct->d_parameters['type'];
++ $type = "";
+ if ( isset( $cur_part->d_parameters['type'] )) { $type = $cur_part->d_parameters['type']; }
// Mozilla bug. Mozilla does not provide the parameter type.
if (!$type) $type = 'text/html';
diff --git a/security/mailzu/files/patch-lib_PHPMailer.class.php b/security/mailzu/files/patch-lib_PHPMailer.class.php
new file mode 100644
index 000000000000..ae290186e73c
--- /dev/null
+++ b/security/mailzu/files/patch-lib_PHPMailer.class.php
@@ -0,0 +1,3085 @@
+--- lib/PHPMailer.class.php.orig 2007-06-14 19:00:15 UTC
++++ lib/PHPMailer.class.php
+@@ -1,1541 +1,1541 @@
+-<?php
+-////////////////////////////////////////////////////
+-// PHPMailer - PHP email class
+-//
+-// Class for sending email using either
+-// sendmail, PHP mail(), or SMTP. Methods are
+-// based upon the standard AspEmail(tm) classes.
+-//
+-// Copyright (C) 2001 - 2003 Brent R. Matzelle
+-//
+-// License: LGPL, see LICENSE
+-////////////////////////////////////////////////////
+-
+-/**
+- * PHPMailer - PHP email transport class
+- * @package PHPMailer
+- * @author Brent R. Matzelle
+- * @copyright 2001 - 2003 Brent R. Matzelle
+- */
+-class PHPMailer
+-{
+- /////////////////////////////////////////////////
+- // PUBLIC VARIABLES
+- /////////////////////////////////////////////////
+-
+- /**
+- * Email priority (1 = High, 3 = Normal, 5 = low).
+- * @var int
+- */
+- var $Priority = 3;
+-
+- /**
+- * Sets the CharSet of the message.
+- * @var string
+- */
+- var $CharSet = "iso-8859-1";
+-
+- /**
+- * Sets the Content-type of the message.
+- * @var string
+- */
+- var $ContentType = "text/plain";
+-
+- /**
+- * Sets the Encoding of the message. Options for this are "8bit",
+- * "7bit", "binary", "base64", and "quoted-printable".
+- * @var string
+- */
+- var $Encoding = "8bit";
+-
+- /**
+- * Holds the most recent mailer error message.
+- * @var string
+- */
+- var $ErrorInfo = "";
+-
+- /**
+- * Sets the From email address for the message.
+- * @var string
+- */
+- var $From = "root@localhost";
+-
+- /**
+- * Sets the From name of the message.
+- * @var string
+- */
+- var $FromName = "Root User";
+-
+- /**
+- * Sets the Sender email (Return-Path) of the message. If not empty,
+- * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
+- * @var string
+- */
+- var $Sender = "";
+-
+- /**
+- * Sets the Subject of the message.
+- * @var string
+- */
+- var $Subject = "";
+-
+- /**
+- * Sets the Body of the message. This can be either an HTML or text body.
+- * If HTML then run IsHTML(true).
+- * @var string
+- */
+- var $Body = "";
+-
+- /**
+- * Sets the text-only body of the message. This automatically sets the
+- * email to multipart/alternative. This body can be read by mail
+- * clients that do not have HTML email capability such as mutt. Clients
+- * that can read HTML will view the normal Body.
+- * @var string
+- */
+- var $AltBody = "";
+-
+- /**
+- * Sets word wrapping on the body of the message to a given number of
+- * characters.
+- * @var int
+- */
+- var $WordWrap = 0;
+-
+- /**
+- * Method to send mail: ("mail", "sendmail", or "smtp").
+- * @var string
+- */
+- var $Mailer = "mail";
+-
+- /**
+- * Sets the path of the sendmail program.
+- * @var string
+- */
+- var $Sendmail = "/usr/sbin/sendmail";
+-
+- /**
+- * Path to PHPMailer plugins. This is now only useful if the SMTP class
+- * is in a different directory than the PHP include path.
+- * @var string
+- */
+- var $PluginDir = "";
+-
+- /**
+- * Holds PHPMailer version.
+- * @var string
+- */
+- var $Version = "1.72";
+-
+- /**
+- * Sets the email address that a reading confirmation will be sent.
+- * @var string
+- */
+- var $ConfirmReadingTo = "";
+-
+- /**
+- * Sets the hostname to use in Message-Id and Received headers
+- * and as default HELO string. If empty, the value returned
+- * by SERVER_NAME is used or 'localhost.localdomain'.
+- * @var string
+- */
+- var $Hostname = "";
+-
+- /////////////////////////////////////////////////
+- // SMTP VARIABLES
+- /////////////////////////////////////////////////
+-
+- /**
+- * Sets the SMTP hosts. All hosts must be separated by a
+- * semicolon. You can also specify a different port
+- * for each host by using this format: [hostname:port]
+- * (e.g. "smtp1.example.com:25;smtp2.example.com").
+- * Hosts will be tried in order.
+- * @var string
+- */
+- var $Host = "localhost";
+-
+- /**
+- * Sets the default SMTP server port.
+- * @var int
+- */
+- var $Port = 25;
+-
+- /**
+- * Sets the SMTP HELO of the message (Default is $Hostname).
+- * @var string
+- */
+- var $Helo = "";
+-
+- /**
+- * Sets SMTP authentication. Utilizes the Username and Password variables.
+- * @var bool
+- */
+- var $SMTPAuth = false;
+-
+- /**
+- * Sets SMTP username.
+- * @var string
+- */
+- var $Username = "";
+-
+- /**
+- * Sets SMTP password.
+- * @var string
+- */
+- var $Password = "";
+-
+- /**
+- * Sets the SMTP server timeout in seconds. This function will not
+- * work with the win32 version.
+- * @var int
+- */
+- var $Timeout = 10;
+-
+- /**
+- * Sets SMTP class debugging on or off.
+- * @var bool
+- */
+- var $SMTPDebug = false;
+-
+- /**
+- * Prevents the SMTP connection from being closed after each mail
+- * sending. If this is set to true then to close the connection
+- * requires an explicit call to SmtpClose().
+- * @var bool
+- */
+- var $SMTPKeepAlive = false;
+-
+- /**#@+
+- * @access private
+- */
+- var $smtp = NULL;
+- var $to = array();
+- var $cc = array();
+- var $bcc = array();
+- var $ReplyTo = array();
+- var $attachment = array();
+- var $CustomHeader = array();
+- var $message_type = "";
+- var $boundary = array();
+- var $language = array();
+- var $error_count = 0;
+- var $LE = "\n";
+- /**#@-*/
+-
+- /////////////////////////////////////////////////
+- // CONSTRUCTOR
+- /////////////////////////////////////////////////
+- /**
+- * Constructor, just set up language
+- * @param none
+- * @return void
+- */
+- function PHPMailer() {
+- global $conf;
+- global $charset;
+-
+- $this->CharSet = $charset;
+-
+- $this->SetLanguage();
+-
+- $this->Mailer = $conf['app']['emailType'];
+-
+- if ($this->Mailer == 'smtp') { // Set smtp variables
+- $this->Host = $conf['app']['smtpHost'];
+- $this->Port = $conf['app']['smtpPort'];
+- }
+-
+- if ($this->Mailer == 'sendmail') // Set sendmail variables
+- $this->Sendmail = $conf['app']['sendmailPath'];
+-
+- if ($this->Mailer == 'qmail') // Set qmail variables
+- $this->Sendmail = $conf['app']['qmailPath'];
+- }
+-
+- /////////////////////////////////////////////////
+- // VARIABLE METHODS
+- /////////////////////////////////////////////////
+-
+- /**
+- * Sets message type to HTML.
+- * @param bool $bool
+- * @return void
+- */
+- function IsHTML($bool) {
+- if($bool == true)
+- $this->ContentType = "text/html";
+- else
+- $this->ContentType = "text/plain";
+- }
+-
+- /**
+- * Sets Mailer to send message using SMTP.
+- * @return void
+- */
+- function IsSMTP() {
+- $this->Mailer = "smtp";
+- }
+-
+- /**
+- * Sets Mailer to send message using PHP mail() function.
+- * @return void
+- */
+- function IsMail() {
+- $this->Mailer = "mail";
+- }
+-
+- /**
+- * Sets Mailer to send message using the $Sendmail program.
+- * @return void
+- */
+- function IsSendmail() {
+- $this->Mailer = "sendmail";
+- }
+-
+- /**
+- * Sets Mailer to send message using the qmail MTA.
+- * @return void
+- */
+- function IsQmail() {
+- $this->Sendmail = "/var/qmail/bin/sendmail";
+- $this->Mailer = "sendmail";
+- }
+-
+-
+- /////////////////////////////////////////////////
+- // RECIPIENT METHODS
+- /////////////////////////////////////////////////
+-
+- /**
+- * Adds a "To" address.
+- * @param string $address
+- * @param string $name
+- * @return void
+- */
+- function AddAddress($address, $name = "") {
+- $cur = count($this->to);
+- $this->to[$cur][0] = trim($address);
+- $this->to[$cur][1] = $name;
+- }
+-
+- /**
+- * Adds a "Cc" address. Note: this function works
+- * with the SMTP mailer on win32, not with the "mail"
+- * mailer.
+- * @param string $address
+- * @param string $name
+- * @return void
+- */
+- function AddCC($address, $name = "") {
+- $cur = count($this->cc);
+- $this->cc[$cur][0] = trim($address);
+- $this->cc[$cur][1] = $name;
+- }
+-
+- /**
+- * Adds a "Bcc" address. Note: this function works
+- * with the SMTP mailer on win32, not with the "mail"
+- * mailer.
+- * @param string $address
+- * @param string $name
+- * @return void
+- */
+- function AddBCC($address, $name = "") {
+- $cur = count($this->bcc);
+- $this->bcc[$cur][0] = trim($address);
+- $this->bcc[$cur][1] = $name;
+- }
+-
+- /**
+- * Adds a "Reply-to" address.
+- * @param string $address
+- * @param string $name
+- * @return void
+- */
+- function AddReplyTo($address, $name = "") {
+- $cur = count($this->ReplyTo);
+- $this->ReplyTo[$cur][0] = trim($address);
+- $this->ReplyTo[$cur][1] = $name;
+- }
+-
+-
+- /////////////////////////////////////////////////
+- // MAIL SENDING METHODS
+- /////////////////////////////////////////////////
+-
+- /**
+- * Creates message and assigns Mailer. If the message is
+- * not sent successfully then it returns false. Use the ErrorInfo
+- * variable to view description of the error.
+- * @return bool
+- */
+- function Send() {
+- $header = "";
+- $body = "";
+- $result = true;
+-
+- if((count($this->to) + count($this->cc) + count($this->bcc)) < 1)
+- {
+- $this->SetError($this->Lang("provide_address"));
+- return false;
+- }
+-
+- // Set whether the message is multipart/alternative
+- if(!empty($this->AltBody))
+- $this->ContentType = "multipart/alternative";
+-
+- $this->error_count = 0; // reset errors
+- $this->SetMessageType();
+- $header .= $this->CreateHeader();
+- $body = $this->CreateBody();
+-
+- // Nick Korbel - 08-21-2005
+- if (version_compare('4.3.0',phpversion(), '<=') == 1) {
+- $this->Subject = html_entity_decode($this->Subject, ENT_COMPAT, $this->CharSet);
+- if ($this->ContentType != "text/html")
+- $body = html_entity_decode($body, ENT_COMPAT, $this->CharSet);
+- }
+-
+- if($body == "") { return false; }
+-
+- // Choose the mailer
+- switch($this->Mailer)
+- {
+- case "sendmail":
+- $result = $this->SendmailSend($header, $body);
+- break;
+- case "mail":
+- $result = $this->MailSend($header, $body);
+- break;
+- case "smtp":
+- $result = $this->SmtpSend($header, $body);
+- break;
+- default:
+- $this->SetError($this->Mailer . $this->Lang("mailer_not_supported"));
+- $result = false;
+- break;
+- }
+-
+- return $result;
+- }
+-
+- /**
+- * Sends mail using the $Sendmail program.
+- * @access private
+- * @return bool
+- */
+- function SendmailSend($header, $body) {
+- if ($this->Sender != "")
+- $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender);
+- else
+- $sendmail = sprintf("%s -oi -t", $this->Sendmail);
+-
+- if(!@$mail = popen($sendmail, "w"))
+- {
+- $this->SetError($this->Lang("execute") . $this->Sendmail);
+- return false;
+- }
+-
+- fputs($mail, $header);
+- fputs($mail, $body);
+-
+- $result = pclose($mail) >> 8 & 0xFF;
+- if($result != 0)
+- {
+- $this->SetError($this->Lang("execute") . $this->Sendmail);
+- return false;
+- }
+-
+- return true;
+- }
+-
+- /**
+- * Sends mail using the PHP mail() function.
+- * @access private
+- * @return bool
+- */
+- function MailSend($header, $body) {
+- $to = "";
+- for($i = 0; $i < count($this->to); $i++)
+- {
+- if($i != 0) { $to .= ", "; }
+- $to .= $this->to[$i][0];
+- }
+-
+- if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1)
+- {
+- $old_from = ini_get("sendmail_from");
+- ini_set("sendmail_from", $this->Sender);
+- $params = sprintf("-oi -f %s", $this->Sender);
+- $rt = @mail($to, $this->EncodeHeader($this->Subject), $body,
+- $header, $params);
+- }
+- else
+- $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);
+-
+- if (isset($old_from))
+- ini_set("sendmail_from", $old_from);
+-
+- if(!$rt)
+- {
+- $this->SetError($this->Lang("instantiate"));
+- return false;
+- }
+-
+- return true;
+- }
+-
+- /**
+- * Sends mail via SMTP using PhpSMTP (Author:
+- * Chris Ryan). Returns bool. Returns false if there is a
+- * bad MAIL FROM, RCPT, or DATA input.
+- * @access private
+- * @return bool
+- */
+- function SmtpSend($header, $body) {
+- include_once($this->PluginDir . "Smtp.class.php");
+- $error = "";
+- $bad_rcpt = array();
+-
+- if(!$this->SmtpConnect())
+- return false;
+-
+- $smtp_from = ($this->Sender == "") ? $this->From : $this->Sender;
+- if(!$this->smtp->Mail($smtp_from))
+- {
+- $error = $this->Lang("from_failed") . $smtp_from;
+- $this->SetError($error);
+- $this->smtp->Reset();
+- return false;
+- }
+-
+- // Attempt to send attach all recipients
+- for($i = 0; $i < count($this->to); $i++)
+- {
+- if(!$this->smtp->Recipient($this->to[$i][0]))
+- $bad_rcpt[] = $this->to[$i][0];
+- }
+- for($i = 0; $i < count($this->cc); $i++)
+- {
+- if(!$this->smtp->Recipient($this->cc[$i][0]))
+- $bad_rcpt[] = $this->cc[$i][0];
+- }
+- for($i = 0; $i < count($this->bcc); $i++)
+- {
+- if(!$this->smtp->Recipient($this->bcc[$i][0]))
+- $bad_rcpt[] = $this->bcc[$i][0];
+- }
+-
+- if(count($bad_rcpt) > 0) // Create error message
+- {
+- for($i = 0; $i < count($bad_rcpt); $i++)
+- {
+- if($i != 0) { $error .= ", "; }
+- $error .= $bad_rcpt[$i];
+- }
+- $error = $this->Lang("recipients_failed") . $error;
+- $this->SetError($error);
+- $this->smtp->Reset();
+- return false;
+- }
+-
+- if(!$this->smtp->Data($header . $body))
+- {
+- $this->SetError($this->Lang("data_not_accepted"));
+- $this->smtp->Reset();
+- return false;
+- }
+- if($this->SMTPKeepAlive == true)
+- $this->smtp->Reset();
+- else
+- $this->SmtpClose();
+-
+- return true;
+- }
+-
+- /**
+- * Initiates a connection to an SMTP server. Returns false if the
+- * operation failed.
+- * @access private
+- * @return bool
+- */
+- function SmtpConnect() {
+- if($this->smtp == NULL) { $this->smtp = new SMTP(); }
+-
+- $this->smtp->do_debug = $this->SMTPDebug;
+- $hosts = explode(";", $this->Host);
+- $index = 0;
+- $connection = ($this->smtp->Connected());
+-
+- // Retry while there is no connection
+- while($index < count($hosts) && $connection == false)
+- {
+- if(strstr($hosts[$index], ":"))
+- list($host, $port) = explode(":", $hosts[$index]);
+- else
+- {
+- $host = $hosts[$index];
+- $port = $this->Port;
+- }
+-
+- if($this->smtp->Connect($host, $port, $this->Timeout))
+- {
+- if ($this->Helo != '')
+- $this->smtp->Hello($this->Helo);
+- else
+- $this->smtp->Hello($this->ServerHostname());
+-
+- if($this->SMTPAuth)
+- {
+- if(!$this->smtp->Authenticate($this->Username,
+- $this->Password))
+- {
+- $this->SetError($this->Lang("authenticate"));
+- $this->smtp->Reset();
+- $connection = false;
+- }
+- }
+- $connection = true;
+- }
+- $index++;
+- }
+- if(!$connection)
+- $this->SetError($this->Lang("connect_host"));
+-
+- return $connection;
+- }
+-
+- /**
+- * Closes the active SMTP session if one exists.
+- * @return void
+- */
+- function SmtpClose() {
+- if($this->smtp != NULL)
+- {
+- if($this->smtp->Connected())
+- {
+- $this->smtp->Quit();
+- $this->smtp->Close();
+- }
+- }
+- }
+-
+- /**
+- * Sets the language for all class error messages. Always in English.
+- * @param none
+- * @access public
+- * @return bool
+- */
+- function SetLanguage() {
+- /**
+- * Only printing errors in english
+- */
+- $PHPMAILER_LANG = array();
+-
+- $PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' .
+- 'recipient email address.';
+- $PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.';
+- $PHPMAILER_LANG["execute"] = 'Could not execute: ';
+- $PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.';
+- $PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.';
+- $PHPMAILER_LANG["from_failed"] = 'The following From address failed: ';
+- $PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' .
+- 'recipients failed: ';
+- $PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.';
+- $PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.';
+- $PHPMAILER_LANG["file_access"] = 'Could not access file: ';
+- $PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: ';
+- $PHPMAILER_LANG["encoding"] = 'Unknown encoding: ';
+-
+- $this->language = $PHPMAILER_LANG;
+-
+- return true;
+- }
+-
+- /////////////////////////////////////////////////
+- // MESSAGE CREATION METHODS
+- /////////////////////////////////////////////////
+-
+- /**
+- * Creates recipient headers.
+- * @access private
+- * @return string
+- */
+- function AddrAppend($type, $addr) {
+- $addr_str = $type . ": ";
+- $addr_str .= $this->AddrFormat($addr[0]);
+- if(count($addr) > 1)
+- {
+- for($i = 1; $i < count($addr); $i++)
+- $addr_str .= ", " . $this->AddrFormat($addr[$i]);
+- }
+- $addr_str .= $this->LE;
+-
+- return $addr_str;
+- }
+-
+- /**
+- * Formats an address correctly.
+- * @access private
+- * @return string
+- */
+- function AddrFormat($addr) {
+- if(empty($addr[1]))
+- $formatted = $addr[0];
+- else
+- {
+- $formatted = $this->EncodeHeader($addr[1], 'phrase') . " <" .
+- $addr[0] . ">";
+- }
+-
+- return $formatted;
+- }
+-
+- /**
+- * Wraps message for use with mailers that do not
+- * automatically perform wrapping and for quoted-printable.
+- * Original written by philippe.
+- * @access private
+- * @return string
+- */
+- function WrapText($message, $length, $qp_mode = false) {
+- $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
+-
+- $message = $this->FixEOL($message);
+- if (substr($message, -1) == $this->LE)
+- $message = substr($message, 0, -1);
+-
+- $line = explode($this->LE, $message);
+- $message = "";
+- for ($i=0 ;$i < count($line); $i++)
+- {
+- $line_part = explode(" ", $line[$i]);
+- $buf = "";
+- for ($e = 0; $e<count($line_part); $e++)
+- {
+- $word = $line_part[$e];
+- if ($qp_mode and (strlen($word) > $length))
+- {
+- $space_left = $length - strlen($buf) - 1;
+- if ($e != 0)
+- {
+- if ($space_left > 20)
+- {
+- $len = $space_left;
+- if (substr($word, $len - 1, 1) == "=")
+- $len--;
+- elseif (substr($word, $len - 2, 1) == "=")
+- $len -= 2;
+- $part = substr($word, 0, $len);
+- $word = substr($word, $len);
+- $buf .= " " . $part;
+- $message .= $buf . sprintf("=%s", $this->LE);
+- }
+- else
+- {
+- $message .= $buf . $soft_break;
+- }
+- $buf = "";
+- }
+- while (strlen($word) > 0)
+- {
+- $len = $length;
+- if (substr($word, $len - 1, 1) == "=")
+- $len--;
+- elseif (substr($word, $len - 2, 1) == "=")
+- $len -= 2;
+- $part = substr($word, 0, $len);
+- $word = substr($word, $len);
+-
+- if (strlen($word) > 0)
+- $message .= $part . sprintf("=%s", $this->LE);
+- else
+- $buf = $part;
+- }
+- }
+- else
+- {
+- $buf_o = $buf;
+- $buf .= ($e == 0) ? $word : (" " . $word);
+-
+- if (strlen($buf) > $length and $buf_o != "")
+- {
+- $message .= $buf_o . $soft_break;
+- $buf = $word;
+- }
+- }
+- }
+- $message .= $buf . $this->LE;
+- }
+-
+- return $message;
+- }
+-
+- /**
+- * Set the body wrapping.
+- * @access private
+- * @return void
+- */
+- function SetWordWrap() {
+- if($this->WordWrap < 1)
+- return;
+-
+- switch($this->message_type)
+- {
+- case "alt":
+- // fall through
+- case "alt_attachment":
+- $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
+- break;
+- default:
+- $this->Body = $this->WrapText($this->Body, $this->WordWrap);
+- break;
+- }
+- }
+-
+- /**
+- * Assembles message header.
+- * @access private
+- * @return string
+- */
+- function CreateHeader() {
+- $result = "";
+-
+- // Set the boundaries
+- $uniq_id = md5(uniqid(time()));
+- $this->boundary[1] = "b1_" . $uniq_id;
+- $this->boundary[2] = "b2_" . $uniq_id;
+-
+- $result .= $this->HeaderLine("Date", $this->RFCDate());
+- if($this->Sender == "")
+- $result .= $this->HeaderLine("Return-Path", trim($this->From));
+- else
+- $result .= $this->HeaderLine("Return-Path", trim($this->Sender));
+-
+- // To be created automatically by mail()
+- if($this->Mailer != "mail")
+- {
+- if(count($this->to) > 0)
+- $result .= $this->AddrAppend("To", $this->to);
+- else if (count($this->cc) == 0)
+- $result .= $this->HeaderLine("To", "undisclosed-recipients:;");
+- if(count($this->cc) > 0)
+- $result .= $this->AddrAppend("Cc", $this->cc);
+- }
+-
+- $from = array();
+- $from[0][0] = trim($this->From);
+- $from[0][1] = $this->FromName;
+- $result .= $this->AddrAppend("From", $from);
+-
+- // sendmail and mail() extract Bcc from the header before sending
+- if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
+- $result .= $this->AddrAppend("Bcc", $this->bcc);
+-
+- if(count($this->ReplyTo) > 0)
+- $result .= $this->AddrAppend("Reply-to", $this->ReplyTo);
+-
+- // mail() sets the subject itself
+- if($this->Mailer != "mail")
+- $result .= $this->HeaderLine("Subject", $this->EncodeHeader(trim($this->Subject)));
+-
+- $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
+- $result .= $this->HeaderLine("X-Priority", $this->Priority);
+- $result .= $this->HeaderLine("X-Mailer", "PHPMailer [version " . $this->Version . "]");
+-
+- if($this->ConfirmReadingTo != "")
+- {
+- $result .= $this->HeaderLine("Disposition-Notification-To",
+- "<" . trim($this->ConfirmReadingTo) . ">");
+- }
+-
+- // Add custom headers
+- for($index = 0; $index < count($this->CustomHeader); $index++)
+- {
+- $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]),
+- $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
+- }
+- $result .= $this->HeaderLine("MIME-Version", "1.0");
+-
+- switch($this->message_type)
+- {
+- case "plain":
+- $result .= $this->HeaderLine("Content-Transfer-Encoding", $this->Encoding);
+- $result .= sprintf("Content-Type: %s; charset=\"%s\"",
+- $this->ContentType, $this->CharSet);
+- break;
+- case "attachments":
+- // fall through
+- case "alt_attachments":
+- if($this->InlineImageExists())
+- {
+- $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s",
+- "multipart/related", $this->LE, $this->LE,
+- $this->boundary[1], $this->LE);
+- }
+- else
+- {
+- $result .= $this->HeaderLine("Content-Type", "multipart/mixed;");
+- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
+- }
+- break;
+- case "alt":
+- $result .= $this->HeaderLine("Content-Type", "multipart/alternative;");
+- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
+- break;
+- }
+-
+- if($this->Mailer != "mail")
+- $result .= $this->LE.$this->LE;
+-
+- return $result;
+- }
+-
+- /**
+- * Assembles the message body. Returns an empty string on failure.
+- * @access private
+- * @return string
+- */
+- function CreateBody() {
+- $result = "";
+-
+- $this->SetWordWrap();
+-
+- switch($this->message_type)
+- {
+- case "alt":
+- $result .= $this->GetBoundary($this->boundary[1], "",
+- "text/plain", "");
+- $result .= $this->EncodeString($this->AltBody, $this->Encoding);
+- $result .= $this->LE.$this->LE;
+- $result .= $this->GetBoundary($this->boundary[1], "",
+- "text/html", "");
+-
+- $result .= $this->EncodeString($this->Body, $this->Encoding);
+- $result .= $this->LE.$this->LE;
+-
+- $result .= $this->EndBoundary($this->boundary[1]);
+- break;
+- case "plain":
+- $result .= $this->EncodeString($this->Body, $this->Encoding);
+- break;
+- case "attachments":
+- $result .= $this->GetBoundary($this->boundary[1], "", "", "");
+- $result .= $this->EncodeString($this->Body, $this->Encoding);
+- $result .= $this->LE;
+-
+- $result .= $this->AttachAll();
+- break;
+- case "alt_attachments":
+- $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
+- $result .= sprintf("Content-Type: %s;%s" .
+- "\tboundary=\"%s\"%s",
+- "multipart/alternative", $this->LE,
+- $this->boundary[2], $this->LE.$this->LE);
+-
+- // Create text body
+- $result .= $this->GetBoundary($this->boundary[2], "",
+- "text/plain", "") . $this->LE;
+-
+- $result .= $this->EncodeString($this->AltBody, $this->Encoding);
+- $result .= $this->LE.$this->LE;
+-
+- // Create the HTML body
+- $result .= $this->GetBoundary($this->boundary[2], "",
+- "text/html", "") . $this->LE;
+-
+- $result .= $this->EncodeString($this->Body, $this->Encoding);
+- $result .= $this->LE.$this->LE;
+-
+- $result .= $this->EndBoundary($this->boundary[2]);
+-
+- $result .= $this->AttachAll();
+- break;
+- }
+- if($this->IsError())
+- $result = "";
+-
+- return $result;
+- }
+-
+- /**
+- * Returns the start of a message boundary.
+- * @access private
+- */
+- function GetBoundary($boundary, $charSet, $contentType, $encoding) {
+- $result = "";
+- if($charSet == "") { $charSet = $this->CharSet; }
+- if($contentType == "") { $contentType = $this->ContentType; }
+- if($encoding == "") { $encoding = $this->Encoding; }
+-
+- $result .= $this->TextLine("--" . $boundary);
+- $result .= sprintf("Content-Type: %s; charset = \"%s\"",
+- $contentType, $charSet);
+- $result .= $this->LE;
+- $result .= $this->HeaderLine("Content-Transfer-Encoding", $encoding);
+- $result .= $this->LE;
+-
+- return $result;
+- }
+-
+- /**
+- * Returns the end of a message boundary.
+- * @access private
+- */
+- function EndBoundary($boundary) {
+- return $this->LE . "--" . $boundary . "--" . $this->LE;
+- }
+-
+- /**
+- * Sets the message type.
+- * @access private
+- * @return void
+- */
+- function SetMessageType() {
+- if(count($this->attachment) < 1 && strlen($this->AltBody) < 1)
+- $this->message_type = "plain";
+- else
+- {
+- if(count($this->attachment) > 0)
+- $this->message_type = "attachments";
+- if(strlen($this->AltBody) > 0 && count($this->attachment) < 1)
+- $this->message_type = "alt";
+- if(strlen($this->AltBody) > 0 && count($this->attachment) > 0)
+- $this->message_type = "alt_attachments";
+- }
+- }
+-
+- /**
+- * Returns a formatted header line.
+- * @access private
+- * @return string
+- */
+- function HeaderLine($name, $value) {
+- return $name . ": " . $value . $this->LE;
+- }
+-
+- /**
+- * Returns a formatted mail line.
+- * @access private
+- * @return string
+- */
+- function TextLine($value) {
+- return $value . $this->LE;
+- }
+-
+- /////////////////////////////////////////////////
+- // ATTACHMENT METHODS
+- /////////////////////////////////////////////////
+-
+- /**
+- * Adds an attachment from a path on the filesystem.
+- * Returns false if the file could not be found
+- * or accessed.
+- * @param string $path Path to the attachment.
+- * @param string $name Overrides the attachment name.
+- * @param string $encoding File encoding (see $Encoding).
+- * @param string $type File extension (MIME) type.
+- * @return bool
+- */
+- function AddAttachment($path, $name = "", $encoding = "base64",
+- $type = "application/octet-stream") {
+- if(!@is_file($path))
+- {
+- $this->SetError($this->Lang("file_access") . $path);
+- return false;
+- }
+-
+- $filename = basename($path);
+- if($name == "")
+- $name = $filename;
+-
+- $cur = count($this->attachment);
+- $this->attachment[$cur][0] = $path;
+- $this->attachment[$cur][1] = $filename;
+- $this->attachment[$cur][2] = $name;
+- $this->attachment[$cur][3] = $encoding;
+- $this->attachment[$cur][4] = $type;
+- $this->attachment[$cur][5] = false; // isStringAttachment
+- $this->attachment[$cur][6] = "attachment";
+- $this->attachment[$cur][7] = 0;
+-
+- return true;
+- }
+-
+- /**
+- * Attaches all fs, string, and binary attachments to the message.
+- * Returns an empty string on failure.
+- * @access private
+- * @return string
+- */
+- function AttachAll() {
+- // Return text of body
+- $mime = array();
+-
+- // Add all attachments
+- for($i = 0; $i < count($this->attachment); $i++)
+- {
+- // Check for string attachment
+- $bString = $this->attachment[$i][5];
+- if ($bString)
+- $string = $this->attachment[$i][0];
+- else
+- $path = $this->attachment[$i][0];
+-
+- $filename = $this->attachment[$i][1];
+- $name = $this->attachment[$i][2];
+- $encoding = $this->attachment[$i][3];
+- $type = $this->attachment[$i][4];
+- $disposition = $this->attachment[$i][6];
+- $cid = $this->attachment[$i][7];
+-
+- $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
+- $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
+- $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
+-
+- if($disposition == "inline")
+- $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
+-
+- $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s",
+- $disposition, $name, $this->LE.$this->LE);
+-
+- // Encode as string attachment
+- if($bString)
+- {
+- $mime[] = $this->EncodeString($string, $encoding);
+- if($this->IsError()) { return ""; }
+- $mime[] = $this->LE.$this->LE;
+- }
+- else
+- {
+- $mime[] = $this->EncodeFile($path, $encoding);
+- if($this->IsError()) { return ""; }
+- $mime[] = $this->LE.$this->LE;
+- }
+- }
+-
+- $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
+-
+- return join("", $mime);
+- }
+-
+- /**
+- * Encodes attachment in requested format. Returns an
+- * empty string on failure.
+- * @access private
+- * @return string
+- */
+- function EncodeFile ($path, $encoding = "base64") {
+- if(!@$fd = fopen($path, "rb"))
+- {
+- $this->SetError($this->Lang("file_open") . $path);
+- return "";
+- }
+- $file_buffer = fread($fd, filesize($path));
+- $file_buffer = $this->EncodeString($file_buffer, $encoding);
+- fclose($fd);
+-
+- return $file_buffer;
+- }
+-
+- /**
+- * Encodes string to requested format. Returns an
+- * empty string on failure.
+- * @access private
+- * @return string
+- */
+- function EncodeString ($str, $encoding = "base64") {
+- $encoded = "";
+- switch(strtolower($encoding)) {
+- case "base64":
+- // chunk_split is found in PHP >= 3.0.6
+- $encoded = chunk_split(base64_encode($str), 76, $this->LE);
+- break;
+- case "7bit":
+- case "8bit":
+- $encoded = $this->FixEOL($str);
+- if (substr($encoded, -(strlen($this->LE))) != $this->LE)
+- $encoded .= $this->LE;
+- break;
+- case "binary":
+- $encoded = $str;
+- break;
+- case "quoted-printable":
+- $encoded = $this->EncodeQP($str);
+- break;
+- default:
+- $this->SetError($this->Lang("encoding") . $encoding);
+- break;
+- }
+- return $encoded;
+- }
+-
+- /**
+- * Encode a header string to best of Q, B, quoted or none.
+- * @access private
+- * @return string
+- */
+- function EncodeHeader ($str, $position = 'text') {
+- $x = 0;
+-
+- switch (strtolower($position)) {
+- case 'phrase':
+- if (!preg_match('/[\200-\377]/', $str)) {
+- // Can't use addslashes as we don't know what value has magic_quotes_sybase.
+- $encoded = addcslashes($str, "\0..\37\177\\\"");
+-
+- if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str))
+- return ($encoded);
+- else
+- return ("\"$encoded\"");
+- }
+- $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
+- break;
+- case 'comment':
+- $x = preg_match_all('/[()"]/', $str, $matches);
+- // Fall-through
+- case 'text':
+- default:
+- $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
+- break;
+- }
+-
+- if ($x == 0)
+- return ($str);
+-
+- $maxlen = 75 - 7 - strlen($this->CharSet);
+- // Try to select the encoding which should produce the shortest output
+- if (strlen($str)/3 < $x) {
+- $encoding = 'B';
+- $encoded = base64_encode($str);
+- $maxlen -= $maxlen % 4;
+- $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
+- } else {
+- $encoding = 'Q';
+- $encoded = $this->EncodeQ($str, $position);
+- $encoded = $this->WrapText($encoded, $maxlen, true);
+- $encoded = str_replace("=".$this->LE, "\n", trim($encoded));
+- }
+-
+- $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
+- $encoded = trim(str_replace("\n", $this->LE, $encoded));
+-
+- return $encoded;
+- }
+-
+- /**
+- * Encode string to quoted-printable.
+- * @access private
+- * @return string
+- */
+- function EncodeQP ($str) {
+- $encoded = $this->FixEOL($str);
+- if (substr($encoded, -(strlen($this->LE))) != $this->LE)
+- $encoded .= $this->LE;
+-
+- // Replace every high ascii, control and = characters
+- $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',
+- "'='.sprintf('%02X', ord('\\1'))", $encoded);
+- // Replace every spaces and tabs when it's the last character on a line
+- $encoded = preg_replace("/([\011\040])".$this->LE."/e",
+- "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);
+-
+- // Maximum line length of 76 characters before CRLF (74 + space + '=')
+- $encoded = $this->WrapText($encoded, 74, true);
+-
+- return $encoded;
+- }
+-
+- /**
+- * Encode string to q encoding.
+- * @access private
+- * @return string
+- */
+- function EncodeQ ($str, $position = "text") {
+- // There should not be any EOL in the string
+- $encoded = preg_replace("[\r\n]", "", $str);
+-
+- switch (strtolower($position)) {
+- case "phrase":
+- $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
+- break;
+- case "comment":
+- $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
+- case "text":
+- default:
+- // Replace every high ascii, control =, ? and _ characters
+- $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
+- "'='.sprintf('%02X', ord('\\1'))", $encoded);
+- break;
+- }
+-
+- // Replace every spaces to _ (more readable than =20)
+- $encoded = str_replace(" ", "_", $encoded);
+-
+- return $encoded;
+- }
+-
+- /**
+- * Adds a string or binary attachment (non-filesystem) to the list.
+- * This method can be used to attach ascii or binary data,
+- * such as a BLOB record from a database.
+- * @param string $string String attachment data.
+- * @param string $filename Name of the attachment.
+- * @param string $encoding File encoding (see $Encoding).
+- * @param string $type File extension (MIME) type.
+- * @return void
+- */
+- function AddStringAttachment($string, $filename, $encoding = "base64",
+- $type = "application/octet-stream") {
+- // Append to $attachment array
+- $cur = count($this->attachment);
+- $this->attachment[$cur][0] = $string;
+- $this->attachment[$cur][1] = $filename;
+- $this->attachment[$cur][2] = $filename;
+- $this->attachment[$cur][3] = $encoding;
+- $this->attachment[$cur][4] = $type;
+- $this->attachment[$cur][5] = true; // isString
+- $this->attachment[$cur][6] = "attachment";
+- $this->attachment[$cur][7] = 0;
+- }
+-
+- /**
+- * Adds an embedded attachment. This can include images, sounds, and
+- * just about any other document. Make sure to set the $type to an
+- * image type. For JPEG images use "image/jpeg" and for GIF images
+- * use "image/gif".
+- * @param string $path Path to the attachment.
+- * @param string $cid Content ID of the attachment. Use this to identify
+- * the Id for accessing the image in an HTML form.
+- * @param string $name Overrides the attachment name.
+- * @param string $encoding File encoding (see $Encoding).
+- * @param string $type File extension (MIME) type.
+- * @return bool
+- */
+- function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64",
+- $type = "application/octet-stream") {
+-
+- if(!@is_file($path))
+- {
+- $this->SetError($this->Lang("file_access") . $path);
+- return false;
+- }
+-
+- $filename = basename($path);
+- if($name == "")
+- $name = $filename;
+-
+- // Append to $attachment array
+- $cur = count($this->attachment);
+- $this->attachment[$cur][0] = $path;
+- $this->attachment[$cur][1] = $filename;
+- $this->attachment[$cur][2] = $name;
+- $this->attachment[$cur][3] = $encoding;
+- $this->attachment[$cur][4] = $type;
+- $this->attachment[$cur][5] = false; // isStringAttachment
+- $this->attachment[$cur][6] = "inline";
+- $this->attachment[$cur][7] = $cid;
+-
+- return true;
+- }
+-
+- /**
+- * Returns true if an inline attachment is present.
+- * @access private
+- * @return bool
+- */
+- function InlineImageExists() {
+- $result = false;
+- for($i = 0; $i < count($this->attachment); $i++)
+- {
+- if($this->attachment[$i][6] == "inline")
+- {
+- $result = true;
+- break;
+- }
+- }
+-
+- return $result;
+- }
+-
+- /////////////////////////////////////////////////
+- // MESSAGE RESET METHODS
+- /////////////////////////////////////////////////
+-
+- /**
+- * Clears all recipients assigned in the TO array. Returns void.
+- * @return void
+- */
+- function ClearAddresses() {
+- $this->to = array();
+- }
+-
+- /**
+- * Clears all recipients assigned in the CC array. Returns void.
+- * @return void
+- */
+- function ClearCCs() {
+- $this->cc = array();
+- }
+-
+- /**
+- * Clears all recipients assigned in the BCC array. Returns void.
+- * @return void
+- */
+- function ClearBCCs() {
+- $this->bcc = array();
+- }
+-
+- /**
+- * Clears all recipients assigned in the ReplyTo array. Returns void.
+- * @return void
+- */
+- function ClearReplyTos() {
+- $this->ReplyTo = array();
+- }
+-
+- /**
+- * Clears all recipients assigned in the TO, CC and BCC
+- * array. Returns void.
+- * @return void
+- */
+- function ClearAllRecipients() {
+- $this->to = array();
+- $this->cc = array();
+- $this->bcc = array();
+- }
+-
+- /**
+- * Clears all previously set filesystem, string, and binary
+- * attachments. Returns void.
+- * @return void
+- */
+- function ClearAttachments() {
+- $this->attachment = array();
+- }
+-
+- /**
+- * Clears all custom headers. Returns void.
+- * @return void
+- */
+- function ClearCustomHeaders() {
+- $this->CustomHeader = array();
+- }
+-
+-
+- /////////////////////////////////////////////////
+- // MISCELLANEOUS METHODS
+- /////////////////////////////////////////////////
+-
+- /**
+- * Adds the error message to the error container.
+- * Returns void.
+- * @access private
+- * @return void
+- */
+- function SetError($msg) {
+- $this->error_count++;
+- $this->ErrorInfo = $msg;
+- }
+-
+- /**
+- * Returns the proper RFC 822 formatted date.
+- * @access private
+- * @return string
+- */
+- function RFCDate() {
+- $tz = date("Z");
+- $tzs = ($tz < 0) ? "-" : "+";
+- $tz = abs($tz);
+- $tz = ($tz/3600)*100 + ($tz%3600)/60;
+- $result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);
+-
+- return $result;
+- }
+-
+- /**
+- * Returns the appropriate server variable. Should work with both
+- * PHP 4.1.0+ as well as older versions. Returns an empty string
+- * if nothing is found.
+- * @access private
+- * @return mixed
+- */
+- function ServerVar($varName) {
+- global $HTTP_SERVER_VARS;
+- global $HTTP_ENV_VARS;
+-
+- if(!isset($_SERVER))
+- {
+- $_SERVER = $HTTP_SERVER_VARS;
+- if(!isset($_SERVER["REMOTE_ADDR"]))
+- $_SERVER = $HTTP_ENV_VARS; // must be Apache
+- }
+-
+- if(isset($_SERVER[$varName]))
+- return $_SERVER[$varName];
+- else
+- return "";
+- }
+-
+- /**
+- * Returns the server hostname or 'localhost.localdomain' if unknown.
+- * @access private
+- * @return string
+- */
+- function ServerHostname() {
+- if ($this->Hostname != "")
+- $result = $this->Hostname;
+- elseif ($this->ServerVar('SERVER_NAME') != "")
+- $result = $this->ServerVar('SERVER_NAME');
+- else
+- $result = "localhost.localdomain";
+-
+- return $result;
+- }
+-
+- /**
+- * Returns a message in the appropriate language.
+- * @access private
+- * @return string
+- */
+- function Lang($key) {
+- if(count($this->language) < 1)
+- $this->SetLanguage("en"); // set the default language
+-
+- if(isset($this->language[$key]))
+- return $this->language[$key];
+- else
+- return "Language string failed to load: " . $key;
+- }
+-
+- /**
+- * Returns true if an error occurred.
+- * @return bool
+- */
+- function IsError() {
+- return ($this->error_count > 0);
+- }
+-
+- /**
+- * Changes every end of line from CR or LF to CRLF.
+- * @access private
+- * @return string
+- */
+- function FixEOL($str) {
+- $str = str_replace("\r\n", "\n", $str);
+- $str = str_replace("\r", "\n", $str);
+- $str = str_replace("\n", $this->LE, $str);
+- return $str;
+- }
+-
+- /**
+- * Adds a custom header.
+- * @return void
+- */
+- function AddCustomHeader($custom_header) {
+- $this->CustomHeader[] = explode(":", $custom_header, 2);
+- }
+-}
+-
+-?>
++<?php
++////////////////////////////////////////////////////
++// PHPMailer - PHP email class
++//
++// Class for sending email using either
++// sendmail, PHP mail(), or SMTP. Methods are
++// based upon the standard AspEmail(tm) classes.
++//
++// Copyright (C) 2001 - 2003 Brent R. Matzelle
++//
++// License: LGPL, see LICENSE
++////////////////////////////////////////////////////
++
++/**
++ * PHPMailer - PHP email transport class
++ * @package PHPMailer
++ * @author Brent R. Matzelle
++ * @copyright 2001 - 2003 Brent R. Matzelle
++ */
++class PHPMailer
++{
++ /////////////////////////////////////////////////
++ // PUBLIC VARIABLES
++ /////////////////////////////////////////////////
++
++ /**
++ * Email priority (1 = High, 3 = Normal, 5 = low).
++ * @var int
++ */
++ var $Priority = 3;
++
++ /**
++ * Sets the CharSet of the message.
++ * @var string
++ */
++ var $CharSet = "iso-8859-1";
++
++ /**
++ * Sets the Content-type of the message.
++ * @var string
++ */
++ var $ContentType = "text/plain";
++
++ /**
++ * Sets the Encoding of the message. Options for this are "8bit",
++ * "7bit", "binary", "base64", and "quoted-printable".
++ * @var string
++ */
++ var $Encoding = "8bit";
++
++ /**
++ * Holds the most recent mailer error message.
++ * @var string
++ */
++ var $ErrorInfo = "";
++
++ /**
++ * Sets the From email address for the message.
++ * @var string
++ */
++ var $From = "root@localhost";
++
++ /**
++ * Sets the From name of the message.
++ * @var string
++ */
++ var $FromName = "Root User";
++
++ /**
++ * Sets the Sender email (Return-Path) of the message. If not empty,
++ * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
++ * @var string
++ */
++ var $Sender = "";
++
++ /**
++ * Sets the Subject of the message.
++ * @var string
++ */
++ var $Subject = "";
++
++ /**
++ * Sets the Body of the message. This can be either an HTML or text body.
++ * If HTML then run IsHTML(true).
++ * @var string
++ */
++ var $Body = "";
++
++ /**
++ * Sets the text-only body of the message. This automatically sets the
++ * email to multipart/alternative. This body can be read by mail
++ * clients that do not have HTML email capability such as mutt. Clients
++ * that can read HTML will view the normal Body.
++ * @var string
++ */
++ var $AltBody = "";
++
++ /**
++ * Sets word wrapping on the body of the message to a given number of
++ * characters.
++ * @var int
++ */
++ var $WordWrap = 0;
++
++ /**
++ * Method to send mail: ("mail", "sendmail", or "smtp").
++ * @var string
++ */
++ var $Mailer = "mail";
++
++ /**
++ * Sets the path of the sendmail program.
++ * @var string
++ */
++ var $Sendmail = "/usr/sbin/sendmail";
++
++ /**
++ * Path to PHPMailer plugins. This is now only useful if the SMTP class
++ * is in a different directory than the PHP include path.
++ * @var string
++ */
++ var $PluginDir = "";
++
++ /**
++ * Holds PHPMailer version.
++ * @var string
++ */
++ var $Version = "1.72";
++
++ /**
++ * Sets the email address that a reading confirmation will be sent.
++ * @var string
++ */
++ var $ConfirmReadingTo = "";
++
++ /**
++ * Sets the hostname to use in Message-Id and Received headers
++ * and as default HELO string. If empty, the value returned
++ * by SERVER_NAME is used or 'localhost.localdomain'.
++ * @var string
++ */
++ var $Hostname = "";
++
++ /////////////////////////////////////////////////
++ // SMTP VARIABLES
++ /////////////////////////////////////////////////
++
++ /**
++ * Sets the SMTP hosts. All hosts must be separated by a
++ * semicolon. You can also specify a different port
++ * for each host by using this format: [hostname:port]
++ * (e.g. "smtp1.example.com:25;smtp2.example.com").
++ * Hosts will be tried in order.
++ * @var string
++ */
++ var $Host = "localhost";
++
++ /**
++ * Sets the default SMTP server port.
++ * @var int
++ */
++ var $Port = 25;
++
++ /**
++ * Sets the SMTP HELO of the message (Default is $Hostname).
++ * @var string
++ */
++ var $Helo = "";
++
++ /**
++ * Sets SMTP authentication. Utilizes the Username and Password variables.
++ * @var bool
++ */
++ var $SMTPAuth = false;
++
++ /**
++ * Sets SMTP username.
++ * @var string
++ */
++ var $Username = "";
++
++ /**
++ * Sets SMTP password.
++ * @var string
++ */
++ var $Password = "";
++
++ /**
++ * Sets the SMTP server timeout in seconds. This function will not
++ * work with the win32 version.
++ * @var int
++ */
++ var $Timeout = 10;
++
++ /**
++ * Sets SMTP class debugging on or off.
++ * @var bool
++ */
++ var $SMTPDebug = false;
++
++ /**
++ * Prevents the SMTP connection from being closed after each mail
++ * sending. If this is set to true then to close the connection
++ * requires an explicit call to SmtpClose().
++ * @var bool
++ */
++ var $SMTPKeepAlive = false;
++
++ /**#@+
++ * @access private
++ */
++ var $smtp = NULL;
++ var $to = array();
++ var $cc = array();
++ var $bcc = array();
++ var $ReplyTo = array();
++ var $attachment = array();
++ var $CustomHeader = array();
++ var $message_type = "";
++ var $boundary = array();
++ var $language = array();
++ var $error_count = 0;
++ var $LE = "\n";
++ /**#@-*/
++
++ /////////////////////////////////////////////////
++ // CONSTRUCTOR
++ /////////////////////////////////////////////////
++ /**
++ * Constructor, just set up language
++ * @param none
++ * @return void
++ */
++ function __construct() {
++ global $conf;
++ global $charset;
++
++ $this->CharSet = $charset;
++
++ $this->SetLanguage();
++
++ $this->Mailer = $conf['app']['emailType'];
++
++ if ($this->Mailer == 'smtp') { // Set smtp variables
++ $this->Host = $conf['app']['smtpHost'];
++ $this->Port = $conf['app']['smtpPort'];
++ }
++
++ if ($this->Mailer == 'sendmail') // Set sendmail variables
++ $this->Sendmail = $conf['app']['sendmailPath'];
++
++ if ($this->Mailer == 'qmail') // Set qmail variables
++ $this->Sendmail = $conf['app']['qmailPath'];
++ }
++
++ /////////////////////////////////////////////////
++ // VARIABLE METHODS
++ /////////////////////////////////////////////////
++
++ /**
++ * Sets message type to HTML.
++ * @param bool $bool
++ * @return void
++ */
++ function IsHTML($bool) {
++ if($bool == true)
++ $this->ContentType = "text/html";
++ else
++ $this->ContentType = "text/plain";
++ }
++
++ /**
++ * Sets Mailer to send message using SMTP.
++ * @return void
++ */
++ function IsSMTP() {
++ $this->Mailer = "smtp";
++ }
++
++ /**
++ * Sets Mailer to send message using PHP mail() function.
++ * @return void
++ */
++ function IsMail() {
++ $this->Mailer = "mail";
++ }
++
++ /**
++ * Sets Mailer to send message using the $Sendmail program.
++ * @return void
++ */
++ function IsSendmail() {
++ $this->Mailer = "sendmail";
++ }
++
++ /**
++ * Sets Mailer to send message using the qmail MTA.
++ * @return void
++ */
++ function IsQmail() {
++ $this->Sendmail = "/var/qmail/bin/sendmail";
++ $this->Mailer = "sendmail";
++ }
++
++
++ /////////////////////////////////////////////////
++ // RECIPIENT METHODS
++ /////////////////////////////////////////////////
++
++ /**
++ * Adds a "To" address.
++ * @param string $address
++ * @param string $name
++ * @return void
++ */
++ function AddAddress($address, $name = "") {
++ $cur = count($this->to);
++ $this->to[$cur][0] = trim($address);
++ $this->to[$cur][1] = $name;
++ }
++
++ /**
++ * Adds a "Cc" address. Note: this function works
++ * with the SMTP mailer on win32, not with the "mail"
++ * mailer.
++ * @param string $address
++ * @param string $name
++ * @return void
++ */
++ function AddCC($address, $name = "") {
++ $cur = count($this->cc);
++ $this->cc[$cur][0] = trim($address);
++ $this->cc[$cur][1] = $name;
++ }
++
++ /**
++ * Adds a "Bcc" address. Note: this function works
++ * with the SMTP mailer on win32, not with the "mail"
++ * mailer.
++ * @param string $address
++ * @param string $name
++ * @return void
++ */
++ function AddBCC($address, $name = "") {
++ $cur = count($this->bcc);
++ $this->bcc[$cur][0] = trim($address);
++ $this->bcc[$cur][1] = $name;
++ }
++
++ /**
++ * Adds a "Reply-to" address.
++ * @param string $address
++ * @param string $name
++ * @return void
++ */
++ function AddReplyTo($address, $name = "") {
++ $cur = count($this->ReplyTo);
++ $this->ReplyTo[$cur][0] = trim($address);
++ $this->ReplyTo[$cur][1] = $name;
++ }
++
++
++ /////////////////////////////////////////////////
++ // MAIL SENDING METHODS
++ /////////////////////////////////////////////////
++
++ /**
++ * Creates message and assigns Mailer. If the message is
++ * not sent successfully then it returns false. Use the ErrorInfo
++ * variable to view description of the error.
++ * @return bool
++ */
++ function Send() {
++ $header = "";
++ $body = "";
++ $result = true;
++
++ if((count($this->to) + count($this->cc) + count($this->bcc)) < 1)
++ {
++ $this->SetError($this->Lang("provide_address"));
++ return false;
++ }
++
++ // Set whether the message is multipart/alternative
++ if(!empty($this->AltBody))
++ $this->ContentType = "multipart/alternative";
++
++ $this->error_count = 0; // reset errors
++ $this->SetMessageType();
++ $header .= $this->CreateHeader();
++ $body = $this->CreateBody();
++
++ // Nick Korbel - 08-21-2005
++ if (version_compare('4.3.0',phpversion(), '<=') == 1) {
++ $this->Subject = html_entity_decode($this->Subject, ENT_COMPAT, $this->CharSet);
++ if ($this->ContentType != "text/html")
++ $body = html_entity_decode($body, ENT_COMPAT, $this->CharSet);
++ }
++
++ if($body == "") { return false; }
++
++ // Choose the mailer
++ switch($this->Mailer)
++ {
++ case "sendmail":
++ $result = $this->SendmailSend($header, $body);
++ break;
++ case "mail":
++ $result = $this->MailSend($header, $body);
++ break;
++ case "smtp":
++ $result = $this->SmtpSend($header, $body);
++ break;
++ default:
++ $this->SetError($this->Mailer . $this->Lang("mailer_not_supported"));
++ $result = false;
++ break;
++ }
++
++ return $result;
++ }
++
++ /**
++ * Sends mail using the $Sendmail program.
++ * @access private
++ * @return bool
++ */
++ function SendmailSend($header, $body) {
++ if ($this->Sender != "")
++ $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender);
++ else
++ $sendmail = sprintf("%s -oi -t", $this->Sendmail);
++
++ if(!@$mail = popen($sendmail, "w"))
++ {
++ $this->SetError($this->Lang("execute") . $this->Sendmail);
++ return false;
++ }
++
++ fputs($mail, $header);
++ fputs($mail, $body);
++
++ $result = pclose($mail) >> 8 & 0xFF;
++ if($result != 0)
++ {
++ $this->SetError($this->Lang("execute") . $this->Sendmail);
++ return false;
++ }
++
++ return true;
++ }
++
++ /**
++ * Sends mail using the PHP mail() function.
++ * @access private
++ * @return bool
++ */
++ function MailSend($header, $body) {
++ $to = "";
++ for($i = 0; $i < count($this->to); $i++)
++ {
++ if($i != 0) { $to .= ", "; }
++ $to .= $this->to[$i][0];
++ }
++
++ if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1)
++ {
++ $old_from = ini_get("sendmail_from");
++ ini_set("sendmail_from", $this->Sender);
++ $params = sprintf("-oi -f %s", $this->Sender);
++ $rt = @mail($to, $this->EncodeHeader($this->Subject), $body,
++ $header, $params);
++ }
++ else
++ $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);
++
++ if (isset($old_from))
++ ini_set("sendmail_from", $old_from);
++
++ if(!$rt)
++ {
++ $this->SetError($this->Lang("instantiate"));
++ return false;
++ }
++
++ return true;
++ }
++
++ /**
++ * Sends mail via SMTP using PhpSMTP (Author:
++ * Chris Ryan). Returns bool. Returns false if there is a
++ * bad MAIL FROM, RCPT, or DATA input.
++ * @access private
++ * @return bool
++ */
++ function SmtpSend($header, $body) {
++ include_once($this->PluginDir . "Smtp.class.php");
++ $error = "";
++ $bad_rcpt = array();
++
++ if(!$this->SmtpConnect())
++ return false;
++
++ $smtp_from = ($this->Sender == "") ? $this->From : $this->Sender;
++ if(!$this->smtp->Mail($smtp_from))
++ {
++ $error = $this->Lang("from_failed") . $smtp_from;
++ $this->SetError($error);
++ $this->smtp->Reset();
++ return false;
++ }
++
++ // Attempt to send attach all recipients
++ for($i = 0; $i < count($this->to); $i++)
++ {
++ if(!$this->smtp->Recipient($this->to[$i][0]))
++ $bad_rcpt[] = $this->to[$i][0];
++ }
++ for($i = 0; $i < count($this->cc); $i++)
++ {
++ if(!$this->smtp->Recipient($this->cc[$i][0]))
++ $bad_rcpt[] = $this->cc[$i][0];
++ }
++ for($i = 0; $i < count($this->bcc); $i++)
++ {
++ if(!$this->smtp->Recipient($this->bcc[$i][0]))
++ $bad_rcpt[] = $this->bcc[$i][0];
++ }
++
++ if(count($bad_rcpt) > 0) // Create error message
++ {
++ for($i = 0; $i < count($bad_rcpt); $i++)
++ {
++ if($i != 0) { $error .= ", "; }
++ $error .= $bad_rcpt[$i];
++ }
++ $error = $this->Lang("recipients_failed") . $error;
++ $this->SetError($error);
++ $this->smtp->Reset();
++ return false;
++ }
++
++ if(!$this->smtp->Data($header . $body))
++ {
++ $this->SetError($this->Lang("data_not_accepted"));
++ $this->smtp->Reset();
++ return false;
++ }
++ if($this->SMTPKeepAlive == true)
++ $this->smtp->Reset();
++ else
++ $this->SmtpClose();
++
++ return true;
++ }
++
++ /**
++ * Initiates a connection to an SMTP server. Returns false if the
++ * operation failed.
++ * @access private
++ * @return bool
++ */
++ function SmtpConnect() {
++ if($this->smtp == NULL) { $this->smtp = new SMTP(); }
++
++ $this->smtp->do_debug = $this->SMTPDebug;
++ $hosts = explode(";", $this->Host);
++ $index = 0;
++ $connection = ($this->smtp->Connected());
++
++ // Retry while there is no connection
++ while($index < count($hosts) && $connection == false)
++ {
++ if(strstr($hosts[$index], ":"))
++ list($host, $port) = explode(":", $hosts[$index]);
++ else
++ {
++ $host = $hosts[$index];
++ $port = $this->Port;
++ }
++
++ if($this->smtp->Connect($host, $port, $this->Timeout))
++ {
++ if ($this->Helo != '')
++ $this->smtp->Hello($this->Helo);
++ else
++ $this->smtp->Hello($this->ServerHostname());
++
++ if($this->SMTPAuth)
++ {
++ if(!$this->smtp->Authenticate($this->Username,
++ $this->Password))
++ {
++ $this->SetError($this->Lang("authenticate"));
++ $this->smtp->Reset();
++ $connection = false;
++ }
++ }
++ $connection = true;
++ }
++ $index++;
++ }
++ if(!$connection)
++ $this->SetError($this->Lang("connect_host"));
++
++ return $connection;
++ }
++
++ /**
++ * Closes the active SMTP session if one exists.
++ * @return void
++ */
++ function SmtpClose() {
++ if($this->smtp != NULL)
++ {
++ if($this->smtp->Connected())
++ {
++ $this->smtp->Quit();
++ $this->smtp->Close();
++ }
++ }
++ }
++
++ /**
++ * Sets the language for all class error messages. Always in English.
++ * @param none
++ * @access public
++ * @return bool
++ */
++ function SetLanguage() {
++ /**
++ * Only printing errors in english
++ */
++ $PHPMAILER_LANG = array();
++
++ $PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' .
++ 'recipient email address.';
++ $PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.';
++ $PHPMAILER_LANG["execute"] = 'Could not execute: ';
++ $PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.';
++ $PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.';
++ $PHPMAILER_LANG["from_failed"] = 'The following From address failed: ';
++ $PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' .
++ 'recipients failed: ';
++ $PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.';
++ $PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.';
++ $PHPMAILER_LANG["file_access"] = 'Could not access file: ';
++ $PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: ';
++ $PHPMAILER_LANG["encoding"] = 'Unknown encoding: ';
++
++ $this->language = $PHPMAILER_LANG;
++
++ return true;
++ }
++
++ /////////////////////////////////////////////////
++ // MESSAGE CREATION METHODS
++ /////////////////////////////////////////////////
++
++ /**
++ * Creates recipient headers.
++ * @access private
++ * @return string
++ */
++ function AddrAppend($type, $addr) {
++ $addr_str = $type . ": ";
++ $addr_str .= $this->AddrFormat($addr[0]);
++ if(count($addr) > 1)
++ {
++ for($i = 1; $i < count($addr); $i++)
++ $addr_str .= ", " . $this->AddrFormat($addr[$i]);
++ }
++ $addr_str .= $this->LE;
++
++ return $addr_str;
++ }
++
++ /**
++ * Formats an address correctly.
++ * @access private
++ * @return string
++ */
++ function AddrFormat($addr) {
++ if(empty($addr[1]))
++ $formatted = $addr[0];
++ else
++ {
++ $formatted = $this->EncodeHeader($addr[1], 'phrase') . " <" .
++ $addr[0] . ">";
++ }
++
++ return $formatted;
++ }
++
++ /**
++ * Wraps message for use with mailers that do not
++ * automatically perform wrapping and for quoted-printable.
++ * Original written by philippe.
++ * @access private
++ * @return string
++ */
++ function WrapText($message, $length, $qp_mode = false) {
++ $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
++
++ $message = $this->FixEOL($message);
++ if (substr($message, -1) == $this->LE)
++ $message = substr($message, 0, -1);
++
++ $line = explode($this->LE, $message);
++ $message = "";
++ for ($i=0 ;$i < count($line); $i++)
++ {
++ $line_part = explode(" ", $line[$i]);
++ $buf = "";
++ for ($e = 0; $e<count($line_part); $e++)
++ {
++ $word = $line_part[$e];
++ if ($qp_mode and (strlen($word) > $length))
++ {
++ $space_left = $length - strlen($buf) - 1;
++ if ($e != 0)
++ {
++ if ($space_left > 20)
++ {
++ $len = $space_left;
++ if (substr($word, $len - 1, 1) == "=")
++ $len--;
++ elseif (substr($word, $len - 2, 1) == "=")
++ $len -= 2;
++ $part = substr($word, 0, $len);
++ $word = substr($word, $len);
++ $buf .= " " . $part;
++ $message .= $buf . sprintf("=%s", $this->LE);
++ }
++ else
++ {
++ $message .= $buf . $soft_break;
++ }
++ $buf = "";
++ }
++ while (strlen($word) > 0)
++ {
++ $len = $length;
++ if (substr($word, $len - 1, 1) == "=")
++ $len--;
++ elseif (substr($word, $len - 2, 1) == "=")
++ $len -= 2;
++ $part = substr($word, 0, $len);
++ $word = substr($word, $len);
++
++ if (strlen($word) > 0)
++ $message .= $part . sprintf("=%s", $this->LE);
++ else
++ $buf = $part;
++ }
++ }
++ else
++ {
++ $buf_o = $buf;
++ $buf .= ($e == 0) ? $word : (" " . $word);
++
++ if (strlen($buf) > $length and $buf_o != "")
++ {
++ $message .= $buf_o . $soft_break;
++ $buf = $word;
++ }
++ }
++ }
++ $message .= $buf . $this->LE;
++ }
++
++ return $message;
++ }
++
++ /**
++ * Set the body wrapping.
++ * @access private
++ * @return void
++ */
++ function SetWordWrap() {
++ if($this->WordWrap < 1)
++ return;
++
++ switch($this->message_type)
++ {
++ case "alt":
++ // fall through
++ case "alt_attachment":
++ $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
++ break;
++ default:
++ $this->Body = $this->WrapText($this->Body, $this->WordWrap);
++ break;
++ }
++ }
++
++ /**
++ * Assembles message header.
++ * @access private
++ * @return string
++ */
++ function CreateHeader() {
++ $result = "";
++
++ // Set the boundaries
++ $uniq_id = md5(uniqid(time()));
++ $this->boundary[1] = "b1_" . $uniq_id;
++ $this->boundary[2] = "b2_" . $uniq_id;
++
++ $result .= $this->HeaderLine("Date", $this->RFCDate());
++ if($this->Sender == "")
++ $result .= $this->HeaderLine("Return-Path", trim($this->From));
++ else
++ $result .= $this->HeaderLine("Return-Path", trim($this->Sender));
++
++ // To be created automatically by mail()
++ if($this->Mailer != "mail")
++ {
++ if(count($this->to) > 0)
++ $result .= $this->AddrAppend("To", $this->to);
++ else if (count($this->cc) == 0)
++ $result .= $this->HeaderLine("To", "undisclosed-recipients:;");
++ if(count($this->cc) > 0)
++ $result .= $this->AddrAppend("Cc", $this->cc);
++ }
++
++ $from = array();
++ $from[0][0] = trim($this->From);
++ $from[0][1] = $this->FromName;
++ $result .= $this->AddrAppend("From", $from);
++
++ // sendmail and mail() extract Bcc from the header before sending
++ if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
++ $result .= $this->AddrAppend("Bcc", $this->bcc);
++
++ if(count($this->ReplyTo) > 0)
++ $result .= $this->AddrAppend("Reply-to", $this->ReplyTo);
++
++ // mail() sets the subject itself
++ if($this->Mailer != "mail")
++ $result .= $this->HeaderLine("Subject", $this->EncodeHeader(trim($this->Subject)));
++
++ $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
++ $result .= $this->HeaderLine("X-Priority", $this->Priority);
++ $result .= $this->HeaderLine("X-Mailer", "PHPMailer [version " . $this->Version . "]");
++
++ if($this->ConfirmReadingTo != "")
++ {
++ $result .= $this->HeaderLine("Disposition-Notification-To",
++ "<" . trim($this->ConfirmReadingTo) . ">");
++ }
++
++ // Add custom headers
++ for($index = 0; $index < count($this->CustomHeader); $index++)
++ {
++ $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]),
++ $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
++ }
++ $result .= $this->HeaderLine("MIME-Version", "1.0");
++
++ switch($this->message_type)
++ {
++ case "plain":
++ $result .= $this->HeaderLine("Content-Transfer-Encoding", $this->Encoding);
++ $result .= sprintf("Content-Type: %s; charset=\"%s\"",
++ $this->ContentType, $this->CharSet);
++ break;
++ case "attachments":
++ // fall through
++ case "alt_attachments":
++ if($this->InlineImageExists())
++ {
++ $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s",
++ "multipart/related", $this->LE, $this->LE,
++ $this->boundary[1], $this->LE);
++ }
++ else
++ {
++ $result .= $this->HeaderLine("Content-Type", "multipart/mixed;");
++ $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
++ }
++ break;
++ case "alt":
++ $result .= $this->HeaderLine("Content-Type", "multipart/alternative;");
++ $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
++ break;
++ }
++
++ if($this->Mailer != "mail")
++ $result .= $this->LE.$this->LE;
++
++ return $result;
++ }
++
++ /**
++ * Assembles the message body. Returns an empty string on failure.
++ * @access private
++ * @return string
++ */
++ function CreateBody() {
++ $result = "";
++
++ $this->SetWordWrap();
++
++ switch($this->message_type)
++ {
++ case "alt":
++ $result .= $this->GetBoundary($this->boundary[1], "",
++ "text/plain", "");
++ $result .= $this->EncodeString($this->AltBody, $this->Encoding);
++ $result .= $this->LE.$this->LE;
++ $result .= $this->GetBoundary($this->boundary[1], "",
++ "text/html", "");
++
++ $result .= $this->EncodeString($this->Body, $this->Encoding);
++ $result .= $this->LE.$this->LE;
++
++ $result .= $this->EndBoundary($this->boundary[1]);
++ break;
++ case "plain":
++ $result .= $this->EncodeString($this->Body, $this->Encoding);
++ break;
++ case "attachments":
++ $result .= $this->GetBoundary($this->boundary[1], "", "", "");
++ $result .= $this->EncodeString($this->Body, $this->Encoding);
++ $result .= $this->LE;
++
++ $result .= $this->AttachAll();
++ break;
++ case "alt_attachments":
++ $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
++ $result .= sprintf("Content-Type: %s;%s" .
++ "\tboundary=\"%s\"%s",
++ "multipart/alternative", $this->LE,
++ $this->boundary[2], $this->LE.$this->LE);
++
++ // Create text body
++ $result .= $this->GetBoundary($this->boundary[2], "",
++ "text/plain", "") . $this->LE;
++
++ $result .= $this->EncodeString($this->AltBody, $this->Encoding);
++ $result .= $this->LE.$this->LE;
++
++ // Create the HTML body
++ $result .= $this->GetBoundary($this->boundary[2], "",
++ "text/html", "") . $this->LE;
++
++ $result .= $this->EncodeString($this->Body, $this->Encoding);
++ $result .= $this->LE.$this->LE;
++
++ $result .= $this->EndBoundary($this->boundary[2]);
++
++ $result .= $this->AttachAll();
++ break;
++ }
++ if($this->IsError())
++ $result = "";
++
++ return $result;
++ }
++
++ /**
++ * Returns the start of a message boundary.
++ * @access private
++ */
++ function GetBoundary($boundary, $charSet, $contentType, $encoding) {
++ $result = "";
++ if($charSet == "") { $charSet = $this->CharSet; }
++ if($contentType == "") { $contentType = $this->ContentType; }
++ if($encoding == "") { $encoding = $this->Encoding; }
++
++ $result .= $this->TextLine("--" . $boundary);
++ $result .= sprintf("Content-Type: %s; charset = \"%s\"",
++ $contentType, $charSet);
++ $result .= $this->LE;
++ $result .= $this->HeaderLine("Content-Transfer-Encoding", $encoding);
++ $result .= $this->LE;
++
++ return $result;
++ }
++
++ /**
++ * Returns the end of a message boundary.
++ * @access private
++ */
++ function EndBoundary($boundary) {
++ return $this->LE . "--" . $boundary . "--" . $this->LE;
++ }
++
++ /**
++ * Sets the message type.
++ * @access private
++ * @return void
++ */
++ function SetMessageType() {
++ if(count($this->attachment) < 1 && strlen($this->AltBody) < 1)
++ $this->message_type = "plain";
++ else
++ {
++ if(count($this->attachment) > 0)
++ $this->message_type = "attachments";
++ if(strlen($this->AltBody) > 0 && count($this->attachment) < 1)
++ $this->message_type = "alt";
++ if(strlen($this->AltBody) > 0 && count($this->attachment) > 0)
++ $this->message_type = "alt_attachments";
++ }
++ }
++
++ /**
++ * Returns a formatted header line.
++ * @access private
++ * @return string
++ */
++ function HeaderLine($name, $value) {
++ return $name . ": " . $value . $this->LE;
++ }
++
++ /**
++ * Returns a formatted mail line.
++ * @access private
++ * @return string
++ */
++ function TextLine($value) {
++ return $value . $this->LE;
++ }
++
++ /////////////////////////////////////////////////
++ // ATTACHMENT METHODS
++ /////////////////////////////////////////////////
++
++ /**
++ * Adds an attachment from a path on the filesystem.
++ * Returns false if the file could not be found
++ * or accessed.
++ * @param string $path Path to the attachment.
++ * @param string $name Overrides the attachment name.
++ * @param string $encoding File encoding (see $Encoding).
++ * @param string $type File extension (MIME) type.
++ * @return bool
++ */
++ function AddAttachment($path, $name = "", $encoding = "base64",
++ $type = "application/octet-stream") {
++ if(!@is_file($path))
++ {
++ $this->SetError($this->Lang("file_access") . $path);
++ return false;
++ }
++
++ $filename = basename($path);
++ if($name == "")
++ $name = $filename;
++
++ $cur = count($this->attachment);
++ $this->attachment[$cur][0] = $path;
++ $this->attachment[$cur][1] = $filename;
++ $this->attachment[$cur][2] = $name;
++ $this->attachment[$cur][3] = $encoding;
++ $this->attachment[$cur][4] = $type;
++ $this->attachment[$cur][5] = false; // isStringAttachment
++ $this->attachment[$cur][6] = "attachment";
++ $this->attachment[$cur][7] = 0;
++
++ return true;
++ }
++
++ /**
++ * Attaches all fs, string, and binary attachments to the message.
++ * Returns an empty string on failure.
++ * @access private
++ * @return string
++ */
++ function AttachAll() {
++ // Return text of body
++ $mime = array();
++
++ // Add all attachments
++ for($i = 0; $i < count($this->attachment); $i++)
++ {
++ // Check for string attachment
++ $bString = $this->attachment[$i][5];
++ if ($bString)
++ $string = $this->attachment[$i][0];
++ else
++ $path = $this->attachment[$i][0];
++
++ $filename = $this->attachment[$i][1];
++ $name = $this->attachment[$i][2];
++ $encoding = $this->attachment[$i][3];
++ $type = $this->attachment[$i][4];
++ $disposition = $this->attachment[$i][6];
++ $cid = $this->attachment[$i][7];
++
++ $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
++ $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
++ $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
++
++ if($disposition == "inline")
++ $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
++
++ $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s",
++ $disposition, $name, $this->LE.$this->LE);
++
++ // Encode as string attachment
++ if($bString)
++ {
++ $mime[] = $this->EncodeString($string, $encoding);
++ if($this->IsError()) { return ""; }
++ $mime[] = $this->LE.$this->LE;
++ }
++ else
++ {
++ $mime[] = $this->EncodeFile($path, $encoding);
++ if($this->IsError()) { return ""; }
++ $mime[] = $this->LE.$this->LE;
++ }
++ }
++
++ $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
++
++ return join("", $mime);
++ }
++
++ /**
++ * Encodes attachment in requested format. Returns an
++ * empty string on failure.
++ * @access private
++ * @return string
++ */
++ function EncodeFile ($path, $encoding = "base64") {
++ if(!@$fd = fopen($path, "rb"))
++ {
++ $this->SetError($this->Lang("file_open") . $path);
++ return "";
++ }
++ $file_buffer = fread($fd, filesize($path));
++ $file_buffer = $this->EncodeString($file_buffer, $encoding);
++ fclose($fd);
++
++ return $file_buffer;
++ }
++
++ /**
++ * Encodes string to requested format. Returns an
++ * empty string on failure.
++ * @access private
++ * @return string
++ */
++ function EncodeString ($str, $encoding = "base64") {
++ $encoded = "";
++ switch(strtolower($encoding)) {
++ case "base64":
++ // chunk_split is found in PHP >= 3.0.6
++ $encoded = chunk_split(base64_encode($str), 76, $this->LE);
++ break;
++ case "7bit":
++ case "8bit":
++ $encoded = $this->FixEOL($str);
++ if (substr($encoded, -(strlen($this->LE))) != $this->LE)
++ $encoded .= $this->LE;
++ break;
++ case "binary":
++ $encoded = $str;
++ break;
++ case "quoted-printable":
++ $encoded = $this->EncodeQP($str);
++ break;
++ default:
++ $this->SetError($this->Lang("encoding") . $encoding);
++ break;
++ }
++ return $encoded;
++ }
++
++ /**
++ * Encode a header string to best of Q, B, quoted or none.
++ * @access private
++ * @return string
++ */
++ function EncodeHeader ($str, $position = 'text') {
++ $x = 0;
++
++ switch (strtolower($position)) {
++ case 'phrase':
++ if (!preg_match('/[\200-\377]/', $str)) {
++ // Can't use addslashes as we don't know what value has magic_quotes_sybase.
++ $encoded = addcslashes($str, "\0..\37\177\\\"");
++
++ if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str))
++ return ($encoded);
++ else
++ return ("\"$encoded\"");
++ }
++ $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
++ break;
++ case 'comment':
++ $x = preg_match_all('/[()"]/', $str, $matches);
++ // Fall-through
++ case 'text':
++ default:
++ $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
++ break;
++ }
++
++ if ($x == 0)
++ return ($str);
++
++ $maxlen = 75 - 7 - strlen($this->CharSet);
++ // Try to select the encoding which should produce the shortest output
++ if (strlen($str)/3 < $x) {
++ $encoding = 'B';
++ $encoded = base64_encode($str);
++ $maxlen -= $maxlen % 4;
++ $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
++ } else {
++ $encoding = 'Q';
++ $encoded = $this->EncodeQ($str, $position);
++ $encoded = $this->WrapText($encoded, $maxlen, true);
++ $encoded = str_replace("=".$this->LE, "\n", trim($encoded));
++ }
++
++ $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
++ $encoded = trim(str_replace("\n", $this->LE, $encoded));
++
++ return $encoded;
++ }
++
++ /**
++ * Encode string to quoted-printable.
++ * @access private
++ * @return string
++ */
++ function EncodeQP ($str) {
++ $encoded = $this->FixEOL($str);
++ if (substr($encoded, -(strlen($this->LE))) != $this->LE)
++ $encoded .= $this->LE;
++
++ // Replace every high ascii, control and = characters
++ $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',
++ "'='.sprintf('%02X', ord('\\1'))", $encoded);
++ // Replace every spaces and tabs when it's the last character on a line
++ $encoded = preg_replace("/([\011\040])".$this->LE."/e",
++ "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);
++
++ // Maximum line length of 76 characters before CRLF (74 + space + '=')
++ $encoded = $this->WrapText($encoded, 74, true);
++
++ return $encoded;
++ }
++
++ /**
++ * Encode string to q encoding.
++ * @access private
++ * @return string
++ */
++ function EncodeQ ($str, $position = "text") {
++ // There should not be any EOL in the string
++ $encoded = preg_replace("[\r\n]", "", $str);
++
++ switch (strtolower($position)) {
++ case "phrase":
++ $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
++ break;
++ case "comment":
++ $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
++ case "text":
++ default:
++ // Replace every high ascii, control =, ? and _ characters
++ $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
++ "'='.sprintf('%02X', ord('\\1'))", $encoded);
++ break;
++ }
++
++ // Replace every spaces to _ (more readable than =20)
++ $encoded = str_replace(" ", "_", $encoded);
++
++ return $encoded;
++ }
++
++ /**
++ * Adds a string or binary attachment (non-filesystem) to the list.
++ * This method can be used to attach ascii or binary data,
++ * such as a BLOB record from a database.
++ * @param string $string String attachment data.
++ * @param string $filename Name of the attachment.
++ * @param string $encoding File encoding (see $Encoding).
++ * @param string $type File extension (MIME) type.
++ * @return void
++ */
++ function AddStringAttachment($string, $filename, $encoding = "base64",
++ $type = "application/octet-stream") {
++ // Append to $attachment array
++ $cur = count($this->attachment);
++ $this->attachment[$cur][0] = $string;
++ $this->attachment[$cur][1] = $filename;
++ $this->attachment[$cur][2] = $filename;
++ $this->attachment[$cur][3] = $encoding;
++ $this->attachment[$cur][4] = $type;
++ $this->attachment[$cur][5] = true; // isString
++ $this->attachment[$cur][6] = "attachment";
++ $this->attachment[$cur][7] = 0;
++ }
++
++ /**
++ * Adds an embedded attachment. This can include images, sounds, and
++ * just about any other document. Make sure to set the $type to an
++ * image type. For JPEG images use "image/jpeg" and for GIF images
++ * use "image/gif".
++ * @param string $path Path to the attachment.
++ * @param string $cid Content ID of the attachment. Use this to identify
++ * the Id for accessing the image in an HTML form.
++ * @param string $name Overrides the attachment name.
++ * @param string $encoding File encoding (see $Encoding).
++ * @param string $type File extension (MIME) type.
++ * @return bool
++ */
++ function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64",
++ $type = "application/octet-stream") {
++
++ if(!@is_file($path))
++ {
++ $this->SetError($this->Lang("file_access") . $path);
++ return false;
++ }
++
++ $filename = basename($path);
++ if($name == "")
++ $name = $filename;
++
++ // Append to $attachment array
++ $cur = count($this->attachment);
++ $this->attachment[$cur][0] = $path;
++ $this->attachment[$cur][1] = $filename;
++ $this->attachment[$cur][2] = $name;
++ $this->attachment[$cur][3] = $encoding;
++ $this->attachment[$cur][4] = $type;
++ $this->attachment[$cur][5] = false; // isStringAttachment
++ $this->attachment[$cur][6] = "inline";
++ $this->attachment[$cur][7] = $cid;
++
++ return true;
++ }
++
++ /**
++ * Returns true if an inline attachment is present.
++ * @access private
++ * @return bool
++ */
++ function InlineImageExists() {
++ $result = false;
++ for($i = 0; $i < count($this->attachment); $i++)
++ {
++ if($this->attachment[$i][6] == "inline")
++ {
++ $result = true;
++ break;
++ }
++ }
++
++ return $result;
++ }
++
++ /////////////////////////////////////////////////
++ // MESSAGE RESET METHODS
++ /////////////////////////////////////////////////
++
++ /**
++ * Clears all recipients assigned in the TO array. Returns void.
++ * @return void
++ */
++ function ClearAddresses() {
++ $this->to = array();
++ }
++
++ /**
++ * Clears all recipients assigned in the CC array. Returns void.
++ * @return void
++ */
++ function ClearCCs() {
++ $this->cc = array();
++ }
++
++ /**
++ * Clears all recipients assigned in the BCC array. Returns void.
++ * @return void
++ */
++ function ClearBCCs() {
++ $this->bcc = array();
++ }
++
++ /**
++ * Clears all recipients assigned in the ReplyTo array. Returns void.
++ * @return void
++ */
++ function ClearReplyTos() {
++ $this->ReplyTo = array();
++ }
++
++ /**
++ * Clears all recipients assigned in the TO, CC and BCC
++ * array. Returns void.
++ * @return void
++ */
++ function ClearAllRecipients() {
++ $this->to = array();
++ $this->cc = array();
++ $this->bcc = array();
++ }
++
++ /**
++ * Clears all previously set filesystem, string, and binary
++ * attachments. Returns void.
++ * @return void
++ */
++ function ClearAttachments() {
++ $this->attachment = array();
++ }
++
++ /**
++ * Clears all custom headers. Returns void.
++ * @return void
++ */
++ function ClearCustomHeaders() {
++ $this->CustomHeader = array();
++ }
++
++
++ /////////////////////////////////////////////////
++ // MISCELLANEOUS METHODS
++ /////////////////////////////////////////////////
++
++ /**
++ * Adds the error message to the error container.
++ * Returns void.
++ * @access private
++ * @return void
++ */
++ function SetError($msg) {
++ $this->error_count++;
++ $this->ErrorInfo = $msg;
++ }
++
++ /**
++ * Returns the proper RFC 822 formatted date.
++ * @access private
++ * @return string
++ */
++ function RFCDate() {
++ $tz = date("Z");
++ $tzs = ($tz < 0) ? "-" : "+";
++ $tz = abs($tz);
++ $tz = ($tz/3600)*100 + ($tz%3600)/60;
++ $result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);
++
++ return $result;
++ }
++
++ /**
++ * Returns the appropriate server variable. Should work with both
++ * PHP 4.1.0+ as well as older versions. Returns an empty string
++ * if nothing is found.
++ * @access private
++ * @return mixed
++ */
++ function ServerVar($varName) {
++ global $HTTP_SERVER_VARS;
++ global $HTTP_ENV_VARS;
++
++ if(!isset($_SERVER))
++ {
++ $_SERVER = $HTTP_SERVER_VARS;
++ if(!isset($_SERVER["REMOTE_ADDR"]))
++ $_SERVER = $HTTP_ENV_VARS; // must be Apache
++ }
++
++ if(isset($_SERVER[$varName]))
++ return $_SERVER[$varName];
++ else
++ return "";
++ }
++
++ /**
++ * Returns the server hostname or 'localhost.localdomain' if unknown.
++ * @access private
++ * @return string
++ */
++ function ServerHostname() {
++ if ($this->Hostname != "")
++ $result = $this->Hostname;
++ elseif ($this->ServerVar('SERVER_NAME') != "")
++ $result = $this->ServerVar('SERVER_NAME');
++ else
++ $result = "localhost.localdomain";
++
++ return $result;
++ }
++
++ /**
++ * Returns a message in the appropriate language.
++ * @access private
++ * @return string
++ */
++ function Lang($key) {
++ if(count($this->language) < 1)
++ $this->SetLanguage("en"); // set the default language
++
++ if(isset($this->language[$key]))
++ return $this->language[$key];
++ else
++ return "Language string failed to load: " . $key;
++ }
++
++ /**
++ * Returns true if an error occurred.
++ * @return bool
++ */
++ function IsError() {
++ return ($this->error_count > 0);
++ }
++
++ /**
++ * Changes every end of line from CR or LF to CRLF.
++ * @access private
++ * @return string
++ */
++ function FixEOL($str) {
++ $str = str_replace("\r\n", "\n", $str);
++ $str = str_replace("\r", "\n", $str);
++ $str = str_replace("\n", $this->LE, $str);
++ return $str;
++ }
++
++ /**
++ * Adds a custom header.
++ * @return void
++ */
++ function AddCustomHeader($custom_header) {
++ $this->CustomHeader[] = explode(":", $custom_header, 2);
++ }
++}
++
++?>
diff --git a/security/mailzu/files/patch-lib_Pager.class.php b/security/mailzu/files/patch-lib_Pager.class.php
new file mode 100644
index 000000000000..485ee1b6ce1c
--- /dev/null
+++ b/security/mailzu/files/patch-lib_Pager.class.php
@@ -0,0 +1,1262 @@
+--- lib/Pager.class.php.orig 2007-06-14 19:00:15 UTC
++++ lib/Pager.class.php
+@@ -1,629 +1,629 @@
+-<?php
+-/**
+-* Paging class to iterate through limited recordsets
+-* @author Nick Korbel <lqqkout13@users.sourceforge.net>
+-* @version 02-02-05
+-* @package Pager
+-*
+-* Copyright (C) 2003 - 2005 phpScheduleIt
+-* License: GPL, see LICENSE
+-* /
+-/**
+-* To actually print out page links, call printPages() function
+-*
+-* In order for this object to work correctly, total records
+-* must be set in either the constructor or by calling
+-* setTotRecords()
+-*
+-* + Warning - The printPages() function cannot be called
+-* from within a form
+-*
+-* === EXAMPLE OF HOW TO USE PAGER ===
+-* // Initialize new Pager object with default values
+-* $pager = new Pager();
+-*
+-* // Get total # of pages
+-* $query = "SELECT COUNT(*) as num FROM table";
+-* $result = $db->query($query);
+-* $rs = $result->fetchRow();
+-* $num = $rs['num']; // # of records
+-*
+-* $pager->setTotRecords($num);
+-* $recordset_offset = $pager->getOffset();
+-* $limit = $pager->getLimit();
+-*
+-* // Execute Query (using $offset and $limit values) //
+-*
+-* $pager->printPages();
+-* ==========================================
+-*
+-*/
+-
+-// Should we use the Link class?
+-$use_link = true;
+-
+-if ($use_link) {
+- //include_once('Link.class.php');
+- $link = new Link();
+-}
+-
+-class Pager {
+- // Application set variables
+- var $cur_page;
+- var $query_string;
+- var $tot_pages;
+- var $page_var;
+- var $limit_var;
+-
+- // Application variables with user modify option
+- var $limit;
+- var $tot_records;
+- var $print_limit_select = true;
+-
+- // User modifiable variables
+- var $prev_link = '&laquo;';
+- var $next_link = '&raquo;';
+- var $limits = array(10, 25, 50, 100);
+- var $view_pages = 3;
+- var $table_width = '100%';
+- var $table_align = 'center';
+- var $link_class;
+- var $tb_class;
+- var $tb_style;
+- var $text_class;
+- var $text_style;
+-
+-
+- /**
+- * Pager Constructor
+- * Sets up Pager variables and initializes values
+- *
+- * - All parameters are optional and have default values of:
+- * $tot_records = 0
+- * $limit = 25
+- * $page_var = "page"
+- * $limit_var = "limit"
+- *
+- * @param int $tot_records optional total number of records
+- * @param int $limit optional limit of recordset
+- * @param string $page_var optional name of var to use in querystring for page value
+- * @param string $limit_var optional name of var to use in querystring for limit value
+- */
+- function Pager($tot_records=0, $limit=25, $page_var='page', $limit_var='limit') {
+- $this->tot_records = $tot_records;
+- $this->limit = $limit;
+- $this->page_var = $page_var;
+- $this->limit_var = $limit_var;
+-
+- // Call all system setter functions
+- $this->initCurPage();
+- $this->initLimit();
+- $this->initTotPages();
+- $this->initQueryString();
+- }
+-
+-
+- /**
+- * Print out the pages as links
+- * Prints out a table of all the pages as links
+- * and a jump menu to change the number of records
+- * per page
+- *
+- * setCurPage() and setTotPages() must be called
+- * before this function can be called
+- *
+- * @param none
+- * @see printPrev()
+- * @see printLink()
+- * @see printPage()
+- * @see printNext()
+- * @see printTotal()
+- * @see startTable()
+- * @see startPagesCell()
+- * @see endPagesCell()
+- * @see printLimitCell()
+- * @see endTable()
+- */
+- function printPages() {
+- $p = $this->view_pages; // How many pages to view
+- $cur_page = $this->cur_page; // Current page
+- $tot_pages = $this->tot_pages; // Total pages
+-
+- // Open up the HTML table
+- $this->startTable();
+- // Open up cell for page links
+- $this->startPagesCell();
+-
+- // Page to start printing bulk of links
+- $start = ($cur_page > $p) ? $cur_page - $p : 1;
+- // Page to end printing bulk of links
+- $end = ($cur_page + $p) < $tot_pages ? $cur_page + $p : $tot_pages;
+-
+- // Print 'prev' link
+- $this->printPrev();
+-
+- // Print link to first page, if not already there
+- if ($start != 1) {
+- $this->printPage(1);
+- }
+-
+- // Print '...' if necessary (with link to center page)
+- if ($cur_page > $p+2) {
+- $this->printLink(ceil( ($start+1)/2 ), '...');
+- }
+-
+- // Print links to pages before current page (up to first page)
+- // Print current page
+- // Print links to pages after current page (up to last page)
+- for ($pg = $start; $pg <= $end; $pg++) {
+- $this->printPage($pg);
+- }
+-
+- // Print '...' if necessary (with link to center page)
+- if ( $cur_page < ($tot_pages - ($p+1)) ) {
+- $this->printLink(ceil( ($tot_pages+$end)/2 ), '...' );
+- }
+-
+- // Print link to last page, if not already there
+- if ($end != $tot_pages) {
+- $this->printPage($tot_pages);
+- }
+-
+- // Print 'next' link
+- $this->printNext();
+-
+- // Print total records
+- $this->printTotal();
+-
+- // Close page links cell
+- $this->endPagesCell();
+- // Print out cell with limit jump menu
+- if ($this->print_limit_select) { $this->printLimitCell(); }
+- // Close table
+- $this->endTable();
+- }
+-
+- //-----------------------------------------
+- // Application setter functions
+- //-----------------------------------------
+- /**
+- * Sets current page variable
+- * @param none
+- */
+- function initCurPage() {
+- $this->cur_page = isset($_GET[$this->page_var]) ? intval($_GET[$this->page_var]) : 1;
+- }
+-
+- /**
+- * Sets the limit variable if it is passed from querystring
+- * @param none
+- */
+- function initLimit() {
+- if (isset($_GET[$this->limit_var]))
+- $this->limit = intval($_GET[$this->limit_var]);
+- if (isset($_POST[$this->limit_var]))
+- $this->limit = intval($_POST[$this->limit_var]);
+- }
+-
+- /**
+- * Pull page information from query string and set $query_string
+- *
+- * setLimit() must be called before this function for it to work correctly
+- * @param none
+- */
+- function initQueryString() {
+- if (isset($_SERVER['QUERY_STRING'])) {
+- // Remove page from query string and convert all "&" to "&amp;"
+- $this->query_string = str_replace('&', '&amp;', preg_replace("/(&|&amp;)?$this->page_var=\d*/",'',$_SERVER['QUERY_STRING']));
+-
+- // Insert limit into querystring, if it's not there
+- if ( !strstr($this->query_string, "$this->limit_var=") )
+- $this->query_string .= "&amp;$this->limit_var=" . $this->limit;
+- }
+- else {
+- $this->query_string = '';
+- }
+-
+- }
+-
+- /**
+- * Sets the tot_pages variable
+- *
+- * tot_records must be set and setLimit() must be called before
+- * this function can be called
+- *
+- * @param none
+- */
+- function initTotPages() {
+- $this->tot_pages = ceil($this->tot_records/$this->limit);
+- }
+- //===========================================
+-
+- //-------------------------------------------
+- // Output functions
+- //-------------------------------------------
+- /**
+- * Print out link to a page
+- * @param int $p page number to print
+- */
+- function printPage($p) {
+- if ($p == $this->cur_page) {
+- echo " <b>[$p]</b> ";
+- }
+- else {
+- $this->printLink($p, $p);
+- }
+- }
+-
+- /**
+- * Print 'prev' link, if necessary
+- * @param none
+- */
+- function printPrev() {
+- $cur_page = $this->cur_page;
+- if ($cur_page > 1)
+- $this->printLink($cur_page-1, $this->prev_link);
+- }
+-
+- /**
+- * Print 'next' link, if necessary
+- * @param none
+- */
+- function printNext() {
+- $cur_page = $this->cur_page;
+- if ($cur_page < $this->tot_pages && $this->tot_records > 0)
+- $this->printLink($cur_page+1, $this->next_link);
+- }
+-
+- /**
+- * Print out link to a certain page
+- * @param int $page page to link to
+- * @param string $text link text
+- */
+- function printLink($page, $text) {
+- global $link;
+- global $use_link;
+-
+- if ($use_link) {
+- $link->doLink(
+- $_SERVER['PHP_SELF'] . "?$this->page_var=$page&amp;" . $this->query_string . '"',
+- $text,
+- $this->link_class,
+- '',
+- 'Page ' . $page
+- );
+- }
+- else {
+- echo ' <a href="' . $_SERVER['PHP_SELF'] . "?$this->page_var=$page&amp;" . $this->query_string . '"'
+- . ' class="$this->class"'
+- . '>'
+- . $text . '</a> ';
+- }
+- }
+-
+- /**
+- * Prints out opening table tag
+- * @param none
+- */
+- function startTable() {
+- echo "<table align=\"$this->table_align\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"$this->table_width\">\n"
+- . "<tr class=\"$this->text_class\" style=\"$this->text_style\">\n";
+- }
+-
+- /**
+- * Begins cell containing page links
+- * @param none
+- */
+- function startPagesCell() {
+- echo '<td>' . translate('Page') . ' ';
+- }
+-
+- /**
+- * Closes cell containing page links
+- * @param none
+- */
+- function endPagesCell() {
+- echo '</td>';
+- }
+-
+- /**
+- * Prints out cell containing limit jump menu
+- * @param none
+- */
+- function printLimitCell() {
+- $limits = $this->limits;
+- echo "<td align=\"right\">\n"
+- . "<form name=\"limit_jump\" id=\"limit_jump\" method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "?" . preg_replace("/(&|&amp;)?$this->limit_var=\d*/", "", $this->query_string) . "\" style=\"margin: 0px;\">\n"
+- . translate('Per page') . " <select name=\"$this->limit_var\" onchange=\"document.limit_jump.submit();\" class=\"$this->tb_class\" style=\"$this->tb_style\">\n";
+- for ($i = 0; $i < count($limits); $i++) {
+- echo '<option value="' . $limits[$i] . '"';
+- if ($limits[$i] == $this->limit)
+- echo ' selected="selected"';
+- echo '>' . $limits[$i] . "</option>\n";
+- }
+- echo "</select>\n"
+- . "</form>\n"
+- . "</td>\n";
+- }
+-
+- /**
+- * Prints out the closing row and table HTML tags
+- * @param none
+- */
+- function endTable() {
+- echo "</tr>\n</table>\n";
+- }
+-
+- /**
+- * Prints out total number of records returned
+- * @param none
+- */
+- function printTotal() {
+- echo '(' . $this->tot_records . ')';
+- }
+- //============================================
+-
+- //--------------------------------------------
+- // User-Modified Setter Functions
+- //--------------------------------------------
+- /**
+- * Sets the total records for this recordset
+- *
+- * - Default setting is 0 (in constructor)
+- *
+- * @param int $tot total number of records
+- */
+- function setTotRecords($tot) {
+- $this->tot_records = intval($tot);
+- // Call initTotPages again to reset paging
+- $this->initTotPages();
+- }
+-
+- /**
+- * Sets the default recordset limit
+- * Note: A limit value set in the querystring
+- * or in a post value will override this
+- *
+- * - Default setting is 25 (in constructor)
+- *
+- * @param int $limit new limit value
+- */
+- function setLimit($limit) {
+- $this->limit = intval($limit);
+- // Call initLimit() to reinitialzie limit
+- $this->initLimit();
+- }
+-
+- /**
+- * Sets the text for 'prev' link
+- *
+- * - Default setting is "&laquo;"
+- *
+- * @param string $text link text
+- */
+- function setPrevLink($text) {
+- $this->prev_link = trim($text);
+- }
+-
+- /**
+- * Sets the text for 'next' link
+- *
+- * - Default setting is "&raquo;"
+- *
+- * @param string $text link text
+- */
+- function setNextLink($text) {
+- $this->next_link = trim($text);
+- }
+-
+- /**
+- * Sets the value of view_pages
+- * How many pages to print on either side of
+- * the currently viewed page number
+- *
+- * - Default setting is 3
+- *
+- * @param int $view_page how many pages to view
+- */
+- function setViewPages($view_page) {
+- $this->view_pages = intval($view_page);
+- }
+-
+- /**
+- * Sets the array of limits
+- * Pass in an array of ints to use
+- * for the limit pull down menu
+- *
+- * - Default setting is (10, 25, 50, 100)
+- *
+- * @param int $new_limits array of limits
+- */
+- function setLimits($new_limits) {
+- $this->limits = $new_limits;
+- }
+-
+- /**
+- * Sets the name of the class to be used for the links
+- *
+- * - Default setting is null
+- *
+- * @param string $link_class name of class
+- */
+- function setLinkClass($link_class) {
+- $this->link_class = $link_class;
+- }
+-
+- /**
+- * Sets the name of the class to be used for the pull down box
+- *
+- * - Default setting is null
+- *
+- * @param string $tb_class name of class
+- */
+- function setTbClass($tb_class) {
+- $this->tb_class = $tb_class;
+- }
+-
+- /**
+- * Sets the inline style of the limit jump menu
+- * This setting overrides the tb_class value
+- *
+- * - Default setting is null
+- * @param string $tb_style style of limit jump menu box
+- */
+- function setTbStyle($tb_style) {
+- $this->tb_style = $tb_style;
+- }
+-
+- /**
+- * Sets the name of the class to be used for the text
+- * ie) "Page:" and "Per page:"
+- * Should be used to modify all paging text font -amily, size, etc
+- *
+- * - Default setting is null
+- *
+- * @param string $text_class name of class
+- */
+- function setTextClass($text_class) {
+- $this->text_class = $text_class;
+- }
+-
+- /**
+- * Sets the inline style to be used for the text
+- * Should be used to modifiy all paging text font-family, size, etc
+- * This will override the text_class setting
+- *
+- * - Default setting is null
+- *
+- * @param string $text_style style to use for the text
+- */
+- function setTextStyle($text_style) {
+- $this->text_style = $text_style;
+- }
+-
+- /**
+- * Sets the width of the table bounding the pages/jump box
+- *
+- * - Default setting is "100%"
+- *
+- * @param string $table_width width of table
+- */
+- function setTableWidth($table_width) {
+- $this->table_width = $table_width;
+- }
+-
+- /**
+- * Sets the horizontial alignment of the table bounding the paging
+- *
+- * - Default setting is "center"
+- *
+- * @param string $table_align alignment value for table align
+- */
+- function setTableAlign($table_align) {
+- $this->table_align = $table_align;
+- }
+-
+- /**
+- * Sets the page variable name for the querystring
+- * @param string $page_var page variable name
+- */
+- function setPageVar($page_var) {
+- $this->page_var = $page_var;
+- }
+-
+- /**
+- * Sets the limit variable name for the querystring
+- * @param string $limit_var limit variable name
+- */
+- function setLimitVar($limit_var) {
+- $this->limit_var = $limit_var;
+- }
+-
+- /**
+- * Sets the print_limit_select variable to decide if we should show the limit select pulldown
+- * @param bool $view_limit_select if we should show the select pulldown or not
+- */
+- function setViewLimitSelect($view_limit_select) {
+- $this->print_limit_select = $view_limit_select;
+- }
+- //============================================
+-
+- //--------------------------------------------
+- // Getter methods
+- //--------------------------------------------
+- /**
+- * Returns the recordset offset
+- * @param none
+- * @return integer recorset offset
+- */
+- function getOffset() {
+- return $this->limit * $this->cur_page - $this->limit;
+- }
+-
+- /**
+- * Returns the total number of pages
+- * @param none
+- * @return integer number of pages total
+- */
+- function getTotPages() {
+- return $this->tot_pages;
+- }
+-
+- /**
+- * Returns the current page number
+- * @param none
+- * @return integer current page number
+- */
+- function getPageNum() {
+- return $this->cur_page;
+- }
+-
+- /**
+- * Returns the current recordset limit
+- * @param none
+- * @return integer recordset limit
+- */
+- function getLimit() {
+- return $this->limit;
+- }
+-
+- /**
+- * Returns value of previous link text
+- * @param none
+- * @return string previous link text
+- */
+- function getPrevLink() {
+- return $this->prev_link;
+- }
+-
+- /**
+- * Returns value of next link text
+- * @param none
+- * @return string next link text
+- */
+- function getNextLink() {
+- return $this->next_link;
+- }
+-
+- /**
+- * Returns the name used for the page querystring variable
+- * @param none
+- * @return string page variable name
+- */
+- function getPageVar() {
+- return $this->page_var;
+- }
+-
+- /**
+- * Returns the name used for the limit querystring variable
+- * @param none
+- * @return string limit variable name
+- */
+- function getLimitVar() {
+- return $this->limit_var;
+- }
+- //===========================================
+-
+-// End class
+-}
+-?>
+\ No newline at end of file
++<?php
++/**
++* Paging class to iterate through limited recordsets
++* @author Nick Korbel <lqqkout13@users.sourceforge.net>
++* @version 02-02-05
++* @package Pager
++*
++* Copyright (C) 2003 - 2005 phpScheduleIt
++* License: GPL, see LICENSE
++* /
++/**
++* To actually print out page links, call printPages() function
++*
++* In order for this object to work correctly, total records
++* must be set in either the constructor or by calling
++* setTotRecords()
++*
++* + Warning - The printPages() function cannot be called
++* from within a form
++*
++* === EXAMPLE OF HOW TO USE PAGER ===
++* // Initialize new Pager object with default values
++* $pager = new Pager();
++*
++* // Get total # of pages
++* $query = "SELECT COUNT(*) as num FROM table";
++* $result = $db->query($query);
++* $rs = $result->fetchRow();
++* $num = $rs['num']; // # of records
++*
++* $pager->setTotRecords($num);
++* $recordset_offset = $pager->getOffset();
++* $limit = $pager->getLimit();
++*
++* // Execute Query (using $offset and $limit values) //
++*
++* $pager->printPages();
++* ==========================================
++*
++*/
++
++// Should we use the Link class?
++$use_link = true;
++
++if ($use_link) {
++ //include_once('Link.class.php');
++ $link = new Link();
++}
++
++class Pager {
++ // Application set variables
++ var $cur_page;
++ var $query_string;
++ var $tot_pages;
++ var $page_var;
++ var $limit_var;
++
++ // Application variables with user modify option
++ var $limit;
++ var $tot_records;
++ var $print_limit_select = true;
++
++ // User modifiable variables
++ var $prev_link = '&laquo;';
++ var $next_link = '&raquo;';
++ var $limits = array(10, 25, 50, 100);
++ var $view_pages = 3;
++ var $table_width = '100%';
++ var $table_align = 'center';
++ var $link_class;
++ var $tb_class;
++ var $tb_style;
++ var $text_class;
++ var $text_style;
++
++
++ /**
++ * Pager Constructor
++ * Sets up Pager variables and initializes values
++ *
++ * - All parameters are optional and have default values of:
++ * $tot_records = 0
++ * $limit = 25
++ * $page_var = "page"
++ * $limit_var = "limit"
++ *
++ * @param int $tot_records optional total number of records
++ * @param int $limit optional limit of recordset
++ * @param string $page_var optional name of var to use in querystring for page value
++ * @param string $limit_var optional name of var to use in querystring for limit value
++ */
++ function __construct($tot_records=0, $limit=25, $page_var='page', $limit_var='limit') {
++ $this->tot_records = $tot_records;
++ $this->limit = $limit;
++ $this->page_var = $page_var;
++ $this->limit_var = $limit_var;
++
++ // Call all system setter functions
++ $this->initCurPage();
++ $this->initLimit();
++ $this->initTotPages();
++ $this->initQueryString();
++ }
++
++
++ /**
++ * Print out the pages as links
++ * Prints out a table of all the pages as links
++ * and a jump menu to change the number of records
++ * per page
++ *
++ * setCurPage() and setTotPages() must be called
++ * before this function can be called
++ *
++ * @param none
++ * @see printPrev()
++ * @see printLink()
++ * @see printPage()
++ * @see printNext()
++ * @see printTotal()
++ * @see startTable()
++ * @see startPagesCell()
++ * @see endPagesCell()
++ * @see printLimitCell()
++ * @see endTable()
++ */
++ function printPages() {
++ $p = $this->view_pages; // How many pages to view
++ $cur_page = $this->cur_page; // Current page
++ $tot_pages = $this->tot_pages; // Total pages
++
++ // Open up the HTML table
++ $this->startTable();
++ // Open up cell for page links
++ $this->startPagesCell();
++
++ // Page to start printing bulk of links
++ $start = ($cur_page > $p) ? $cur_page - $p : 1;
++ // Page to end printing bulk of links
++ $end = ($cur_page + $p) < $tot_pages ? $cur_page + $p : $tot_pages;
++
++ // Print 'prev' link
++ $this->printPrev();
++
++ // Print link to first page, if not already there
++ if ($start != 1) {
++ $this->printPage(1);
++ }
++
++ // Print '...' if necessary (with link to center page)
++ if ($cur_page > $p+2) {
++ $this->printLink(ceil( ($start+1)/2 ), '...');
++ }
++
++ // Print links to pages before current page (up to first page)
++ // Print current page
++ // Print links to pages after current page (up to last page)
++ for ($pg = $start; $pg <= $end; $pg++) {
++ $this->printPage($pg);
++ }
++
++ // Print '...' if necessary (with link to center page)
++ if ( $cur_page < ($tot_pages - ($p+1)) ) {
++ $this->printLink(ceil( ($tot_pages+$end)/2 ), '...' );
++ }
++
++ // Print link to last page, if not already there
++ if ($end != $tot_pages) {
++ $this->printPage($tot_pages);
++ }
++
++ // Print 'next' link
++ $this->printNext();
++
++ // Print total records
++ $this->printTotal();
++
++ // Close page links cell
++ $this->endPagesCell();
++ // Print out cell with limit jump menu
++ if ($this->print_limit_select) { $this->printLimitCell(); }
++ // Close table
++ $this->endTable();
++ }
++
++ //-----------------------------------------
++ // Application setter functions
++ //-----------------------------------------
++ /**
++ * Sets current page variable
++ * @param none
++ */
++ function initCurPage() {
++ $this->cur_page = isset($_GET[$this->page_var]) ? intval($_GET[$this->page_var]) : 1;
++ }
++
++ /**
++ * Sets the limit variable if it is passed from querystring
++ * @param none
++ */
++ function initLimit() {
++ if (isset($_GET[$this->limit_var]))
++ $this->limit = intval($_GET[$this->limit_var]);
++ if (isset($_POST[$this->limit_var]))
++ $this->limit = intval($_POST[$this->limit_var]);
++ }
++
++ /**
++ * Pull page information from query string and set $query_string
++ *
++ * setLimit() must be called before this function for it to work correctly
++ * @param none
++ */
++ function initQueryString() {
++ if (isset($_SERVER['QUERY_STRING'])) {
++ // Remove page from query string and convert all "&" to "&amp;"
++ $this->query_string = str_replace('&', '&amp;', preg_replace("/(&|&amp;)?$this->page_var=\d*/",'',$_SERVER['QUERY_STRING']));
++
++ // Insert limit into querystring, if it's not there
++ if ( !strstr($this->query_string, "$this->limit_var=") )
++ $this->query_string .= "&amp;$this->limit_var=" . $this->limit;
++ }
++ else {
++ $this->query_string = '';
++ }
++
++ }
++
++ /**
++ * Sets the tot_pages variable
++ *
++ * tot_records must be set and setLimit() must be called before
++ * this function can be called
++ *
++ * @param none
++ */
++ function initTotPages() {
++ $this->tot_pages = ceil($this->tot_records/$this->limit);
++ }
++ //===========================================
++
++ //-------------------------------------------
++ // Output functions
++ //-------------------------------------------
++ /**
++ * Print out link to a page
++ * @param int $p page number to print
++ */
++ function printPage($p) {
++ if ($p == $this->cur_page) {
++ echo " <b>[$p]</b> ";
++ }
++ else {
++ $this->printLink($p, $p);
++ }
++ }
++
++ /**
++ * Print 'prev' link, if necessary
++ * @param none
++ */
++ function printPrev() {
++ $cur_page = $this->cur_page;
++ if ($cur_page > 1)
++ $this->printLink($cur_page-1, $this->prev_link);
++ }
++
++ /**
++ * Print 'next' link, if necessary
++ * @param none
++ */
++ function printNext() {
++ $cur_page = $this->cur_page;
++ if ($cur_page < $this->tot_pages && $this->tot_records > 0)
++ $this->printLink($cur_page+1, $this->next_link);
++ }
++
++ /**
++ * Print out link to a certain page
++ * @param int $page page to link to
++ * @param string $text link text
++ */
++ function printLink($page, $text) {
++ global $link;
++ global $use_link;
++
++ if ($use_link) {
++ $link->doLink(
++ $_SERVER['PHP_SELF'] . "?$this->page_var=$page&amp;" . $this->query_string . '"',
++ $text,
++ $this->link_class,
++ '',
++ 'Page ' . $page
++ );
++ }
++ else {
++ echo ' <a href="' . $_SERVER['PHP_SELF'] . "?$this->page_var=$page&amp;" . $this->query_string . '"'
++ . ' class="$this->class"'
++ . '>'
++ . $text . '</a> ';
++ }
++ }
++
++ /**
++ * Prints out opening table tag
++ * @param none
++ */
++ function startTable() {
++ echo "<table align=\"$this->table_align\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"$this->table_width\">\n"
++ . "<tr class=\"$this->text_class\" style=\"$this->text_style\">\n";
++ }
++
++ /**
++ * Begins cell containing page links
++ * @param none
++ */
++ function startPagesCell() {
++ echo '<td>' . translate('Page') . ' ';
++ }
++
++ /**
++ * Closes cell containing page links
++ * @param none
++ */
++ function endPagesCell() {
++ echo '</td>';
++ }
++
++ /**
++ * Prints out cell containing limit jump menu
++ * @param none
++ */
++ function printLimitCell() {
++ $limits = $this->limits;
++ echo "<td align=\"right\">\n"
++ . "<form name=\"limit_jump\" id=\"limit_jump\" method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "?" . preg_replace("/(&|&amp;)?$this->limit_var=\d*/", "", $this->query_string) . "\" style=\"margin: 0px;\">\n"
++ . translate('Per page') . " <select name=\"$this->limit_var\" onchange=\"document.limit_jump.submit();\" class=\"$this->tb_class\" style=\"$this->tb_style\">\n";
++ for ($i = 0; $i < count($limits); $i++) {
++ echo '<option value="' . $limits[$i] . '"';
++ if ($limits[$i] == $this->limit)
++ echo ' selected="selected"';
++ echo '>' . $limits[$i] . "</option>\n";
++ }
++ echo "</select>\n"
++ . "</form>\n"
++ . "</td>\n";
++ }
++
++ /**
++ * Prints out the closing row and table HTML tags
++ * @param none
++ */
++ function endTable() {
++ echo "</tr>\n</table>\n";
++ }
++
++ /**
++ * Prints out total number of records returned
++ * @param none
++ */
++ function printTotal() {
++ echo '(' . $this->tot_records . ')';
++ }
++ //============================================
++
++ //--------------------------------------------
++ // User-Modified Setter Functions
++ //--------------------------------------------
++ /**
++ * Sets the total records for this recordset
++ *
++ * - Default setting is 0 (in constructor)
++ *
++ * @param int $tot total number of records
++ */
++ function setTotRecords($tot) {
++ $this->tot_records = intval($tot);
++ // Call initTotPages again to reset paging
++ $this->initTotPages();
++ }
++
++ /**
++ * Sets the default recordset limit
++ * Note: A limit value set in the querystring
++ * or in a post value will override this
++ *
++ * - Default setting is 25 (in constructor)
++ *
++ * @param int $limit new limit value
++ */
++ function setLimit($limit) {
++ $this->limit = intval($limit);
++ // Call initLimit() to reinitialzie limit
++ $this->initLimit();
++ }
++
++ /**
++ * Sets the text for 'prev' link
++ *
++ * - Default setting is "&laquo;"
++ *
++ * @param string $text link text
++ */
++ function setPrevLink($text) {
++ $this->prev_link = trim($text);
++ }
++
++ /**
++ * Sets the text for 'next' link
++ *
++ * - Default setting is "&raquo;"
++ *
++ * @param string $text link text
++ */
++ function setNextLink($text) {
++ $this->next_link = trim($text);
++ }
++
++ /**
++ * Sets the value of view_pages
++ * How many pages to print on either side of
++ * the currently viewed page number
++ *
++ * - Default setting is 3
++ *
++ * @param int $view_page how many pages to view
++ */
++ function setViewPages($view_page) {
++ $this->view_pages = intval($view_page);
++ }
++
++ /**
++ * Sets the array of limits
++ * Pass in an array of ints to use
++ * for the limit pull down menu
++ *
++ * - Default setting is (10, 25, 50, 100)
++ *
++ * @param int $new_limits array of limits
++ */
++ function setLimits($new_limits) {
++ $this->limits = $new_limits;
++ }
++
++ /**
++ * Sets the name of the class to be used for the links
++ *
++ * - Default setting is null
++ *
++ * @param string $link_class name of class
++ */
++ function setLinkClass($link_class) {
++ $this->link_class = $link_class;
++ }
++
++ /**
++ * Sets the name of the class to be used for the pull down box
++ *
++ * - Default setting is null
++ *
++ * @param string $tb_class name of class
++ */
++ function setTbClass($tb_class) {
++ $this->tb_class = $tb_class;
++ }
++
++ /**
++ * Sets the inline style of the limit jump menu
++ * This setting overrides the tb_class value
++ *
++ * - Default setting is null
++ * @param string $tb_style style of limit jump menu box
++ */
++ function setTbStyle($tb_style) {
++ $this->tb_style = $tb_style;
++ }
++
++ /**
++ * Sets the name of the class to be used for the text
++ * ie) "Page:" and "Per page:"
++ * Should be used to modify all paging text font -amily, size, etc
++ *
++ * - Default setting is null
++ *
++ * @param string $text_class name of class
++ */
++ function setTextClass($text_class) {
++ $this->text_class = $text_class;
++ }
++
++ /**
++ * Sets the inline style to be used for the text
++ * Should be used to modifiy all paging text font-family, size, etc
++ * This will override the text_class setting
++ *
++ * - Default setting is null
++ *
++ * @param string $text_style style to use for the text
++ */
++ function setTextStyle($text_style) {
++ $this->text_style = $text_style;
++ }
++
++ /**
++ * Sets the width of the table bounding the pages/jump box
++ *
++ * - Default setting is "100%"
++ *
++ * @param string $table_width width of table
++ */
++ function setTableWidth($table_width) {
++ $this->table_width = $table_width;
++ }
++
++ /**
++ * Sets the horizontial alignment of the table bounding the paging
++ *
++ * - Default setting is "center"
++ *
++ * @param string $table_align alignment value for table align
++ */
++ function setTableAlign($table_align) {
++ $this->table_align = $table_align;
++ }
++
++ /**
++ * Sets the page variable name for the querystring
++ * @param string $page_var page variable name
++ */
++ function setPageVar($page_var) {
++ $this->page_var = $page_var;
++ }
++
++ /**
++ * Sets the limit variable name for the querystring
++ * @param string $limit_var limit variable name
++ */
++ function setLimitVar($limit_var) {
++ $this->limit_var = $limit_var;
++ }
++
++ /**
++ * Sets the print_limit_select variable to decide if we should show the limit select pulldown
++ * @param bool $view_limit_select if we should show the select pulldown or not
++ */
++ function setViewLimitSelect($view_limit_select) {
++ $this->print_limit_select = $view_limit_select;
++ }
++ //============================================
++
++ //--------------------------------------------
++ // Getter methods
++ //--------------------------------------------
++ /**
++ * Returns the recordset offset
++ * @param none
++ * @return integer recorset offset
++ */
++ function getOffset() {
++ return $this->limit * $this->cur_page - $this->limit;
++ }
++
++ /**
++ * Returns the total number of pages
++ * @param none
++ * @return integer number of pages total
++ */
++ function getTotPages() {
++ return $this->tot_pages;
++ }
++
++ /**
++ * Returns the current page number
++ * @param none
++ * @return integer current page number
++ */
++ function getPageNum() {
++ return $this->cur_page;
++ }
++
++ /**
++ * Returns the current recordset limit
++ * @param none
++ * @return integer recordset limit
++ */
++ function getLimit() {
++ return $this->limit;
++ }
++
++ /**
++ * Returns value of previous link text
++ * @param none
++ * @return string previous link text
++ */
++ function getPrevLink() {
++ return $this->prev_link;
++ }
++
++ /**
++ * Returns value of next link text
++ * @param none
++ * @return string next link text
++ */
++ function getNextLink() {
++ return $this->next_link;
++ }
++
++ /**
++ * Returns the name used for the page querystring variable
++ * @param none
++ * @return string page variable name
++ */
++ function getPageVar() {
++ return $this->page_var;
++ }
++
++ /**
++ * Returns the name used for the limit querystring variable
++ * @param none
++ * @return string limit variable name
++ */
++ function getLimitVar() {
++ return $this->limit_var;
++ }
++ //===========================================
++
++// End class
++}
++?>
diff --git a/security/mailzu/files/patch-lib_Template.class.php b/security/mailzu/files/patch-lib_Template.class.php
index b8d91c4fbd89..94b341f35946 100644
--- a/security/mailzu/files/patch-lib_Template.class.php
+++ b/security/mailzu/files/patch-lib_Template.class.php
@@ -1,5 +1,14 @@
--- lib/Template.class.php.orig 2007-06-14 19:00:15 UTC
+++ lib/Template.class.php
+@@ -30,7 +30,7 @@ class Template {
+ * @param string $title title of page
+ * @param int $depth depth of the current page relative to phpScheduleIt root
+ */
+- function Template($title = '', $depth = 0) {
++ function __construct($title = '', $depth = 0) {
+ global $conf;
+
+ $this->title = (!empty($title)) ? $title : $conf['ui']['welcome'];
@@ -57,21 +57,21 @@ class Template {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
diff --git a/security/mailzu/files/patch-lib_htmlfilter.php b/security/mailzu/files/patch-lib_htmlfilter.php
index 217e7843256d..d73830a2c811 100644
--- a/security/mailzu/files/patch-lib_htmlfilter.php
+++ b/security/mailzu/files/patch-lib_htmlfilter.php
@@ -1,11 +1,145 @@
--- lib/htmlfilter.php.orig 2007-06-14 19:00:15 UTC
+++ lib/htmlfilter.php
-@@ -106,7 +106,7 @@ function casenormalize(&$val){
+@@ -106,8 +106,8 @@ function casenormalize(&$val){
function skipspace($body, $offset){
$me = 'skipspace';
preg_match('/^(\s*)/s', substr($body, $offset), $matches);
- if (sizeof($matches{1})){
-+ if (is_array($matches{1}) && sizeof($matches{1})){
- $count = strlen($matches{1});
+- $count = strlen($matches{1});
++ if (is_array($matches[1]) && sizeof($matches[1])){
++ $count = strlen($matches[1]);
spew("$me: skipped $count chars\n");
$offset += $count;
+ }
+@@ -159,10 +159,10 @@ function findnxreg($body, $offset, $reg){
+ spew("$me: No matches found.\n");
+ $retarr = false;
+ } else {
+- $retarr{0} = $offset + strlen($matches{1});
+- $retarr{1} = $matches{1};
+- $retarr{2} = $matches{2};
+- spew("$me: '$reg' found at pos $offset matching '".$matches{2}."'\n");
++ $retarr[0] = $offset + strlen($matches[1]);
++ $retarr[1] = $matches[1];
++ $retarr[2] = $matches[2];
++ spew("$me: '$reg' found at pos $offset matching '".$matches[2]."'\n");
+ }
+ return $retarr;
+ }
+@@ -335,13 +335,13 @@ function getnxtag($body, $offset){
+ */
+ $matches = Array();
+ preg_match('%^(\s*)(>|/>)%s', substr($body, $pos), $matches);
+- if (isset($matches{0}) && $matches{0}){
++ if (isset($matches[0]) && $matches[0]){
+ /**
+ * Yep. So we did.
+ */
+ spew("$me: Arrived at the end of the tag.\n");
+- $pos += strlen($matches{1});
+- if ($matches{2} == '/>'){
++ $pos += strlen($matches[1]);
++ if ($matches[2] == '/>'){
+ $tagtype = 3;
+ $pos++;
+ }
+@@ -409,7 +409,7 @@ function getnxtag($body, $offset){
+ spew("$me: Additionally, end of tag found at $pos\n");
+ spew("$me: Attname is '$attname'\n");
+ spew("$me: Setting attvalue to 'yes'\n");
+- $attary{$attname} = '"yes"';
++ $attary[$attname] = '"yes"';
+ return Array($tagname, $attary, $tagtype, $lt, $pos);
+ break;
+ default:
+@@ -449,7 +449,7 @@ function getnxtag($body, $offset){
+ list($pos, $attval, $match) = $regary;
+ spew("$me: Attvalue is '$attval'\n");
+ $pos++;
+- $attary{$attname} = '\'' . $attval . '\'';
++ $attary[$attname] = '\'' . $attval . '\'';
+ } else if ($quot == '"'){
+ spew("$me: In fact, this is attribute type 2\n");
+ spew("$me: looking for closing quote\n");
+@@ -462,7 +462,7 @@ function getnxtag($body, $offset){
+ list($pos, $attval, $match) = $regary;
+ spew("$me: Attvalue is \"$attval\"\n");
+ $pos++;
+- $attary{$attname} = '"' . $attval . '"';
++ $attary[$attname] = '"' . $attval . '"';
+ } else {
+ spew("$me: This looks like attribute type 3\n");
+ /**
+@@ -482,7 +482,7 @@ function getnxtag($body, $offset){
+ spew("$me: translating '\"' into &quot;\n");
+ $attval = preg_replace('/\"/s', '&quot;', $attval);
+ spew("$me: wrapping in quotes\n");
+- $attary{$attname} = '"' . $attval . '"';
++ $attary[$attname] = '"' . $attval . '"';
+ }
+ } else if (preg_match('|[\w/>]|', $char)) {
+ /**
+@@ -490,7 +490,7 @@ function getnxtag($body, $offset){
+ */
+ spew("$me: attribute type 4 found.\n");
+ spew("$me: Setting value to 'yes'\n");
+- $attary{$attname} = '"yes"';
++ $attary[$attname] = '"yes"';
+ } else {
+ /**
+ * An illegal character. Find next '>' and return.
+@@ -533,7 +533,7 @@ function deent(&$attvalue, $regex, $hex=false){
+ $numval = hexdec($numval);
+ spew("$me: hex! Numval is now $numval\n");
+ }
+- $repl{$matches[0][$i]} = chr($numval);
++ $repl[$matches[0][$i]] = chr($numval);
+ }
+ $attvalue = strtr($attvalue, $repl);
+ spew("$me: attvalue after translation: $attvalue\n");
+@@ -621,7 +621,7 @@ function fixatts($tagname,
+ if (preg_match($matchattr, $attname)){
+ spew("$me: Attribute '$attname' defined as bad.\n");
+ spew("$me: Removing.\n");
+- unset($attary{$attname});
++ unset($attary[$attname]);
+ continue;
+ }
+ }
+@@ -652,7 +652,7 @@ function fixatts($tagname,
+ $newvalue = preg_replace($valmatch,$valrepl,$attvalue);
+ if ($newvalue != $attvalue){
+ spew("$me: attvalue is now $newvalue\n");
+- $attary{$attname} = $newvalue;
++ $attary[$attname] = $newvalue;
+ }
+ }
+ }
+@@ -927,10 +927,10 @@ function sanitize($body,
+ $skip_content = false;
+ } else {
+ if ($skip_content == false){
+- if (isset($open_tags{$tagname}) &&
+- $open_tags{$tagname} > 0){
++ if (isset($open_tags[$tagname]) &&
++ $open_tags[$tagname] > 0){
+ spew("$me: popping '$tagname' from open_tags\n");
+- $open_tags{$tagname}--;
++ $open_tags[$tagname]--;
+ } else {
+ spew("$me: '$tagname' was never opened\n");
+ spew("$me: removing\n");
+@@ -972,10 +972,10 @@ function sanitize($body,
+ } else {
+ if ($tagtype == 1){
+ spew("$me: adding '$tagname' to open_tags\n");
+- if (isset($open_tags{$tagname})){
+- $open_tags{$tagname}++;
++ if (isset($open_tags[$tagname])){
++ $open_tags[$tagname]++;
+ } else {
+- $open_tags{$tagname} = 1;
++ $open_tags[$tagname] = 1;
+ }
+ }
+ /**