View | Details | Raw Unified | Return to bug 263614 | Differences between
and this patch

Collapse All | Expand All

(-)b/security/mailzu/Makefile (-1 / +1 lines)
Lines 2-8 Link Here
2
2
3
PORTNAME=	mailzu
3
PORTNAME=	mailzu
4
DISTVERSION=	0.8rc3
4
DISTVERSION=	0.8rc3
5
PORTREVISION=	9
5
PORTREVISION=	10
6
CATEGORIES=	security
6
CATEGORIES=	security
7
MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}/MailZu%200.8RC3
7
MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}/MailZu%200.8RC3
8
PKGNAMESUFFIX=	${PHP_PKGNAMESUFFIX}
8
PKGNAMESUFFIX=	${PHP_PKGNAMESUFFIX}
(-)b/security/mailzu/files/patch-config_langs.php (-1 / +1 lines)
Lines 6-12 Link Here
6
 	'it'	=> array('it([-_][[:alpha:]]{2})?|italian', 'it.lang.php', 'it', 'Italiano'),
6
 	'it'	=> array('it([-_][[:alpha:]]{2})?|italian', 'it.lang.php', 'it', 'Italiano'),
7
-        'pt_BR' => array('pt([-_]br)?|portuguese', 'pt_BR.lang.php', 'pt', 'Portuguese Brazilian')
7
-        'pt_BR' => array('pt([-_]br)?|portuguese', 'pt_BR.lang.php', 'pt', 'Portuguese Brazilian')
8
+        'pt_BR' => array('pt([-_]br)?|portuguese', 'pt_BR.lang.php', 'pt', 'Portuguese Brazilian'),
8
+        'pt_BR' => array('pt([-_]br)?|portuguese', 'pt_BR.lang.php', 'pt', 'Portuguese Brazilian'),
9
+	'pl'   => array('cs([-_][[:alpha:]]{2})?|polish', 'pl.lang.php', 'pl', 'Polski')
9
+	'pl'   => array('pl([-_][[:alpha:]]{2})?|polish', 'pl.lang.php', 'pl', 'Polski')
10
 );
10
 );
11
 
11
 
12
 // Language files directory	
12
 // Language files directory	
(-)b/security/mailzu/files/patch-lib-DBEngine.class.php (+9 lines)
Lines 1-5 Link Here
1
--- lib/DBEngine.class.php.orig	2007-06-14 19:00:15 UTC
1
--- lib/DBEngine.class.php.orig	2007-06-14 19:00:15 UTC
2
+++ lib/DBEngine.class.php
2
+++ lib/DBEngine.class.php
3
@@ -67,7 +67,7 @@ class DBEngine {
4
 	* DBEngine constructor to initialize object
5
 	* @param none
6
 	*/
7
-	function DBEngine() {
8
+	function __construct() {
9
 		global $conf;
10
 
11
 		$this->dbType = $conf['db']['dbType'];
3
@@ -133,35 +133,35 @@ class DBEngine {
12
@@ -133,35 +133,35 @@ class DBEngine {
4
 			MAX(stattable.pending) AS pending
13
 			MAX(stattable.pending) AS pending
5
 			FROM (
14
 			FROM (
(-)b/security/mailzu/files/patch-lib_AmavisdEngine.class.php (+11 lines)
Added Link Here
1
--- lib/AmavisdEngine.class.php.orig	2007-06-14 19:00:15 UTC
2
+++ lib/AmavisdEngine.class.php
3
@@ -48,7 +48,7 @@ class AmavisdEngine {
4
 	* $param none
5
 	* $return object Amavisd object
6
 	*/
7
-	function AmavisdEngine($host) {
8
+	function __construct($host) {
9
 
10
 		$this->socket = new Net_Socket();
11
 		$this->port = $GLOBALS['conf']['amavisd']['spam_release_port'];
(-)b/security/mailzu/files/patch-lib_DBAuth.class.php (+11 lines)
Added Link Here
1
--- lib/DBAuth.class.php.orig	2007-06-14 19:00:15 UTC
2
+++ lib/DBAuth.class.php
3
@@ -81,7 +81,7 @@ class DBAuth {
4
 	* DBEngine constructor to initialize object
5
 	* @param none
6
 	*/
7
-	function DBAuth() {
8
+	function __construct() {
9
 		global $conf;
10
 
11
 		$this->dbType = $conf['auth']['dbType'];
(-)b/security/mailzu/files/patch-lib_ExchAuth.class.php (+11 lines)
Added Link Here
1
--- lib/ExchAuth.class.php.orig	2007-06-14 19:00:15 UTC
2
+++ lib/ExchAuth.class.php
3
@@ -55,7 +55,7 @@ class ExchAuth {
4
 	* @param string $domain
5
 	* @return boolean
6
 	*/
7
-	function authUser($username, $password, $domain) {
8
+	function __construct($username, $password, $domain) {
9
 		
10
 		$fulluser = $domain.'/'.$username;
11
 		$mbox = imap_open('{'.$this->exchHost.'/imap}Inbox', $fulluser, $password);
(-)b/security/mailzu/files/patch-lib_IMAPAuth.class.php (+11 lines)
Added Link Here
1
--- lib/IMAPAuth.class.php.orig	2007-06-14 19:00:15 UTC
2
+++ lib/IMAPAuth.class.php
3
@@ -36,7 +36,7 @@ class IMAPAuth {
4
 	* Constructor to initialize object
5
 	* @param none
6
 	*/
7
-	function IMAPAuth() {
8
+	function __construct() {
9
 		global $conf;
10
 
11
 		$this->imapHosts = $conf['auth']['imap_hosts'];
(-)b/security/mailzu/files/patch-lib_LDAPEngine.class.php (+11 lines)
Added Link Here
1
--- lib/LDAPEngine.class.php.orig	2007-06-14 19:00:15 UTC
2
+++ lib/LDAPEngine.class.php
3
@@ -93,7 +93,7 @@ class LDAPEngine {
4
 	/**
5
 	* LDAPEngine constructor to initialize object
6
 	*/
7
-	function LDAPEngine() {
8
+	function __construct() {
9
 		global $conf;
10
 
11
 		$this->serverType = strtolower($conf['auth']['serverType']);
(-)b/security/mailzu/files/patch-lib_Link.class.php (+11 lines)
Added Link Here
1
--- lib/Link.class.php.orig	2007-06-14 19:00:15 UTC
2
+++ lib/Link.class.php
3
@@ -29,7 +29,7 @@ class Link {
4
 	* @param string $text_on_over text to display in status bar onmouseover
5
 	* @param string $on_over javascript to call onmouseover
6
 	*/
7
-	function Link($url=null, $text=null, $class=null, $style=null, $text_on_over=null) {
8
+	function __construct($url=null, $text=null, $class=null, $style=null, $text_on_over=null) {
9
 		$this->url = $url;
10
 		$this->text = $text;
11
 		$this->_class = $class;
(-)b/security/mailzu/files/patch-lib_MailEngine.class.php (+11 lines)
Added Link Here
1
--- lib/MailEngine.class.php.orig	2007-06-14 19:00:15 UTC
2
+++ lib/MailEngine.class.php
3
@@ -48,7 +48,7 @@ class MailEngine {
4
 	* $param string The mail addr of the reader
5
 	* $return object MailEngine object
6
 	*/
7
-	function MailEngine($mail_id, $recip) {
8
+	function __construct($mail_id, $recip) {
9
 	  $this->recipient = $recip;
10
 	  $this->getRawContent($mail_id);
11
 	  $this->msg_error = false;
(-)b/security/mailzu/files/patch-lib_MailMime.class.php (-4 / +23 lines)
Lines 1-6 Link Here
1
--- lib/MailMime.class.php.orig	2007-06-14 19:00:15 UTC
1
--- lib/MailMime.class.php.orig	2007-06-14 19:00:15 UTC
2
+++ lib/MailMime.class.php
2
+++ lib/MailMime.class.php
3
@@ -94,8 +94,14 @@ function MsgParseBody($struct) {
3
@@ -59,9 +59,15 @@ function MsgParseBody($struct) {
4
 
5
         global $filelist;
6
         global $errors;
7
-        $ctype_p = strtolower(trim($struct->ctype_primary));
8
-        $ctype_s = strtolower(trim($struct->ctype_secondary));
9
 
10
+        if ( is_object( $struct) ) {
11
+            $ctype_p = strtolower(trim($struct->ctype_primary));
12
+            $ctype_s = strtolower(trim($struct->ctype_secondary));
13
+        } else {
14
+            $ctype_p = $struct;
15
+            $ctype_s = "";
16
+        }
17
+
18
         switch ($ctype_p) {
19
           case "multipart":
20
             switch ($ctype_s) {
21
@@ -94,8 +100,14 @@ function MsgParseBody($struct) {
4
 
22
 
5
           case "text":
23
           case "text":
6
             // Do not display attached text types
24
             // Do not display attached text types
Lines 17-23 Link Here
17
                 array_push($filelist, $attachment);
35
                 array_push($filelist, $attachment);
18
                 break;
36
                 break;
19
             }
37
             }
20
@@ -117,7 +123,9 @@ function MsgParseBody($struct) {
38
@@ -117,7 +129,9 @@ function MsgParseBody($struct) {
21
           default:
39
           default:
22
             // Save the listed filename or notify the
40
             // Save the listed filename or notify the
23
             // reader that this mail is not displayed completely
41
             // reader that this mail is not displayed completely
Lines 28-34 Link Here
28
             $attachment ? array_push($filelist, $attachment) : $errors['Unsupported MIME objects present'] = true;
46
             $attachment ? array_push($filelist, $attachment) : $errors['Unsupported MIME objects present'] = true;
29
 
47
 
30
         }
48
         }
31
@@ -137,9 +145,9 @@ function FindMultiAlt($parts) {
49
@@ -137,9 +151,9 @@ function FindMultiAlt($parts) {
32
     foreach ($parts as $cur_part) {
50
     foreach ($parts as $cur_part) {
33
       $type = GetCtype($cur_part);
51
       $type = GetCtype($cur_part);
34
       if ($type == 'multipart/related') {
52
       if ($type == 'multipart/related') {
Lines 41-51 Link Here
41
       }
59
       }
42
       $altCount = count($alt_pref);
60
       $altCount = count($alt_pref);
43
       for ($j = $best_view; $j < $altCount; ++$j) {
61
       for ($j = $best_view; $j < $altCount; ++$j) {
44
@@ -163,7 +171,7 @@ function FindMultiAlt($parts) {
62
@@ -163,7 +177,8 @@ function FindMultiAlt($parts) {
45
 */
63
 */
46
 function FindMultiRel($struct) {
64
 function FindMultiRel($struct) {
47
   $entities = array();
65
   $entities = array();
48
-  $type = $struct->d_parameters['type'];
66
-  $type = $struct->d_parameters['type'];
67
+  $type = "";
49
+  if ( isset( $cur_part->d_parameters['type'] )) { $type = $cur_part->d_parameters['type']; }
68
+  if ( isset( $cur_part->d_parameters['type'] )) { $type = $cur_part->d_parameters['type']; }
50
   // Mozilla bug. Mozilla does not provide the parameter type.
69
   // Mozilla bug. Mozilla does not provide the parameter type.
51
   if (!$type) $type = 'text/html';
70
   if (!$type) $type = 'text/html';
(-)b/security/mailzu/files/patch-lib_PHPMailer.class.php (+3085 lines)
Added Link Here
1
--- lib/PHPMailer.class.php.orig	2007-06-14 19:00:15 UTC
2
+++ lib/PHPMailer.class.php
3
@@ -1,1541 +1,1541 @@
4
-<?php
5
-////////////////////////////////////////////////////
6
-// PHPMailer - PHP email class
7
-//
8
-// Class for sending email using either
9
-// sendmail, PHP mail(), or SMTP.  Methods are
10
-// based upon the standard AspEmail(tm) classes.
11
-//
12
-// Copyright (C) 2001 - 2003  Brent R. Matzelle
13
-//
14
-// License: LGPL, see LICENSE
15
-////////////////////////////////////////////////////
16
-
17
-/**
18
- * PHPMailer - PHP email transport class
19
- * @package PHPMailer
20
- * @author Brent R. Matzelle
21
- * @copyright 2001 - 2003 Brent R. Matzelle
22
- */
23
-class PHPMailer
24
-{
25
-    /////////////////////////////////////////////////
26
-    // PUBLIC VARIABLES
27
-    /////////////////////////////////////////////////
28
-
29
-    /**
30
-     * Email priority (1 = High, 3 = Normal, 5 = low).
31
-     * @var int
32
-     */
33
-    var $Priority          = 3;
34
-
35
-    /**
36
-     * Sets the CharSet of the message.
37
-     * @var string
38
-     */
39
-    var $CharSet           = "iso-8859-1";
40
-
41
-    /**
42
-     * Sets the Content-type of the message.
43
-     * @var string
44
-     */
45
-    var $ContentType        = "text/plain";
46
-
47
-    /**
48
-     * Sets the Encoding of the message. Options for this are "8bit",
49
-     * "7bit", "binary", "base64", and "quoted-printable".
50
-     * @var string
51
-     */
52
-    var $Encoding          = "8bit";
53
-
54
-    /**
55
-     * Holds the most recent mailer error message.
56
-     * @var string
57
-     */
58
-    var $ErrorInfo         = "";
59
-
60
-    /**
61
-     * Sets the From email address for the message.
62
-     * @var string
63
-     */
64
-    var $From               = "root@localhost";
65
-
66
-    /**
67
-     * Sets the From name of the message.
68
-     * @var string
69
-     */
70
-    var $FromName           = "Root User";
71
-
72
-    /**
73
-     * Sets the Sender email (Return-Path) of the message.  If not empty,
74
-     * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
75
-     * @var string
76
-     */
77
-    var $Sender            = "";
78
-
79
-    /**
80
-     * Sets the Subject of the message.
81
-     * @var string
82
-     */
83
-    var $Subject           = "";
84
-
85
-    /**
86
-     * Sets the Body of the message.  This can be either an HTML or text body.
87
-     * If HTML then run IsHTML(true).
88
-     * @var string
89
-     */
90
-    var $Body               = "";
91
-
92
-    /**
93
-     * Sets the text-only body of the message.  This automatically sets the
94
-     * email to multipart/alternative.  This body can be read by mail
95
-     * clients that do not have HTML email capability such as mutt. Clients
96
-     * that can read HTML will view the normal Body.
97
-     * @var string
98
-     */
99
-    var $AltBody           = "";
100
-
101
-    /**
102
-     * Sets word wrapping on the body of the message to a given number of 
103
-     * characters.
104
-     * @var int
105
-     */
106
-    var $WordWrap          = 0;
107
-
108
-    /**
109
-     * Method to send mail: ("mail", "sendmail", or "smtp").
110
-     * @var string
111
-     */
112
-    var $Mailer            = "mail";
113
-
114
-    /**
115
-     * Sets the path of the sendmail program.
116
-     * @var string
117
-     */
118
-    var $Sendmail          = "/usr/sbin/sendmail";
119
-    
120
-    /**
121
-     * Path to PHPMailer plugins.  This is now only useful if the SMTP class 
122
-     * is in a different directory than the PHP include path.  
123
-     * @var string
124
-     */
125
-    var $PluginDir         = "";
126
-
127
-    /**
128
-     *  Holds PHPMailer version.
129
-     *  @var string
130
-     */
131
-    var $Version           = "1.72";
132
-
133
-    /**
134
-     * Sets the email address that a reading confirmation will be sent.
135
-     * @var string
136
-     */
137
-    var $ConfirmReadingTo  = "";
138
-
139
-    /**
140
-     *  Sets the hostname to use in Message-Id and Received headers
141
-     *  and as default HELO string. If empty, the value returned
142
-     *  by SERVER_NAME is used or 'localhost.localdomain'.
143
-     *  @var string
144
-     */
145
-    var $Hostname          = "";
146
-
147
-    /////////////////////////////////////////////////
148
-    // SMTP VARIABLES
149
-    /////////////////////////////////////////////////
150
-
151
-    /**
152
-     *  Sets the SMTP hosts.  All hosts must be separated by a
153
-     *  semicolon.  You can also specify a different port
154
-     *  for each host by using this format: [hostname:port]
155
-     *  (e.g. "smtp1.example.com:25;smtp2.example.com").
156
-     *  Hosts will be tried in order.
157
-     *  @var string
158
-     */
159
-    var $Host        = "localhost";
160
-
161
-    /**
162
-     *  Sets the default SMTP server port.
163
-     *  @var int
164
-     */
165
-    var $Port        = 25;
166
-
167
-    /**
168
-     *  Sets the SMTP HELO of the message (Default is $Hostname).
169
-     *  @var string
170
-     */
171
-    var $Helo        = "";
172
-
173
-    /**
174
-     *  Sets SMTP authentication. Utilizes the Username and Password variables.
175
-     *  @var bool
176
-     */
177
-    var $SMTPAuth     = false;
178
-
179
-    /**
180
-     *  Sets SMTP username.
181
-     *  @var string
182
-     */
183
-    var $Username     = "";
184
-
185
-    /**
186
-     *  Sets SMTP password.
187
-     *  @var string
188
-     */
189
-    var $Password     = "";
190
-
191
-    /**
192
-     *  Sets the SMTP server timeout in seconds. This function will not 
193
-     *  work with the win32 version.
194
-     *  @var int
195
-     */
196
-    var $Timeout      = 10;
197
-
198
-    /**
199
-     *  Sets SMTP class debugging on or off.
200
-     *  @var bool
201
-     */
202
-    var $SMTPDebug    = false;
203
-
204
-    /**
205
-     * Prevents the SMTP connection from being closed after each mail 
206
-     * sending.  If this is set to true then to close the connection 
207
-     * requires an explicit call to SmtpClose(). 
208
-     * @var bool
209
-     */
210
-    var $SMTPKeepAlive = false;
211
-
212
-    /**#@+
213
-     * @access private
214
-     */
215
-    var $smtp            = NULL;
216
-    var $to              = array();
217
-    var $cc              = array();
218
-    var $bcc             = array();
219
-    var $ReplyTo         = array();
220
-    var $attachment      = array();
221
-    var $CustomHeader    = array();
222
-    var $message_type    = "";
223
-    var $boundary        = array();
224
-    var $language        = array();
225
-    var $error_count     = 0;
226
-    var $LE              = "\n";
227
-    /**#@-*/
228
-	
229
-		/////////////////////////////////////////////////
230
-   	// CONSTRUCTOR
231
-   	/////////////////////////////////////////////////
232
-   	/**
233
-   	* Constructor, just set up language
234
-   	* @param none
235
-   	* @return void
236
-   	*/
237
-   	function PHPMailer() {
238
-		global $conf;
239
-		global $charset;
240
-		
241
-		$this->CharSet = $charset;
242
-		
243
-   		$this->SetLanguage();
244
-		
245
-		$this->Mailer = $conf['app']['emailType'];
246
-		
247
-		if ($this->Mailer == 'smtp') {									// Set smtp variables
248
-			$this->Host = $conf['app']['smtpHost'];
249
-			$this->Port = $conf['app']['smtpPort'];
250
-		}
251
-		
252
-		if ($this->Mailer == 'sendmail')								// Set sendmail variables
253
-			$this->Sendmail = $conf['app']['sendmailPath']; 
254
-		
255
-		if ($this->Mailer == 'qmail')									// Set qmail variables
256
-			$this->Sendmail = $conf['app']['qmailPath'];
257
-   	}
258
-    
259
-    /////////////////////////////////////////////////
260
-    // VARIABLE METHODS
261
-    /////////////////////////////////////////////////
262
-
263
-    /**
264
-     * Sets message type to HTML.  
265
-     * @param bool $bool
266
-     * @return void
267
-     */
268
-    function IsHTML($bool) {
269
-        if($bool == true)
270
-            $this->ContentType = "text/html";
271
-        else
272
-            $this->ContentType = "text/plain";
273
-    }
274
-
275
-    /**
276
-     * Sets Mailer to send message using SMTP.
277
-     * @return void
278
-     */
279
-    function IsSMTP() {
280
-        $this->Mailer = "smtp";
281
-    }
282
-
283
-    /**
284
-     * Sets Mailer to send message using PHP mail() function.
285
-     * @return void
286
-     */
287
-    function IsMail() {
288
-        $this->Mailer = "mail";
289
-    }
290
-
291
-    /**
292
-     * Sets Mailer to send message using the $Sendmail program.
293
-     * @return void
294
-     */
295
-    function IsSendmail() {
296
-        $this->Mailer = "sendmail";
297
-    }
298
-
299
-    /**
300
-     * Sets Mailer to send message using the qmail MTA. 
301
-     * @return void
302
-     */
303
-    function IsQmail() {
304
-        $this->Sendmail = "/var/qmail/bin/sendmail";
305
-        $this->Mailer = "sendmail";
306
-    }
307
-
308
-
309
-    /////////////////////////////////////////////////
310
-    // RECIPIENT METHODS
311
-    /////////////////////////////////////////////////
312
-
313
-    /**
314
-     * Adds a "To" address.  
315
-     * @param string $address
316
-     * @param string $name
317
-     * @return void
318
-     */
319
-    function AddAddress($address, $name = "") {
320
-        $cur = count($this->to);
321
-        $this->to[$cur][0] = trim($address);
322
-        $this->to[$cur][1] = $name;
323
-    }
324
-
325
-    /**
326
-     * Adds a "Cc" address. Note: this function works
327
-     * with the SMTP mailer on win32, not with the "mail"
328
-     * mailer.  
329
-     * @param string $address
330
-     * @param string $name
331
-     * @return void
332
-    */
333
-    function AddCC($address, $name = "") {
334
-        $cur = count($this->cc);
335
-        $this->cc[$cur][0] = trim($address);
336
-        $this->cc[$cur][1] = $name;
337
-    }
338
-
339
-    /**
340
-     * Adds a "Bcc" address. Note: this function works
341
-     * with the SMTP mailer on win32, not with the "mail"
342
-     * mailer.  
343
-     * @param string $address
344
-     * @param string $name
345
-     * @return void
346
-     */
347
-    function AddBCC($address, $name = "") {
348
-        $cur = count($this->bcc);
349
-        $this->bcc[$cur][0] = trim($address);
350
-        $this->bcc[$cur][1] = $name;
351
-    }
352
-
353
-    /**
354
-     * Adds a "Reply-to" address.  
355
-     * @param string $address
356
-     * @param string $name
357
-     * @return void
358
-     */
359
-    function AddReplyTo($address, $name = "") {
360
-        $cur = count($this->ReplyTo);
361
-        $this->ReplyTo[$cur][0] = trim($address);
362
-        $this->ReplyTo[$cur][1] = $name;
363
-    }
364
-
365
-
366
-    /////////////////////////////////////////////////
367
-    // MAIL SENDING METHODS
368
-    /////////////////////////////////////////////////
369
-
370
-    /**
371
-     * Creates message and assigns Mailer. If the message is
372
-     * not sent successfully then it returns false.  Use the ErrorInfo
373
-     * variable to view description of the error.  
374
-     * @return bool
375
-     */
376
-    function Send() {
377
-		$header = "";
378
-        $body = "";
379
-        $result = true;
380
-
381
-        if((count($this->to) + count($this->cc) + count($this->bcc)) < 1)
382
-        {
383
-            $this->SetError($this->Lang("provide_address"));
384
-            return false;
385
-        }
386
-
387
-        // Set whether the message is multipart/alternative
388
-        if(!empty($this->AltBody))
389
-            $this->ContentType = "multipart/alternative";
390
-
391
-        $this->error_count = 0; // reset errors
392
-        $this->SetMessageType();
393
-        $header .= $this->CreateHeader();
394
-        $body = $this->CreateBody();
395
-
396
-		// Nick Korbel - 08-21-2005
397
-		if (version_compare('4.3.0',phpversion(), '<=') == 1) {
398
-			$this->Subject = html_entity_decode($this->Subject, ENT_COMPAT, $this->CharSet);
399
-			if ($this->ContentType != "text/html")
400
-				$body = html_entity_decode($body, ENT_COMPAT, $this->CharSet);
401
-		}
402
-
403
-        if($body == "") { return false; }
404
-
405
-        // Choose the mailer
406
-        switch($this->Mailer)
407
-        {
408
-            case "sendmail":
409
-                $result = $this->SendmailSend($header, $body);
410
-                break;
411
-            case "mail":
412
-                $result = $this->MailSend($header, $body);
413
-                break;
414
-            case "smtp":
415
-                $result = $this->SmtpSend($header, $body);
416
-                break;
417
-            default:
418
-            $this->SetError($this->Mailer . $this->Lang("mailer_not_supported"));
419
-                $result = false;
420
-                break;
421
-        }
422
-
423
-        return $result;
424
-    }
425
-    
426
-    /**
427
-     * Sends mail using the $Sendmail program.  
428
-     * @access private
429
-     * @return bool
430
-     */
431
-    function SendmailSend($header, $body) {
432
-        if ($this->Sender != "")
433
-            $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender);
434
-        else
435
-            $sendmail = sprintf("%s -oi -t", $this->Sendmail);
436
-
437
-        if(!@$mail = popen($sendmail, "w"))
438
-        {
439
-            $this->SetError($this->Lang("execute") . $this->Sendmail);
440
-            return false;
441
-        }
442
-
443
-        fputs($mail, $header);
444
-        fputs($mail, $body);
445
-        
446
-        $result = pclose($mail) >> 8 & 0xFF;
447
-        if($result != 0)
448
-        {
449
-            $this->SetError($this->Lang("execute") . $this->Sendmail);
450
-            return false;
451
-        }
452
-
453
-        return true;
454
-    }
455
-
456
-    /**
457
-     * Sends mail using the PHP mail() function.  
458
-     * @access private
459
-     * @return bool
460
-     */
461
-    function MailSend($header, $body) {
462
-        $to = "";
463
-        for($i = 0; $i < count($this->to); $i++)
464
-        {
465
-            if($i != 0) { $to .= ", "; }
466
-            $to .= $this->to[$i][0];
467
-        }
468
-
469
-        if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1)
470
-        {
471
-            $old_from = ini_get("sendmail_from");
472
-            ini_set("sendmail_from", $this->Sender);
473
-            $params = sprintf("-oi -f %s", $this->Sender);
474
-            $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, 
475
-                        $header, $params);
476
-        }
477
-        else
478
-            $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);
479
-
480
-        if (isset($old_from))
481
-            ini_set("sendmail_from", $old_from);
482
-
483
-        if(!$rt)
484
-        {
485
-            $this->SetError($this->Lang("instantiate"));
486
-            return false;
487
-        }
488
-
489
-        return true;
490
-    }
491
-
492
-    /**
493
-     * Sends mail via SMTP using PhpSMTP (Author:
494
-     * Chris Ryan).  Returns bool.  Returns false if there is a
495
-     * bad MAIL FROM, RCPT, or DATA input.
496
-     * @access private
497
-     * @return bool
498
-     */
499
-    function SmtpSend($header, $body) {
500
-        include_once($this->PluginDir . "Smtp.class.php");
501
-        $error = "";
502
-        $bad_rcpt = array();
503
-
504
-        if(!$this->SmtpConnect())
505
-            return false;
506
-
507
-        $smtp_from = ($this->Sender == "") ? $this->From : $this->Sender;
508
-        if(!$this->smtp->Mail($smtp_from))
509
-        {
510
-            $error = $this->Lang("from_failed") . $smtp_from;
511
-            $this->SetError($error);
512
-            $this->smtp->Reset();
513
-            return false;
514
-        }
515
-
516
-        // Attempt to send attach all recipients
517
-        for($i = 0; $i < count($this->to); $i++)
518
-        {
519
-            if(!$this->smtp->Recipient($this->to[$i][0]))
520
-                $bad_rcpt[] = $this->to[$i][0];
521
-        }
522
-        for($i = 0; $i < count($this->cc); $i++)
523
-        {
524
-            if(!$this->smtp->Recipient($this->cc[$i][0]))
525
-                $bad_rcpt[] = $this->cc[$i][0];
526
-        }
527
-        for($i = 0; $i < count($this->bcc); $i++)
528
-        {
529
-            if(!$this->smtp->Recipient($this->bcc[$i][0]))
530
-                $bad_rcpt[] = $this->bcc[$i][0];
531
-        }
532
-
533
-        if(count($bad_rcpt) > 0) // Create error message
534
-        {
535
-            for($i = 0; $i < count($bad_rcpt); $i++)
536
-            {
537
-                if($i != 0) { $error .= ", "; }
538
-                $error .= $bad_rcpt[$i];
539
-            }
540
-            $error = $this->Lang("recipients_failed") . $error;
541
-            $this->SetError($error);
542
-            $this->smtp->Reset();
543
-            return false;
544
-        }
545
-
546
-        if(!$this->smtp->Data($header . $body))
547
-        {
548
-            $this->SetError($this->Lang("data_not_accepted"));
549
-            $this->smtp->Reset();
550
-            return false;
551
-        }
552
-        if($this->SMTPKeepAlive == true)
553
-            $this->smtp->Reset();
554
-        else
555
-            $this->SmtpClose();
556
-
557
-        return true;
558
-    }
559
-
560
-    /**
561
-     * Initiates a connection to an SMTP server.  Returns false if the 
562
-     * operation failed.
563
-     * @access private
564
-     * @return bool
565
-     */
566
-    function SmtpConnect() {
567
-        if($this->smtp == NULL) { $this->smtp = new SMTP(); }
568
-
569
-        $this->smtp->do_debug = $this->SMTPDebug;
570
-        $hosts = explode(";", $this->Host);
571
-        $index = 0;
572
-        $connection = ($this->smtp->Connected()); 
573
-
574
-        // Retry while there is no connection
575
-        while($index < count($hosts) && $connection == false)
576
-        {
577
-            if(strstr($hosts[$index], ":"))
578
-                list($host, $port) = explode(":", $hosts[$index]);
579
-            else
580
-            {
581
-                $host = $hosts[$index];
582
-                $port = $this->Port;
583
-            }
584
-
585
-            if($this->smtp->Connect($host, $port, $this->Timeout))
586
-            {
587
-                if ($this->Helo != '')
588
-                    $this->smtp->Hello($this->Helo);
589
-                else
590
-                    $this->smtp->Hello($this->ServerHostname());
591
-        
592
-                if($this->SMTPAuth)
593
-                {
594
-                    if(!$this->smtp->Authenticate($this->Username, 
595
-                                                  $this->Password))
596
-                    {
597
-                        $this->SetError($this->Lang("authenticate"));
598
-                        $this->smtp->Reset();
599
-                        $connection = false;
600
-                    }
601
-                }
602
-                $connection = true;
603
-            }
604
-            $index++;
605
-        }
606
-        if(!$connection)
607
-            $this->SetError($this->Lang("connect_host"));
608
-
609
-        return $connection;
610
-    }
611
-
612
-    /**
613
-     * Closes the active SMTP session if one exists.
614
-     * @return void
615
-     */
616
-    function SmtpClose() {
617
-        if($this->smtp != NULL)
618
-        {
619
-            if($this->smtp->Connected())
620
-            {
621
-                $this->smtp->Quit();
622
-                $this->smtp->Close();
623
-            }
624
-        }
625
-    }
626
-
627
-    /**
628
-     * Sets the language for all class error messages. Always in English.
629
-     * @param none
630
-     * @access public
631
-     * @return bool
632
-     */
633
-    function SetLanguage() {
634
-        /**
635
-    	* Only printing errors in english
636
-    	*/
637
-    	$PHPMAILER_LANG = array();
638
-
639
-		$PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' .
640
-		                                     'recipient email address.';
641
-		$PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.';
642
-		$PHPMAILER_LANG["execute"] = 'Could not execute: ';
643
-		$PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.';
644
-		$PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.';
645
-		$PHPMAILER_LANG["from_failed"] = 'The following From address failed: ';
646
-		$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' .
647
-		                                       'recipients failed: ';
648
-		$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.';
649
-		$PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.';
650
-		$PHPMAILER_LANG["file_access"] = 'Could not access file: ';
651
-		$PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: ';
652
-		$PHPMAILER_LANG["encoding"] = 'Unknown encoding: ';
653
-
654
-        $this->language = $PHPMAILER_LANG;
655
-
656
-        return true;
657
-    }
658
-
659
-    /////////////////////////////////////////////////
660
-    // MESSAGE CREATION METHODS
661
-    /////////////////////////////////////////////////
662
-
663
-    /**
664
-     * Creates recipient headers.  
665
-     * @access private
666
-     * @return string
667
-     */
668
-    function AddrAppend($type, $addr) {
669
-        $addr_str = $type . ": ";
670
-        $addr_str .= $this->AddrFormat($addr[0]);
671
-        if(count($addr) > 1)
672
-        {
673
-            for($i = 1; $i < count($addr); $i++)
674
-                $addr_str .= ", " . $this->AddrFormat($addr[$i]);
675
-        }
676
-        $addr_str .= $this->LE;
677
-
678
-        return $addr_str;
679
-    }
680
-    
681
-    /**
682
-     * Formats an address correctly. 
683
-     * @access private
684
-     * @return string
685
-     */
686
-    function AddrFormat($addr) {
687
-        if(empty($addr[1]))
688
-            $formatted = $addr[0];
689
-        else
690
-        {
691
-            $formatted = $this->EncodeHeader($addr[1], 'phrase') . " <" . 
692
-                         $addr[0] . ">";
693
-        }
694
-
695
-        return $formatted;
696
-    }
697
-
698
-    /**
699
-     * Wraps message for use with mailers that do not
700
-     * automatically perform wrapping and for quoted-printable.
701
-     * Original written by philippe.  
702
-     * @access private
703
-     * @return string
704
-     */
705
-    function WrapText($message, $length, $qp_mode = false) {
706
-        $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
707
-
708
-        $message = $this->FixEOL($message);
709
-        if (substr($message, -1) == $this->LE)
710
-            $message = substr($message, 0, -1);
711
-
712
-        $line = explode($this->LE, $message);
713
-        $message = "";
714
-        for ($i=0 ;$i < count($line); $i++)
715
-        {
716
-          $line_part = explode(" ", $line[$i]);
717
-          $buf = "";
718
-          for ($e = 0; $e<count($line_part); $e++)
719
-          {
720
-              $word = $line_part[$e];
721
-              if ($qp_mode and (strlen($word) > $length))
722
-              {
723
-                $space_left = $length - strlen($buf) - 1;
724
-                if ($e != 0)
725
-                {
726
-                    if ($space_left > 20)
727
-                    {
728
-                        $len = $space_left;
729
-                        if (substr($word, $len - 1, 1) == "=")
730
-                          $len--;
731
-                        elseif (substr($word, $len - 2, 1) == "=")
732
-                          $len -= 2;
733
-                        $part = substr($word, 0, $len);
734
-                        $word = substr($word, $len);
735
-                        $buf .= " " . $part;
736
-                        $message .= $buf . sprintf("=%s", $this->LE);
737
-                    }
738
-                    else
739
-                    {
740
-                        $message .= $buf . $soft_break;
741
-                    }
742
-                    $buf = "";
743
-                }
744
-                while (strlen($word) > 0)
745
-                {
746
-                    $len = $length;
747
-                    if (substr($word, $len - 1, 1) == "=")
748
-                        $len--;
749
-                    elseif (substr($word, $len - 2, 1) == "=")
750
-                        $len -= 2;
751
-                    $part = substr($word, 0, $len);
752
-                    $word = substr($word, $len);
753
-
754
-                    if (strlen($word) > 0)
755
-                        $message .= $part . sprintf("=%s", $this->LE);
756
-                    else
757
-                        $buf = $part;
758
-                }
759
-              }
760
-              else
761
-              {
762
-                $buf_o = $buf;
763
-                $buf .= ($e == 0) ? $word : (" " . $word); 
764
-
765
-                if (strlen($buf) > $length and $buf_o != "")
766
-                {
767
-                    $message .= $buf_o . $soft_break;
768
-                    $buf = $word;
769
-                }
770
-              }
771
-          }
772
-          $message .= $buf . $this->LE;
773
-        }
774
-
775
-        return $message;
776
-    }
777
-    
778
-    /**
779
-     * Set the body wrapping.
780
-     * @access private
781
-     * @return void
782
-     */
783
-    function SetWordWrap() {
784
-        if($this->WordWrap < 1)
785
-            return;
786
-            
787
-        switch($this->message_type)
788
-        {
789
-           case "alt":
790
-              // fall through
791
-           case "alt_attachment":
792
-              $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
793
-              break;
794
-           default:
795
-              $this->Body = $this->WrapText($this->Body, $this->WordWrap);
796
-              break;
797
-        }
798
-    }
799
-
800
-    /**
801
-     * Assembles message header.  
802
-     * @access private
803
-     * @return string
804
-     */
805
-    function CreateHeader() {
806
-        $result = "";
807
-        
808
-        // Set the boundaries
809
-        $uniq_id = md5(uniqid(time()));
810
-        $this->boundary[1] = "b1_" . $uniq_id;
811
-        $this->boundary[2] = "b2_" . $uniq_id;
812
-
813
-        $result .= $this->HeaderLine("Date", $this->RFCDate());
814
-        if($this->Sender == "")
815
-            $result .= $this->HeaderLine("Return-Path", trim($this->From));
816
-        else
817
-            $result .= $this->HeaderLine("Return-Path", trim($this->Sender));
818
-        
819
-        // To be created automatically by mail()
820
-        if($this->Mailer != "mail")
821
-        {
822
-            if(count($this->to) > 0)
823
-                $result .= $this->AddrAppend("To", $this->to);
824
-            else if (count($this->cc) == 0)
825
-                $result .= $this->HeaderLine("To", "undisclosed-recipients:;");
826
-            if(count($this->cc) > 0)
827
-                $result .= $this->AddrAppend("Cc", $this->cc);
828
-        }
829
-
830
-        $from = array();
831
-        $from[0][0] = trim($this->From);
832
-        $from[0][1] = $this->FromName;
833
-        $result .= $this->AddrAppend("From", $from); 
834
-
835
-        // sendmail and mail() extract Bcc from the header before sending
836
-        if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
837
-            $result .= $this->AddrAppend("Bcc", $this->bcc);
838
-
839
-        if(count($this->ReplyTo) > 0)
840
-            $result .= $this->AddrAppend("Reply-to", $this->ReplyTo);
841
-
842
-        // mail() sets the subject itself
843
-        if($this->Mailer != "mail")
844
-            $result .= $this->HeaderLine("Subject", $this->EncodeHeader(trim($this->Subject)));
845
-
846
-        $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
847
-        $result .= $this->HeaderLine("X-Priority", $this->Priority);
848
-        $result .= $this->HeaderLine("X-Mailer", "PHPMailer [version " . $this->Version . "]");
849
-        
850
-        if($this->ConfirmReadingTo != "")
851
-        {
852
-            $result .= $this->HeaderLine("Disposition-Notification-To", 
853
-                       "<" . trim($this->ConfirmReadingTo) . ">");
854
-        }
855
-
856
-        // Add custom headers
857
-        for($index = 0; $index < count($this->CustomHeader); $index++)
858
-        {
859
-            $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), 
860
-                       $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
861
-        }
862
-        $result .= $this->HeaderLine("MIME-Version", "1.0");
863
-
864
-        switch($this->message_type)
865
-        {
866
-            case "plain":
867
-                $result .= $this->HeaderLine("Content-Transfer-Encoding", $this->Encoding);
868
-                $result .= sprintf("Content-Type: %s; charset=\"%s\"",
869
-                                    $this->ContentType, $this->CharSet);
870
-                break;
871
-            case "attachments":
872
-                // fall through
873
-            case "alt_attachments":
874
-                if($this->InlineImageExists())
875
-                {
876
-                    $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 
877
-                                    "multipart/related", $this->LE, $this->LE, 
878
-                                    $this->boundary[1], $this->LE);
879
-                }
880
-                else
881
-                {
882
-                    $result .= $this->HeaderLine("Content-Type", "multipart/mixed;");
883
-                    $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
884
-                }
885
-                break;
886
-            case "alt":
887
-                $result .= $this->HeaderLine("Content-Type", "multipart/alternative;");
888
-                $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
889
-                break;
890
-        }
891
-
892
-        if($this->Mailer != "mail")
893
-            $result .= $this->LE.$this->LE;
894
-
895
-        return $result;
896
-    }
897
-
898
-    /**
899
-     * Assembles the message body.  Returns an empty string on failure.
900
-     * @access private
901
-     * @return string
902
-     */
903
-    function CreateBody() {
904
-        $result = "";
905
-
906
-        $this->SetWordWrap();
907
-
908
-        switch($this->message_type)
909
-        {
910
-            case "alt":
911
-                $result .= $this->GetBoundary($this->boundary[1], "", 
912
-                                              "text/plain", "");
913
-                $result .= $this->EncodeString($this->AltBody, $this->Encoding);
914
-                $result .= $this->LE.$this->LE;
915
-                $result .= $this->GetBoundary($this->boundary[1], "", 
916
-                                              "text/html", "");
917
-                
918
-                $result .= $this->EncodeString($this->Body, $this->Encoding);
919
-                $result .= $this->LE.$this->LE;
920
-    
921
-                $result .= $this->EndBoundary($this->boundary[1]);
922
-                break;
923
-            case "plain":
924
-                $result .= $this->EncodeString($this->Body, $this->Encoding);
925
-                break;
926
-            case "attachments":
927
-                $result .= $this->GetBoundary($this->boundary[1], "", "", "");
928
-                $result .= $this->EncodeString($this->Body, $this->Encoding);
929
-                $result .= $this->LE;
930
-     
931
-                $result .= $this->AttachAll();
932
-                break;
933
-            case "alt_attachments":
934
-                $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
935
-                $result .= sprintf("Content-Type: %s;%s" .
936
-                                   "\tboundary=\"%s\"%s",
937
-                                   "multipart/alternative", $this->LE, 
938
-                                   $this->boundary[2], $this->LE.$this->LE);
939
-    
940
-                // Create text body
941
-                $result .= $this->GetBoundary($this->boundary[2], "", 
942
-                                              "text/plain", "") . $this->LE;
943
-
944
-                $result .= $this->EncodeString($this->AltBody, $this->Encoding);
945
-                $result .= $this->LE.$this->LE;
946
-    
947
-                // Create the HTML body
948
-                $result .= $this->GetBoundary($this->boundary[2], "", 
949
-                                              "text/html", "") . $this->LE;
950
-    
951
-                $result .= $this->EncodeString($this->Body, $this->Encoding);
952
-                $result .= $this->LE.$this->LE;
953
-
954
-                $result .= $this->EndBoundary($this->boundary[2]);
955
-                
956
-                $result .= $this->AttachAll();
957
-                break;
958
-        }
959
-        if($this->IsError())
960
-            $result = "";
961
-
962
-        return $result;
963
-    }
964
-
965
-    /**
966
-     * Returns the start of a message boundary.
967
-     * @access private
968
-     */
969
-    function GetBoundary($boundary, $charSet, $contentType, $encoding) {
970
-        $result = "";
971
-        if($charSet == "") { $charSet = $this->CharSet; }
972
-        if($contentType == "") { $contentType = $this->ContentType; }
973
-        if($encoding == "") { $encoding = $this->Encoding; }
974
-
975
-        $result .= $this->TextLine("--" . $boundary);
976
-        $result .= sprintf("Content-Type: %s; charset = \"%s\"", 
977
-                            $contentType, $charSet);
978
-        $result .= $this->LE;
979
-        $result .= $this->HeaderLine("Content-Transfer-Encoding", $encoding);
980
-        $result .= $this->LE;
981
-       
982
-        return $result;
983
-    }
984
-    
985
-    /**
986
-     * Returns the end of a message boundary.
987
-     * @access private
988
-     */
989
-    function EndBoundary($boundary) {
990
-        return $this->LE . "--" . $boundary . "--" . $this->LE; 
991
-    }
992
-    
993
-    /**
994
-     * Sets the message type.
995
-     * @access private
996
-     * @return void
997
-     */
998
-    function SetMessageType() {
999
-        if(count($this->attachment) < 1 && strlen($this->AltBody) < 1)
1000
-            $this->message_type = "plain";
1001
-        else
1002
-        {
1003
-            if(count($this->attachment) > 0)
1004
-                $this->message_type = "attachments";
1005
-            if(strlen($this->AltBody) > 0 && count($this->attachment) < 1)
1006
-                $this->message_type = "alt";
1007
-            if(strlen($this->AltBody) > 0 && count($this->attachment) > 0)
1008
-                $this->message_type = "alt_attachments";
1009
-        }
1010
-    }
1011
-
1012
-    /**
1013
-     * Returns a formatted header line.
1014
-     * @access private
1015
-     * @return string
1016
-     */
1017
-    function HeaderLine($name, $value) {
1018
-        return $name . ": " . $value . $this->LE;
1019
-    }
1020
-
1021
-    /**
1022
-     * Returns a formatted mail line.
1023
-     * @access private
1024
-     * @return string
1025
-     */
1026
-    function TextLine($value) {
1027
-        return $value . $this->LE;
1028
-    }
1029
-
1030
-    /////////////////////////////////////////////////
1031
-    // ATTACHMENT METHODS
1032
-    /////////////////////////////////////////////////
1033
-
1034
-    /**
1035
-     * Adds an attachment from a path on the filesystem.
1036
-     * Returns false if the file could not be found
1037
-     * or accessed.
1038
-     * @param string $path Path to the attachment.
1039
-     * @param string $name Overrides the attachment name.
1040
-     * @param string $encoding File encoding (see $Encoding).
1041
-     * @param string $type File extension (MIME) type.
1042
-     * @return bool
1043
-     */
1044
-    function AddAttachment($path, $name = "", $encoding = "base64", 
1045
-                           $type = "application/octet-stream") {
1046
-        if(!@is_file($path))
1047
-        {
1048
-            $this->SetError($this->Lang("file_access") . $path);
1049
-            return false;
1050
-        }
1051
-
1052
-        $filename = basename($path);
1053
-        if($name == "")
1054
-            $name = $filename;
1055
-
1056
-        $cur = count($this->attachment);
1057
-        $this->attachment[$cur][0] = $path;
1058
-        $this->attachment[$cur][1] = $filename;
1059
-        $this->attachment[$cur][2] = $name;
1060
-        $this->attachment[$cur][3] = $encoding;
1061
-        $this->attachment[$cur][4] = $type;
1062
-        $this->attachment[$cur][5] = false; // isStringAttachment
1063
-        $this->attachment[$cur][6] = "attachment";
1064
-        $this->attachment[$cur][7] = 0;
1065
-
1066
-        return true;
1067
-    }
1068
-
1069
-    /**
1070
-     * Attaches all fs, string, and binary attachments to the message.
1071
-     * Returns an empty string on failure.
1072
-     * @access private
1073
-     * @return string
1074
-     */
1075
-    function AttachAll() {
1076
-        // Return text of body
1077
-        $mime = array();
1078
-
1079
-        // Add all attachments
1080
-        for($i = 0; $i < count($this->attachment); $i++)
1081
-        {
1082
-            // Check for string attachment
1083
-            $bString = $this->attachment[$i][5];
1084
-            if ($bString)
1085
-                $string = $this->attachment[$i][0];
1086
-            else
1087
-                $path = $this->attachment[$i][0];
1088
-
1089
-            $filename    = $this->attachment[$i][1];
1090
-            $name        = $this->attachment[$i][2];
1091
-            $encoding    = $this->attachment[$i][3];
1092
-            $type        = $this->attachment[$i][4];
1093
-            $disposition = $this->attachment[$i][6];
1094
-            $cid         = $this->attachment[$i][7];
1095
-            
1096
-            $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
1097
-            $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
1098
-            $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
1099
-
1100
-            if($disposition == "inline")
1101
-                $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
1102
-
1103
-            $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", 
1104
-                              $disposition, $name, $this->LE.$this->LE);
1105
-
1106
-            // Encode as string attachment
1107
-            if($bString)
1108
-            {
1109
-                $mime[] = $this->EncodeString($string, $encoding);
1110
-                if($this->IsError()) { return ""; }
1111
-                $mime[] = $this->LE.$this->LE;
1112
-            }
1113
-            else
1114
-            {
1115
-                $mime[] = $this->EncodeFile($path, $encoding);                
1116
-                if($this->IsError()) { return ""; }
1117
-                $mime[] = $this->LE.$this->LE;
1118
-            }
1119
-        }
1120
-
1121
-        $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
1122
-
1123
-        return join("", $mime);
1124
-    }
1125
-    
1126
-    /**
1127
-     * Encodes attachment in requested format.  Returns an
1128
-     * empty string on failure.
1129
-     * @access private
1130
-     * @return string
1131
-     */
1132
-    function EncodeFile ($path, $encoding = "base64") {
1133
-        if(!@$fd = fopen($path, "rb"))
1134
-        {
1135
-            $this->SetError($this->Lang("file_open") . $path);
1136
-            return "";
1137
-        }
1138
-        $file_buffer = fread($fd, filesize($path));
1139
-        $file_buffer = $this->EncodeString($file_buffer, $encoding);
1140
-        fclose($fd);
1141
-
1142
-        return $file_buffer;
1143
-    }
1144
-
1145
-    /**
1146
-     * Encodes string to requested format. Returns an
1147
-     * empty string on failure.
1148
-     * @access private
1149
-     * @return string
1150
-     */
1151
-    function EncodeString ($str, $encoding = "base64") {
1152
-        $encoded = "";
1153
-        switch(strtolower($encoding)) {
1154
-          case "base64":
1155
-              // chunk_split is found in PHP >= 3.0.6
1156
-              $encoded = chunk_split(base64_encode($str), 76, $this->LE);
1157
-              break;
1158
-          case "7bit":
1159
-          case "8bit":
1160
-              $encoded = $this->FixEOL($str);
1161
-              if (substr($encoded, -(strlen($this->LE))) != $this->LE)
1162
-                $encoded .= $this->LE;
1163
-              break;
1164
-          case "binary":
1165
-              $encoded = $str;
1166
-              break;
1167
-          case "quoted-printable":
1168
-              $encoded = $this->EncodeQP($str);
1169
-              break;
1170
-          default:
1171
-              $this->SetError($this->Lang("encoding") . $encoding);
1172
-              break;
1173
-        }
1174
-        return $encoded;
1175
-    }
1176
-
1177
-    /**
1178
-     * Encode a header string to best of Q, B, quoted or none.  
1179
-     * @access private
1180
-     * @return string
1181
-     */
1182
-    function EncodeHeader ($str, $position = 'text') {
1183
-      $x = 0;
1184
-      
1185
-      switch (strtolower($position)) {
1186
-        case 'phrase':
1187
-          if (!preg_match('/[\200-\377]/', $str)) {
1188
-            // Can't use addslashes as we don't know what value has magic_quotes_sybase.
1189
-            $encoded = addcslashes($str, "\0..\37\177\\\"");
1190
-
1191
-            if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str))
1192
-              return ($encoded);
1193
-            else
1194
-              return ("\"$encoded\"");
1195
-          }
1196
-          $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
1197
-          break;
1198
-        case 'comment':
1199
-          $x = preg_match_all('/[()"]/', $str, $matches);
1200
-          // Fall-through
1201
-        case 'text':
1202
-        default:
1203
-          $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
1204
-          break;
1205
-      }
1206
-
1207
-      if ($x == 0)
1208
-        return ($str);
1209
-
1210
-      $maxlen = 75 - 7 - strlen($this->CharSet);
1211
-      // Try to select the encoding which should produce the shortest output
1212
-      if (strlen($str)/3 < $x) {
1213
-        $encoding = 'B';
1214
-        $encoded = base64_encode($str);
1215
-        $maxlen -= $maxlen % 4;
1216
-        $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
1217
-      } else {
1218
-        $encoding = 'Q';
1219
-        $encoded = $this->EncodeQ($str, $position);
1220
-        $encoded = $this->WrapText($encoded, $maxlen, true);
1221
-        $encoded = str_replace("=".$this->LE, "\n", trim($encoded));
1222
-      }
1223
-
1224
-      $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
1225
-      $encoded = trim(str_replace("\n", $this->LE, $encoded));
1226
-      
1227
-      return $encoded;
1228
-    }
1229
-    
1230
-    /**
1231
-     * Encode string to quoted-printable.  
1232
-     * @access private
1233
-     * @return string
1234
-     */
1235
-    function EncodeQP ($str) {
1236
-        $encoded = $this->FixEOL($str);
1237
-        if (substr($encoded, -(strlen($this->LE))) != $this->LE)
1238
-            $encoded .= $this->LE;
1239
-
1240
-        // Replace every high ascii, control and = characters
1241
-        $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',
1242
-                  "'='.sprintf('%02X', ord('\\1'))", $encoded);
1243
-        // Replace every spaces and tabs when it's the last character on a line
1244
-        $encoded = preg_replace("/([\011\040])".$this->LE."/e",
1245
-                  "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);
1246
-
1247
-        // Maximum line length of 76 characters before CRLF (74 + space + '=')
1248
-        $encoded = $this->WrapText($encoded, 74, true);
1249
-
1250
-        return $encoded;
1251
-    }
1252
-
1253
-    /**
1254
-     * Encode string to q encoding.  
1255
-     * @access private
1256
-     * @return string
1257
-     */
1258
-    function EncodeQ ($str, $position = "text") {
1259
-        // There should not be any EOL in the string
1260
-        $encoded = preg_replace("[\r\n]", "", $str);
1261
-
1262
-        switch (strtolower($position)) {
1263
-          case "phrase":
1264
-            $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
1265
-            break;
1266
-          case "comment":
1267
-            $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
1268
-          case "text":
1269
-          default:
1270
-            // Replace every high ascii, control =, ? and _ characters
1271
-            $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
1272
-                  "'='.sprintf('%02X', ord('\\1'))", $encoded);
1273
-            break;
1274
-        }
1275
-        
1276
-        // Replace every spaces to _ (more readable than =20)
1277
-        $encoded = str_replace(" ", "_", $encoded);
1278
-
1279
-        return $encoded;
1280
-    }
1281
-
1282
-    /**
1283
-     * Adds a string or binary attachment (non-filesystem) to the list.
1284
-     * This method can be used to attach ascii or binary data,
1285
-     * such as a BLOB record from a database.
1286
-     * @param string $string String attachment data.
1287
-     * @param string $filename Name of the attachment.
1288
-     * @param string $encoding File encoding (see $Encoding).
1289
-     * @param string $type File extension (MIME) type.
1290
-     * @return void
1291
-     */
1292
-    function AddStringAttachment($string, $filename, $encoding = "base64", 
1293
-                                 $type = "application/octet-stream") {
1294
-        // Append to $attachment array
1295
-        $cur = count($this->attachment);
1296
-        $this->attachment[$cur][0] = $string;
1297
-        $this->attachment[$cur][1] = $filename;
1298
-        $this->attachment[$cur][2] = $filename;
1299
-        $this->attachment[$cur][3] = $encoding;
1300
-        $this->attachment[$cur][4] = $type;
1301
-        $this->attachment[$cur][5] = true; // isString
1302
-        $this->attachment[$cur][6] = "attachment";
1303
-        $this->attachment[$cur][7] = 0;
1304
-    }
1305
-    
1306
-    /**
1307
-     * Adds an embedded attachment.  This can include images, sounds, and 
1308
-     * just about any other document.  Make sure to set the $type to an 
1309
-     * image type.  For JPEG images use "image/jpeg" and for GIF images 
1310
-     * use "image/gif".
1311
-     * @param string $path Path to the attachment.
1312
-     * @param string $cid Content ID of the attachment.  Use this to identify 
1313
-     *        the Id for accessing the image in an HTML form.
1314
-     * @param string $name Overrides the attachment name.
1315
-     * @param string $encoding File encoding (see $Encoding).
1316
-     * @param string $type File extension (MIME) type.  
1317
-     * @return bool
1318
-     */
1319
-    function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64", 
1320
-                              $type = "application/octet-stream") {
1321
-    
1322
-        if(!@is_file($path))
1323
-        {
1324
-            $this->SetError($this->Lang("file_access") . $path);
1325
-            return false;
1326
-        }
1327
-
1328
-        $filename = basename($path);
1329
-        if($name == "")
1330
-            $name = $filename;
1331
-
1332
-        // Append to $attachment array
1333
-        $cur = count($this->attachment);
1334
-        $this->attachment[$cur][0] = $path;
1335
-        $this->attachment[$cur][1] = $filename;
1336
-        $this->attachment[$cur][2] = $name;
1337
-        $this->attachment[$cur][3] = $encoding;
1338
-        $this->attachment[$cur][4] = $type;
1339
-        $this->attachment[$cur][5] = false; // isStringAttachment
1340
-        $this->attachment[$cur][6] = "inline";
1341
-        $this->attachment[$cur][7] = $cid;
1342
-    
1343
-        return true;
1344
-    }
1345
-    
1346
-    /**
1347
-     * Returns true if an inline attachment is present.
1348
-     * @access private
1349
-     * @return bool
1350
-     */
1351
-    function InlineImageExists() {
1352
-        $result = false;
1353
-        for($i = 0; $i < count($this->attachment); $i++)
1354
-        {
1355
-            if($this->attachment[$i][6] == "inline")
1356
-            {
1357
-                $result = true;
1358
-                break;
1359
-            }
1360
-        }
1361
-        
1362
-        return $result;
1363
-    }
1364
-
1365
-    /////////////////////////////////////////////////
1366
-    // MESSAGE RESET METHODS
1367
-    /////////////////////////////////////////////////
1368
-
1369
-    /**
1370
-     * Clears all recipients assigned in the TO array.  Returns void.
1371
-     * @return void
1372
-     */
1373
-    function ClearAddresses() {
1374
-        $this->to = array();
1375
-    }
1376
-
1377
-    /**
1378
-     * Clears all recipients assigned in the CC array.  Returns void.
1379
-     * @return void
1380
-     */
1381
-    function ClearCCs() {
1382
-        $this->cc = array();
1383
-    }
1384
-
1385
-    /**
1386
-     * Clears all recipients assigned in the BCC array.  Returns void.
1387
-     * @return void
1388
-     */
1389
-    function ClearBCCs() {
1390
-        $this->bcc = array();
1391
-    }
1392
-
1393
-    /**
1394
-     * Clears all recipients assigned in the ReplyTo array.  Returns void.
1395
-     * @return void
1396
-     */
1397
-    function ClearReplyTos() {
1398
-        $this->ReplyTo = array();
1399
-    }
1400
-
1401
-    /**
1402
-     * Clears all recipients assigned in the TO, CC and BCC
1403
-     * array.  Returns void.
1404
-     * @return void
1405
-     */
1406
-    function ClearAllRecipients() {
1407
-        $this->to = array();
1408
-        $this->cc = array();
1409
-        $this->bcc = array();
1410
-    }
1411
-
1412
-    /**
1413
-     * Clears all previously set filesystem, string, and binary
1414
-     * attachments.  Returns void.
1415
-     * @return void
1416
-     */
1417
-    function ClearAttachments() {
1418
-        $this->attachment = array();
1419
-    }
1420
-
1421
-    /**
1422
-     * Clears all custom headers.  Returns void.
1423
-     * @return void
1424
-     */
1425
-    function ClearCustomHeaders() {
1426
-        $this->CustomHeader = array();
1427
-    }
1428
-
1429
-
1430
-    /////////////////////////////////////////////////
1431
-    // MISCELLANEOUS METHODS
1432
-    /////////////////////////////////////////////////
1433
-
1434
-    /**
1435
-     * Adds the error message to the error container.
1436
-     * Returns void.
1437
-     * @access private
1438
-     * @return void
1439
-     */
1440
-    function SetError($msg) {
1441
-        $this->error_count++;
1442
-        $this->ErrorInfo = $msg;
1443
-    }
1444
-
1445
-    /**
1446
-     * Returns the proper RFC 822 formatted date. 
1447
-     * @access private
1448
-     * @return string
1449
-     */
1450
-    function RFCDate() {
1451
-        $tz = date("Z");
1452
-        $tzs = ($tz < 0) ? "-" : "+";
1453
-        $tz = abs($tz);
1454
-        $tz = ($tz/3600)*100 + ($tz%3600)/60;
1455
-        $result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);
1456
-
1457
-        return $result;
1458
-    }
1459
-    
1460
-    /**
1461
-     * Returns the appropriate server variable.  Should work with both 
1462
-     * PHP 4.1.0+ as well as older versions.  Returns an empty string 
1463
-     * if nothing is found.
1464
-     * @access private
1465
-     * @return mixed
1466
-     */
1467
-    function ServerVar($varName) {
1468
-        global $HTTP_SERVER_VARS;
1469
-        global $HTTP_ENV_VARS;
1470
-
1471
-        if(!isset($_SERVER))
1472
-        {
1473
-            $_SERVER = $HTTP_SERVER_VARS;
1474
-            if(!isset($_SERVER["REMOTE_ADDR"]))
1475
-                $_SERVER = $HTTP_ENV_VARS; // must be Apache
1476
-        }
1477
-        
1478
-        if(isset($_SERVER[$varName]))
1479
-            return $_SERVER[$varName];
1480
-        else
1481
-            return "";
1482
-    }
1483
-
1484
-    /**
1485
-     * Returns the server hostname or 'localhost.localdomain' if unknown.
1486
-     * @access private
1487
-     * @return string
1488
-     */
1489
-    function ServerHostname() {
1490
-        if ($this->Hostname != "")
1491
-            $result = $this->Hostname;
1492
-        elseif ($this->ServerVar('SERVER_NAME') != "")
1493
-            $result = $this->ServerVar('SERVER_NAME');
1494
-        else
1495
-            $result = "localhost.localdomain";
1496
-
1497
-        return $result;
1498
-    }
1499
-
1500
-    /**
1501
-     * Returns a message in the appropriate language.
1502
-     * @access private
1503
-     * @return string
1504
-     */
1505
-    function Lang($key) {
1506
-        if(count($this->language) < 1)
1507
-            $this->SetLanguage("en"); // set the default language
1508
-    
1509
-        if(isset($this->language[$key]))
1510
-            return $this->language[$key];
1511
-        else
1512
-            return "Language string failed to load: " . $key;
1513
-    }
1514
-    
1515
-    /**
1516
-     * Returns true if an error occurred.
1517
-     * @return bool
1518
-     */
1519
-    function IsError() {
1520
-        return ($this->error_count > 0);
1521
-    }
1522
-
1523
-    /**
1524
-     * Changes every end of line from CR or LF to CRLF.  
1525
-     * @access private
1526
-     * @return string
1527
-     */
1528
-    function FixEOL($str) {
1529
-        $str = str_replace("\r\n", "\n", $str);
1530
-        $str = str_replace("\r", "\n", $str);
1531
-        $str = str_replace("\n", $this->LE, $str);
1532
-        return $str;
1533
-    }
1534
-
1535
-    /**
1536
-     * Adds a custom header. 
1537
-     * @return void
1538
-     */
1539
-    function AddCustomHeader($custom_header) {
1540
-        $this->CustomHeader[] = explode(":", $custom_header, 2);
1541
-    }
1542
-}
1543
-
1544
-?>
1545
+<?php
1546
+////////////////////////////////////////////////////
1547
+// PHPMailer - PHP email class
1548
+//
1549
+// Class for sending email using either
1550
+// sendmail, PHP mail(), or SMTP.  Methods are
1551
+// based upon the standard AspEmail(tm) classes.
1552
+//
1553
+// Copyright (C) 2001 - 2003  Brent R. Matzelle
1554
+//
1555
+// License: LGPL, see LICENSE
1556
+////////////////////////////////////////////////////
1557
+
1558
+/**
1559
+ * PHPMailer - PHP email transport class
1560
+ * @package PHPMailer
1561
+ * @author Brent R. Matzelle
1562
+ * @copyright 2001 - 2003 Brent R. Matzelle
1563
+ */
1564
+class PHPMailer
1565
+{
1566
+    /////////////////////////////////////////////////
1567
+    // PUBLIC VARIABLES
1568
+    /////////////////////////////////////////////////
1569
+
1570
+    /**
1571
+     * Email priority (1 = High, 3 = Normal, 5 = low).
1572
+     * @var int
1573
+     */
1574
+    var $Priority          = 3;
1575
+
1576
+    /**
1577
+     * Sets the CharSet of the message.
1578
+     * @var string
1579
+     */
1580
+    var $CharSet           = "iso-8859-1";
1581
+
1582
+    /**
1583
+     * Sets the Content-type of the message.
1584
+     * @var string
1585
+     */
1586
+    var $ContentType        = "text/plain";
1587
+
1588
+    /**
1589
+     * Sets the Encoding of the message. Options for this are "8bit",
1590
+     * "7bit", "binary", "base64", and "quoted-printable".
1591
+     * @var string
1592
+     */
1593
+    var $Encoding          = "8bit";
1594
+
1595
+    /**
1596
+     * Holds the most recent mailer error message.
1597
+     * @var string
1598
+     */
1599
+    var $ErrorInfo         = "";
1600
+
1601
+    /**
1602
+     * Sets the From email address for the message.
1603
+     * @var string
1604
+     */
1605
+    var $From               = "root@localhost";
1606
+
1607
+    /**
1608
+     * Sets the From name of the message.
1609
+     * @var string
1610
+     */
1611
+    var $FromName           = "Root User";
1612
+
1613
+    /**
1614
+     * Sets the Sender email (Return-Path) of the message.  If not empty,
1615
+     * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
1616
+     * @var string
1617
+     */
1618
+    var $Sender            = "";
1619
+
1620
+    /**
1621
+     * Sets the Subject of the message.
1622
+     * @var string
1623
+     */
1624
+    var $Subject           = "";
1625
+
1626
+    /**
1627
+     * Sets the Body of the message.  This can be either an HTML or text body.
1628
+     * If HTML then run IsHTML(true).
1629
+     * @var string
1630
+     */
1631
+    var $Body               = "";
1632
+
1633
+    /**
1634
+     * Sets the text-only body of the message.  This automatically sets the
1635
+     * email to multipart/alternative.  This body can be read by mail
1636
+     * clients that do not have HTML email capability such as mutt. Clients
1637
+     * that can read HTML will view the normal Body.
1638
+     * @var string
1639
+     */
1640
+    var $AltBody           = "";
1641
+
1642
+    /**
1643
+     * Sets word wrapping on the body of the message to a given number of 
1644
+     * characters.
1645
+     * @var int
1646
+     */
1647
+    var $WordWrap          = 0;
1648
+
1649
+    /**
1650
+     * Method to send mail: ("mail", "sendmail", or "smtp").
1651
+     * @var string
1652
+     */
1653
+    var $Mailer            = "mail";
1654
+
1655
+    /**
1656
+     * Sets the path of the sendmail program.
1657
+     * @var string
1658
+     */
1659
+    var $Sendmail          = "/usr/sbin/sendmail";
1660
+    
1661
+    /**
1662
+     * Path to PHPMailer plugins.  This is now only useful if the SMTP class 
1663
+     * is in a different directory than the PHP include path.  
1664
+     * @var string
1665
+     */
1666
+    var $PluginDir         = "";
1667
+
1668
+    /**
1669
+     *  Holds PHPMailer version.
1670
+     *  @var string
1671
+     */
1672
+    var $Version           = "1.72";
1673
+
1674
+    /**
1675
+     * Sets the email address that a reading confirmation will be sent.
1676
+     * @var string
1677
+     */
1678
+    var $ConfirmReadingTo  = "";
1679
+
1680
+    /**
1681
+     *  Sets the hostname to use in Message-Id and Received headers
1682
+     *  and as default HELO string. If empty, the value returned
1683
+     *  by SERVER_NAME is used or 'localhost.localdomain'.
1684
+     *  @var string
1685
+     */
1686
+    var $Hostname          = "";
1687
+
1688
+    /////////////////////////////////////////////////
1689
+    // SMTP VARIABLES
1690
+    /////////////////////////////////////////////////
1691
+
1692
+    /**
1693
+     *  Sets the SMTP hosts.  All hosts must be separated by a
1694
+     *  semicolon.  You can also specify a different port
1695
+     *  for each host by using this format: [hostname:port]
1696
+     *  (e.g. "smtp1.example.com:25;smtp2.example.com").
1697
+     *  Hosts will be tried in order.
1698
+     *  @var string
1699
+     */
1700
+    var $Host        = "localhost";
1701
+
1702
+    /**
1703
+     *  Sets the default SMTP server port.
1704
+     *  @var int
1705
+     */
1706
+    var $Port        = 25;
1707
+
1708
+    /**
1709
+     *  Sets the SMTP HELO of the message (Default is $Hostname).
1710
+     *  @var string
1711
+     */
1712
+    var $Helo        = "";
1713
+
1714
+    /**
1715
+     *  Sets SMTP authentication. Utilizes the Username and Password variables.
1716
+     *  @var bool
1717
+     */
1718
+    var $SMTPAuth     = false;
1719
+
1720
+    /**
1721
+     *  Sets SMTP username.
1722
+     *  @var string
1723
+     */
1724
+    var $Username     = "";
1725
+
1726
+    /**
1727
+     *  Sets SMTP password.
1728
+     *  @var string
1729
+     */
1730
+    var $Password     = "";
1731
+
1732
+    /**
1733
+     *  Sets the SMTP server timeout in seconds. This function will not 
1734
+     *  work with the win32 version.
1735
+     *  @var int
1736
+     */
1737
+    var $Timeout      = 10;
1738
+
1739
+    /**
1740
+     *  Sets SMTP class debugging on or off.
1741
+     *  @var bool
1742
+     */
1743
+    var $SMTPDebug    = false;
1744
+
1745
+    /**
1746
+     * Prevents the SMTP connection from being closed after each mail 
1747
+     * sending.  If this is set to true then to close the connection 
1748
+     * requires an explicit call to SmtpClose(). 
1749
+     * @var bool
1750
+     */
1751
+    var $SMTPKeepAlive = false;
1752
+
1753
+    /**#@+
1754
+     * @access private
1755
+     */
1756
+    var $smtp            = NULL;
1757
+    var $to              = array();
1758
+    var $cc              = array();
1759
+    var $bcc             = array();
1760
+    var $ReplyTo         = array();
1761
+    var $attachment      = array();
1762
+    var $CustomHeader    = array();
1763
+    var $message_type    = "";
1764
+    var $boundary        = array();
1765
+    var $language        = array();
1766
+    var $error_count     = 0;
1767
+    var $LE              = "\n";
1768
+    /**#@-*/
1769
+	
1770
+		/////////////////////////////////////////////////
1771
+   	// CONSTRUCTOR
1772
+   	/////////////////////////////////////////////////
1773
+   	/**
1774
+   	* Constructor, just set up language
1775
+   	* @param none
1776
+   	* @return void
1777
+   	*/
1778
+   	function __construct() {
1779
+		global $conf;
1780
+		global $charset;
1781
+		
1782
+		$this->CharSet = $charset;
1783
+		
1784
+   		$this->SetLanguage();
1785
+		
1786
+		$this->Mailer = $conf['app']['emailType'];
1787
+		
1788
+		if ($this->Mailer == 'smtp') {									// Set smtp variables
1789
+			$this->Host = $conf['app']['smtpHost'];
1790
+			$this->Port = $conf['app']['smtpPort'];
1791
+		}
1792
+		
1793
+		if ($this->Mailer == 'sendmail')								// Set sendmail variables
1794
+			$this->Sendmail = $conf['app']['sendmailPath']; 
1795
+		
1796
+		if ($this->Mailer == 'qmail')									// Set qmail variables
1797
+			$this->Sendmail = $conf['app']['qmailPath'];
1798
+   	}
1799
+    
1800
+    /////////////////////////////////////////////////
1801
+    // VARIABLE METHODS
1802
+    /////////////////////////////////////////////////
1803
+
1804
+    /**
1805
+     * Sets message type to HTML.  
1806
+     * @param bool $bool
1807
+     * @return void
1808
+     */
1809
+    function IsHTML($bool) {
1810
+        if($bool == true)
1811
+            $this->ContentType = "text/html";
1812
+        else
1813
+            $this->ContentType = "text/plain";
1814
+    }
1815
+
1816
+    /**
1817
+     * Sets Mailer to send message using SMTP.
1818
+     * @return void
1819
+     */
1820
+    function IsSMTP() {
1821
+        $this->Mailer = "smtp";
1822
+    }
1823
+
1824
+    /**
1825
+     * Sets Mailer to send message using PHP mail() function.
1826
+     * @return void
1827
+     */
1828
+    function IsMail() {
1829
+        $this->Mailer = "mail";
1830
+    }
1831
+
1832
+    /**
1833
+     * Sets Mailer to send message using the $Sendmail program.
1834
+     * @return void
1835
+     */
1836
+    function IsSendmail() {
1837
+        $this->Mailer = "sendmail";
1838
+    }
1839
+
1840
+    /**
1841
+     * Sets Mailer to send message using the qmail MTA. 
1842
+     * @return void
1843
+     */
1844
+    function IsQmail() {
1845
+        $this->Sendmail = "/var/qmail/bin/sendmail";
1846
+        $this->Mailer = "sendmail";
1847
+    }
1848
+
1849
+
1850
+    /////////////////////////////////////////////////
1851
+    // RECIPIENT METHODS
1852
+    /////////////////////////////////////////////////
1853
+
1854
+    /**
1855
+     * Adds a "To" address.  
1856
+     * @param string $address
1857
+     * @param string $name
1858
+     * @return void
1859
+     */
1860
+    function AddAddress($address, $name = "") {
1861
+        $cur = count($this->to);
1862
+        $this->to[$cur][0] = trim($address);
1863
+        $this->to[$cur][1] = $name;
1864
+    }
1865
+
1866
+    /**
1867
+     * Adds a "Cc" address. Note: this function works
1868
+     * with the SMTP mailer on win32, not with the "mail"
1869
+     * mailer.  
1870
+     * @param string $address
1871
+     * @param string $name
1872
+     * @return void
1873
+    */
1874
+    function AddCC($address, $name = "") {
1875
+        $cur = count($this->cc);
1876
+        $this->cc[$cur][0] = trim($address);
1877
+        $this->cc[$cur][1] = $name;
1878
+    }
1879
+
1880
+    /**
1881
+     * Adds a "Bcc" address. Note: this function works
1882
+     * with the SMTP mailer on win32, not with the "mail"
1883
+     * mailer.  
1884
+     * @param string $address
1885
+     * @param string $name
1886
+     * @return void
1887
+     */
1888
+    function AddBCC($address, $name = "") {
1889
+        $cur = count($this->bcc);
1890
+        $this->bcc[$cur][0] = trim($address);
1891
+        $this->bcc[$cur][1] = $name;
1892
+    }
1893
+
1894
+    /**
1895
+     * Adds a "Reply-to" address.  
1896
+     * @param string $address
1897
+     * @param string $name
1898
+     * @return void
1899
+     */
1900
+    function AddReplyTo($address, $name = "") {
1901
+        $cur = count($this->ReplyTo);
1902
+        $this->ReplyTo[$cur][0] = trim($address);
1903
+        $this->ReplyTo[$cur][1] = $name;
1904
+    }
1905
+
1906
+
1907
+    /////////////////////////////////////////////////
1908
+    // MAIL SENDING METHODS
1909
+    /////////////////////////////////////////////////
1910
+
1911
+    /**
1912
+     * Creates message and assigns Mailer. If the message is
1913
+     * not sent successfully then it returns false.  Use the ErrorInfo
1914
+     * variable to view description of the error.  
1915
+     * @return bool
1916
+     */
1917
+    function Send() {
1918
+		$header = "";
1919
+        $body = "";
1920
+        $result = true;
1921
+
1922
+        if((count($this->to) + count($this->cc) + count($this->bcc)) < 1)
1923
+        {
1924
+            $this->SetError($this->Lang("provide_address"));
1925
+            return false;
1926
+        }
1927
+
1928
+        // Set whether the message is multipart/alternative
1929
+        if(!empty($this->AltBody))
1930
+            $this->ContentType = "multipart/alternative";
1931
+
1932
+        $this->error_count = 0; // reset errors
1933
+        $this->SetMessageType();
1934
+        $header .= $this->CreateHeader();
1935
+        $body = $this->CreateBody();
1936
+
1937
+		// Nick Korbel - 08-21-2005
1938
+		if (version_compare('4.3.0',phpversion(), '<=') == 1) {
1939
+			$this->Subject = html_entity_decode($this->Subject, ENT_COMPAT, $this->CharSet);
1940
+			if ($this->ContentType != "text/html")
1941
+				$body = html_entity_decode($body, ENT_COMPAT, $this->CharSet);
1942
+		}
1943
+
1944
+        if($body == "") { return false; }
1945
+
1946
+        // Choose the mailer
1947
+        switch($this->Mailer)
1948
+        {
1949
+            case "sendmail":
1950
+                $result = $this->SendmailSend($header, $body);
1951
+                break;
1952
+            case "mail":
1953
+                $result = $this->MailSend($header, $body);
1954
+                break;
1955
+            case "smtp":
1956
+                $result = $this->SmtpSend($header, $body);
1957
+                break;
1958
+            default:
1959
+            $this->SetError($this->Mailer . $this->Lang("mailer_not_supported"));
1960
+                $result = false;
1961
+                break;
1962
+        }
1963
+
1964
+        return $result;
1965
+    }
1966
+    
1967
+    /**
1968
+     * Sends mail using the $Sendmail program.  
1969
+     * @access private
1970
+     * @return bool
1971
+     */
1972
+    function SendmailSend($header, $body) {
1973
+        if ($this->Sender != "")
1974
+            $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender);
1975
+        else
1976
+            $sendmail = sprintf("%s -oi -t", $this->Sendmail);
1977
+
1978
+        if(!@$mail = popen($sendmail, "w"))
1979
+        {
1980
+            $this->SetError($this->Lang("execute") . $this->Sendmail);
1981
+            return false;
1982
+        }
1983
+
1984
+        fputs($mail, $header);
1985
+        fputs($mail, $body);
1986
+        
1987
+        $result = pclose($mail) >> 8 & 0xFF;
1988
+        if($result != 0)
1989
+        {
1990
+            $this->SetError($this->Lang("execute") . $this->Sendmail);
1991
+            return false;
1992
+        }
1993
+
1994
+        return true;
1995
+    }
1996
+
1997
+    /**
1998
+     * Sends mail using the PHP mail() function.  
1999
+     * @access private
2000
+     * @return bool
2001
+     */
2002
+    function MailSend($header, $body) {
2003
+        $to = "";
2004
+        for($i = 0; $i < count($this->to); $i++)
2005
+        {
2006
+            if($i != 0) { $to .= ", "; }
2007
+            $to .= $this->to[$i][0];
2008
+        }
2009
+
2010
+        if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1)
2011
+        {
2012
+            $old_from = ini_get("sendmail_from");
2013
+            ini_set("sendmail_from", $this->Sender);
2014
+            $params = sprintf("-oi -f %s", $this->Sender);
2015
+            $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, 
2016
+                        $header, $params);
2017
+        }
2018
+        else
2019
+            $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);
2020
+
2021
+        if (isset($old_from))
2022
+            ini_set("sendmail_from", $old_from);
2023
+
2024
+        if(!$rt)
2025
+        {
2026
+            $this->SetError($this->Lang("instantiate"));
2027
+            return false;
2028
+        }
2029
+
2030
+        return true;
2031
+    }
2032
+
2033
+    /**
2034
+     * Sends mail via SMTP using PhpSMTP (Author:
2035
+     * Chris Ryan).  Returns bool.  Returns false if there is a
2036
+     * bad MAIL FROM, RCPT, or DATA input.
2037
+     * @access private
2038
+     * @return bool
2039
+     */
2040
+    function SmtpSend($header, $body) {
2041
+        include_once($this->PluginDir . "Smtp.class.php");
2042
+        $error = "";
2043
+        $bad_rcpt = array();
2044
+
2045
+        if(!$this->SmtpConnect())
2046
+            return false;
2047
+
2048
+        $smtp_from = ($this->Sender == "") ? $this->From : $this->Sender;
2049
+        if(!$this->smtp->Mail($smtp_from))
2050
+        {
2051
+            $error = $this->Lang("from_failed") . $smtp_from;
2052
+            $this->SetError($error);
2053
+            $this->smtp->Reset();
2054
+            return false;
2055
+        }
2056
+
2057
+        // Attempt to send attach all recipients
2058
+        for($i = 0; $i < count($this->to); $i++)
2059
+        {
2060
+            if(!$this->smtp->Recipient($this->to[$i][0]))
2061
+                $bad_rcpt[] = $this->to[$i][0];
2062
+        }
2063
+        for($i = 0; $i < count($this->cc); $i++)
2064
+        {
2065
+            if(!$this->smtp->Recipient($this->cc[$i][0]))
2066
+                $bad_rcpt[] = $this->cc[$i][0];
2067
+        }
2068
+        for($i = 0; $i < count($this->bcc); $i++)
2069
+        {
2070
+            if(!$this->smtp->Recipient($this->bcc[$i][0]))
2071
+                $bad_rcpt[] = $this->bcc[$i][0];
2072
+        }
2073
+
2074
+        if(count($bad_rcpt) > 0) // Create error message
2075
+        {
2076
+            for($i = 0; $i < count($bad_rcpt); $i++)
2077
+            {
2078
+                if($i != 0) { $error .= ", "; }
2079
+                $error .= $bad_rcpt[$i];
2080
+            }
2081
+            $error = $this->Lang("recipients_failed") . $error;
2082
+            $this->SetError($error);
2083
+            $this->smtp->Reset();
2084
+            return false;
2085
+        }
2086
+
2087
+        if(!$this->smtp->Data($header . $body))
2088
+        {
2089
+            $this->SetError($this->Lang("data_not_accepted"));
2090
+            $this->smtp->Reset();
2091
+            return false;
2092
+        }
2093
+        if($this->SMTPKeepAlive == true)
2094
+            $this->smtp->Reset();
2095
+        else
2096
+            $this->SmtpClose();
2097
+
2098
+        return true;
2099
+    }
2100
+
2101
+    /**
2102
+     * Initiates a connection to an SMTP server.  Returns false if the 
2103
+     * operation failed.
2104
+     * @access private
2105
+     * @return bool
2106
+     */
2107
+    function SmtpConnect() {
2108
+        if($this->smtp == NULL) { $this->smtp = new SMTP(); }
2109
+
2110
+        $this->smtp->do_debug = $this->SMTPDebug;
2111
+        $hosts = explode(";", $this->Host);
2112
+        $index = 0;
2113
+        $connection = ($this->smtp->Connected()); 
2114
+
2115
+        // Retry while there is no connection
2116
+        while($index < count($hosts) && $connection == false)
2117
+        {
2118
+            if(strstr($hosts[$index], ":"))
2119
+                list($host, $port) = explode(":", $hosts[$index]);
2120
+            else
2121
+            {
2122
+                $host = $hosts[$index];
2123
+                $port = $this->Port;
2124
+            }
2125
+
2126
+            if($this->smtp->Connect($host, $port, $this->Timeout))
2127
+            {
2128
+                if ($this->Helo != '')
2129
+                    $this->smtp->Hello($this->Helo);
2130
+                else
2131
+                    $this->smtp->Hello($this->ServerHostname());
2132
+        
2133
+                if($this->SMTPAuth)
2134
+                {
2135
+                    if(!$this->smtp->Authenticate($this->Username, 
2136
+                                                  $this->Password))
2137
+                    {
2138
+                        $this->SetError($this->Lang("authenticate"));
2139
+                        $this->smtp->Reset();
2140
+                        $connection = false;
2141
+                    }
2142
+                }
2143
+                $connection = true;
2144
+            }
2145
+            $index++;
2146
+        }
2147
+        if(!$connection)
2148
+            $this->SetError($this->Lang("connect_host"));
2149
+
2150
+        return $connection;
2151
+    }
2152
+
2153
+    /**
2154
+     * Closes the active SMTP session if one exists.
2155
+     * @return void
2156
+     */
2157
+    function SmtpClose() {
2158
+        if($this->smtp != NULL)
2159
+        {
2160
+            if($this->smtp->Connected())
2161
+            {
2162
+                $this->smtp->Quit();
2163
+                $this->smtp->Close();
2164
+            }
2165
+        }
2166
+    }
2167
+
2168
+    /**
2169
+     * Sets the language for all class error messages. Always in English.
2170
+     * @param none
2171
+     * @access public
2172
+     * @return bool
2173
+     */
2174
+    function SetLanguage() {
2175
+        /**
2176
+    	* Only printing errors in english
2177
+    	*/
2178
+    	$PHPMAILER_LANG = array();
2179
+
2180
+		$PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' .
2181
+		                                     'recipient email address.';
2182
+		$PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.';
2183
+		$PHPMAILER_LANG["execute"] = 'Could not execute: ';
2184
+		$PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.';
2185
+		$PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.';
2186
+		$PHPMAILER_LANG["from_failed"] = 'The following From address failed: ';
2187
+		$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' .
2188
+		                                       'recipients failed: ';
2189
+		$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.';
2190
+		$PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.';
2191
+		$PHPMAILER_LANG["file_access"] = 'Could not access file: ';
2192
+		$PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: ';
2193
+		$PHPMAILER_LANG["encoding"] = 'Unknown encoding: ';
2194
+
2195
+        $this->language = $PHPMAILER_LANG;
2196
+
2197
+        return true;
2198
+    }
2199
+
2200
+    /////////////////////////////////////////////////
2201
+    // MESSAGE CREATION METHODS
2202
+    /////////////////////////////////////////////////
2203
+
2204
+    /**
2205
+     * Creates recipient headers.  
2206
+     * @access private
2207
+     * @return string
2208
+     */
2209
+    function AddrAppend($type, $addr) {
2210
+        $addr_str = $type . ": ";
2211
+        $addr_str .= $this->AddrFormat($addr[0]);
2212
+        if(count($addr) > 1)
2213
+        {
2214
+            for($i = 1; $i < count($addr); $i++)
2215
+                $addr_str .= ", " . $this->AddrFormat($addr[$i]);
2216
+        }
2217
+        $addr_str .= $this->LE;
2218
+
2219
+        return $addr_str;
2220
+    }
2221
+    
2222
+    /**
2223
+     * Formats an address correctly. 
2224
+     * @access private
2225
+     * @return string
2226
+     */
2227
+    function AddrFormat($addr) {
2228
+        if(empty($addr[1]))
2229
+            $formatted = $addr[0];
2230
+        else
2231
+        {
2232
+            $formatted = $this->EncodeHeader($addr[1], 'phrase') . " <" . 
2233
+                         $addr[0] . ">";
2234
+        }
2235
+
2236
+        return $formatted;
2237
+    }
2238
+
2239
+    /**
2240
+     * Wraps message for use with mailers that do not
2241
+     * automatically perform wrapping and for quoted-printable.
2242
+     * Original written by philippe.  
2243
+     * @access private
2244
+     * @return string
2245
+     */
2246
+    function WrapText($message, $length, $qp_mode = false) {
2247
+        $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
2248
+
2249
+        $message = $this->FixEOL($message);
2250
+        if (substr($message, -1) == $this->LE)
2251
+            $message = substr($message, 0, -1);
2252
+
2253
+        $line = explode($this->LE, $message);
2254
+        $message = "";
2255
+        for ($i=0 ;$i < count($line); $i++)
2256
+        {
2257
+          $line_part = explode(" ", $line[$i]);
2258
+          $buf = "";
2259
+          for ($e = 0; $e<count($line_part); $e++)
2260
+          {
2261
+              $word = $line_part[$e];
2262
+              if ($qp_mode and (strlen($word) > $length))
2263
+              {
2264
+                $space_left = $length - strlen($buf) - 1;
2265
+                if ($e != 0)
2266
+                {
2267
+                    if ($space_left > 20)
2268
+                    {
2269
+                        $len = $space_left;
2270
+                        if (substr($word, $len - 1, 1) == "=")
2271
+                          $len--;
2272
+                        elseif (substr($word, $len - 2, 1) == "=")
2273
+                          $len -= 2;
2274
+                        $part = substr($word, 0, $len);
2275
+                        $word = substr($word, $len);
2276
+                        $buf .= " " . $part;
2277
+                        $message .= $buf . sprintf("=%s", $this->LE);
2278
+                    }
2279
+                    else
2280
+                    {
2281
+                        $message .= $buf . $soft_break;
2282
+                    }
2283
+                    $buf = "";
2284
+                }
2285
+                while (strlen($word) > 0)
2286
+                {
2287
+                    $len = $length;
2288
+                    if (substr($word, $len - 1, 1) == "=")
2289
+                        $len--;
2290
+                    elseif (substr($word, $len - 2, 1) == "=")
2291
+                        $len -= 2;
2292
+                    $part = substr($word, 0, $len);
2293
+                    $word = substr($word, $len);
2294
+
2295
+                    if (strlen($word) > 0)
2296
+                        $message .= $part . sprintf("=%s", $this->LE);
2297
+                    else
2298
+                        $buf = $part;
2299
+                }
2300
+              }
2301
+              else
2302
+              {
2303
+                $buf_o = $buf;
2304
+                $buf .= ($e == 0) ? $word : (" " . $word); 
2305
+
2306
+                if (strlen($buf) > $length and $buf_o != "")
2307
+                {
2308
+                    $message .= $buf_o . $soft_break;
2309
+                    $buf = $word;
2310
+                }
2311
+              }
2312
+          }
2313
+          $message .= $buf . $this->LE;
2314
+        }
2315
+
2316
+        return $message;
2317
+    }
2318
+    
2319
+    /**
2320
+     * Set the body wrapping.
2321
+     * @access private
2322
+     * @return void
2323
+     */
2324
+    function SetWordWrap() {
2325
+        if($this->WordWrap < 1)
2326
+            return;
2327
+            
2328
+        switch($this->message_type)
2329
+        {
2330
+           case "alt":
2331
+              // fall through
2332
+           case "alt_attachment":
2333
+              $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
2334
+              break;
2335
+           default:
2336
+              $this->Body = $this->WrapText($this->Body, $this->WordWrap);
2337
+              break;
2338
+        }
2339
+    }
2340
+
2341
+    /**
2342
+     * Assembles message header.  
2343
+     * @access private
2344
+     * @return string
2345
+     */
2346
+    function CreateHeader() {
2347
+        $result = "";
2348
+        
2349
+        // Set the boundaries
2350
+        $uniq_id = md5(uniqid(time()));
2351
+        $this->boundary[1] = "b1_" . $uniq_id;
2352
+        $this->boundary[2] = "b2_" . $uniq_id;
2353
+
2354
+        $result .= $this->HeaderLine("Date", $this->RFCDate());
2355
+        if($this->Sender == "")
2356
+            $result .= $this->HeaderLine("Return-Path", trim($this->From));
2357
+        else
2358
+            $result .= $this->HeaderLine("Return-Path", trim($this->Sender));
2359
+        
2360
+        // To be created automatically by mail()
2361
+        if($this->Mailer != "mail")
2362
+        {
2363
+            if(count($this->to) > 0)
2364
+                $result .= $this->AddrAppend("To", $this->to);
2365
+            else if (count($this->cc) == 0)
2366
+                $result .= $this->HeaderLine("To", "undisclosed-recipients:;");
2367
+            if(count($this->cc) > 0)
2368
+                $result .= $this->AddrAppend("Cc", $this->cc);
2369
+        }
2370
+
2371
+        $from = array();
2372
+        $from[0][0] = trim($this->From);
2373
+        $from[0][1] = $this->FromName;
2374
+        $result .= $this->AddrAppend("From", $from); 
2375
+
2376
+        // sendmail and mail() extract Bcc from the header before sending
2377
+        if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
2378
+            $result .= $this->AddrAppend("Bcc", $this->bcc);
2379
+
2380
+        if(count($this->ReplyTo) > 0)
2381
+            $result .= $this->AddrAppend("Reply-to", $this->ReplyTo);
2382
+
2383
+        // mail() sets the subject itself
2384
+        if($this->Mailer != "mail")
2385
+            $result .= $this->HeaderLine("Subject", $this->EncodeHeader(trim($this->Subject)));
2386
+
2387
+        $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
2388
+        $result .= $this->HeaderLine("X-Priority", $this->Priority);
2389
+        $result .= $this->HeaderLine("X-Mailer", "PHPMailer [version " . $this->Version . "]");
2390
+        
2391
+        if($this->ConfirmReadingTo != "")
2392
+        {
2393
+            $result .= $this->HeaderLine("Disposition-Notification-To", 
2394
+                       "<" . trim($this->ConfirmReadingTo) . ">");
2395
+        }
2396
+
2397
+        // Add custom headers
2398
+        for($index = 0; $index < count($this->CustomHeader); $index++)
2399
+        {
2400
+            $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), 
2401
+                       $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
2402
+        }
2403
+        $result .= $this->HeaderLine("MIME-Version", "1.0");
2404
+
2405
+        switch($this->message_type)
2406
+        {
2407
+            case "plain":
2408
+                $result .= $this->HeaderLine("Content-Transfer-Encoding", $this->Encoding);
2409
+                $result .= sprintf("Content-Type: %s; charset=\"%s\"",
2410
+                                    $this->ContentType, $this->CharSet);
2411
+                break;
2412
+            case "attachments":
2413
+                // fall through
2414
+            case "alt_attachments":
2415
+                if($this->InlineImageExists())
2416
+                {
2417
+                    $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 
2418
+                                    "multipart/related", $this->LE, $this->LE, 
2419
+                                    $this->boundary[1], $this->LE);
2420
+                }
2421
+                else
2422
+                {
2423
+                    $result .= $this->HeaderLine("Content-Type", "multipart/mixed;");
2424
+                    $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
2425
+                }
2426
+                break;
2427
+            case "alt":
2428
+                $result .= $this->HeaderLine("Content-Type", "multipart/alternative;");
2429
+                $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
2430
+                break;
2431
+        }
2432
+
2433
+        if($this->Mailer != "mail")
2434
+            $result .= $this->LE.$this->LE;
2435
+
2436
+        return $result;
2437
+    }
2438
+
2439
+    /**
2440
+     * Assembles the message body.  Returns an empty string on failure.
2441
+     * @access private
2442
+     * @return string
2443
+     */
2444
+    function CreateBody() {
2445
+        $result = "";
2446
+
2447
+        $this->SetWordWrap();
2448
+
2449
+        switch($this->message_type)
2450
+        {
2451
+            case "alt":
2452
+                $result .= $this->GetBoundary($this->boundary[1], "", 
2453
+                                              "text/plain", "");
2454
+                $result .= $this->EncodeString($this->AltBody, $this->Encoding);
2455
+                $result .= $this->LE.$this->LE;
2456
+                $result .= $this->GetBoundary($this->boundary[1], "", 
2457
+                                              "text/html", "");
2458
+                
2459
+                $result .= $this->EncodeString($this->Body, $this->Encoding);
2460
+                $result .= $this->LE.$this->LE;
2461
+    
2462
+                $result .= $this->EndBoundary($this->boundary[1]);
2463
+                break;
2464
+            case "plain":
2465
+                $result .= $this->EncodeString($this->Body, $this->Encoding);
2466
+                break;
2467
+            case "attachments":
2468
+                $result .= $this->GetBoundary($this->boundary[1], "", "", "");
2469
+                $result .= $this->EncodeString($this->Body, $this->Encoding);
2470
+                $result .= $this->LE;
2471
+     
2472
+                $result .= $this->AttachAll();
2473
+                break;
2474
+            case "alt_attachments":
2475
+                $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
2476
+                $result .= sprintf("Content-Type: %s;%s" .
2477
+                                   "\tboundary=\"%s\"%s",
2478
+                                   "multipart/alternative", $this->LE, 
2479
+                                   $this->boundary[2], $this->LE.$this->LE);
2480
+    
2481
+                // Create text body
2482
+                $result .= $this->GetBoundary($this->boundary[2], "", 
2483
+                                              "text/plain", "") . $this->LE;
2484
+
2485
+                $result .= $this->EncodeString($this->AltBody, $this->Encoding);
2486
+                $result .= $this->LE.$this->LE;
2487
+    
2488
+                // Create the HTML body
2489
+                $result .= $this->GetBoundary($this->boundary[2], "", 
2490
+                                              "text/html", "") . $this->LE;
2491
+    
2492
+                $result .= $this->EncodeString($this->Body, $this->Encoding);
2493
+                $result .= $this->LE.$this->LE;
2494
+
2495
+                $result .= $this->EndBoundary($this->boundary[2]);
2496
+                
2497
+                $result .= $this->AttachAll();
2498
+                break;
2499
+        }
2500
+        if($this->IsError())
2501
+            $result = "";
2502
+
2503
+        return $result;
2504
+    }
2505
+
2506
+    /**
2507
+     * Returns the start of a message boundary.
2508
+     * @access private
2509
+     */
2510
+    function GetBoundary($boundary, $charSet, $contentType, $encoding) {
2511
+        $result = "";
2512
+        if($charSet == "") { $charSet = $this->CharSet; }
2513
+        if($contentType == "") { $contentType = $this->ContentType; }
2514
+        if($encoding == "") { $encoding = $this->Encoding; }
2515
+
2516
+        $result .= $this->TextLine("--" . $boundary);
2517
+        $result .= sprintf("Content-Type: %s; charset = \"%s\"", 
2518
+                            $contentType, $charSet);
2519
+        $result .= $this->LE;
2520
+        $result .= $this->HeaderLine("Content-Transfer-Encoding", $encoding);
2521
+        $result .= $this->LE;
2522
+       
2523
+        return $result;
2524
+    }
2525
+    
2526
+    /**
2527
+     * Returns the end of a message boundary.
2528
+     * @access private
2529
+     */
2530
+    function EndBoundary($boundary) {
2531
+        return $this->LE . "--" . $boundary . "--" . $this->LE; 
2532
+    }
2533
+    
2534
+    /**
2535
+     * Sets the message type.
2536
+     * @access private
2537
+     * @return void
2538
+     */
2539
+    function SetMessageType() {
2540
+        if(count($this->attachment) < 1 && strlen($this->AltBody) < 1)
2541
+            $this->message_type = "plain";
2542
+        else
2543
+        {
2544
+            if(count($this->attachment) > 0)
2545
+                $this->message_type = "attachments";
2546
+            if(strlen($this->AltBody) > 0 && count($this->attachment) < 1)
2547
+                $this->message_type = "alt";
2548
+            if(strlen($this->AltBody) > 0 && count($this->attachment) > 0)
2549
+                $this->message_type = "alt_attachments";
2550
+        }
2551
+    }
2552
+
2553
+    /**
2554
+     * Returns a formatted header line.
2555
+     * @access private
2556
+     * @return string
2557
+     */
2558
+    function HeaderLine($name, $value) {
2559
+        return $name . ": " . $value . $this->LE;
2560
+    }
2561
+
2562
+    /**
2563
+     * Returns a formatted mail line.
2564
+     * @access private
2565
+     * @return string
2566
+     */
2567
+    function TextLine($value) {
2568
+        return $value . $this->LE;
2569
+    }
2570
+
2571
+    /////////////////////////////////////////////////
2572
+    // ATTACHMENT METHODS
2573
+    /////////////////////////////////////////////////
2574
+
2575
+    /**
2576
+     * Adds an attachment from a path on the filesystem.
2577
+     * Returns false if the file could not be found
2578
+     * or accessed.
2579
+     * @param string $path Path to the attachment.
2580
+     * @param string $name Overrides the attachment name.
2581
+     * @param string $encoding File encoding (see $Encoding).
2582
+     * @param string $type File extension (MIME) type.
2583
+     * @return bool
2584
+     */
2585
+    function AddAttachment($path, $name = "", $encoding = "base64", 
2586
+                           $type = "application/octet-stream") {
2587
+        if(!@is_file($path))
2588
+        {
2589
+            $this->SetError($this->Lang("file_access") . $path);
2590
+            return false;
2591
+        }
2592
+
2593
+        $filename = basename($path);
2594
+        if($name == "")
2595
+            $name = $filename;
2596
+
2597
+        $cur = count($this->attachment);
2598
+        $this->attachment[$cur][0] = $path;
2599
+        $this->attachment[$cur][1] = $filename;
2600
+        $this->attachment[$cur][2] = $name;
2601
+        $this->attachment[$cur][3] = $encoding;
2602
+        $this->attachment[$cur][4] = $type;
2603
+        $this->attachment[$cur][5] = false; // isStringAttachment
2604
+        $this->attachment[$cur][6] = "attachment";
2605
+        $this->attachment[$cur][7] = 0;
2606
+
2607
+        return true;
2608
+    }
2609
+
2610
+    /**
2611
+     * Attaches all fs, string, and binary attachments to the message.
2612
+     * Returns an empty string on failure.
2613
+     * @access private
2614
+     * @return string
2615
+     */
2616
+    function AttachAll() {
2617
+        // Return text of body
2618
+        $mime = array();
2619
+
2620
+        // Add all attachments
2621
+        for($i = 0; $i < count($this->attachment); $i++)
2622
+        {
2623
+            // Check for string attachment
2624
+            $bString = $this->attachment[$i][5];
2625
+            if ($bString)
2626
+                $string = $this->attachment[$i][0];
2627
+            else
2628
+                $path = $this->attachment[$i][0];
2629
+
2630
+            $filename    = $this->attachment[$i][1];
2631
+            $name        = $this->attachment[$i][2];
2632
+            $encoding    = $this->attachment[$i][3];
2633
+            $type        = $this->attachment[$i][4];
2634
+            $disposition = $this->attachment[$i][6];
2635
+            $cid         = $this->attachment[$i][7];
2636
+            
2637
+            $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
2638
+            $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
2639
+            $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
2640
+
2641
+            if($disposition == "inline")
2642
+                $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
2643
+
2644
+            $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", 
2645
+                              $disposition, $name, $this->LE.$this->LE);
2646
+
2647
+            // Encode as string attachment
2648
+            if($bString)
2649
+            {
2650
+                $mime[] = $this->EncodeString($string, $encoding);
2651
+                if($this->IsError()) { return ""; }
2652
+                $mime[] = $this->LE.$this->LE;
2653
+            }
2654
+            else
2655
+            {
2656
+                $mime[] = $this->EncodeFile($path, $encoding);                
2657
+                if($this->IsError()) { return ""; }
2658
+                $mime[] = $this->LE.$this->LE;
2659
+            }
2660
+        }
2661
+
2662
+        $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
2663
+
2664
+        return join("", $mime);
2665
+    }
2666
+    
2667
+    /**
2668
+     * Encodes attachment in requested format.  Returns an
2669
+     * empty string on failure.
2670
+     * @access private
2671
+     * @return string
2672
+     */
2673
+    function EncodeFile ($path, $encoding = "base64") {
2674
+        if(!@$fd = fopen($path, "rb"))
2675
+        {
2676
+            $this->SetError($this->Lang("file_open") . $path);
2677
+            return "";
2678
+        }
2679
+        $file_buffer = fread($fd, filesize($path));
2680
+        $file_buffer = $this->EncodeString($file_buffer, $encoding);
2681
+        fclose($fd);
2682
+
2683
+        return $file_buffer;
2684
+    }
2685
+
2686
+    /**
2687
+     * Encodes string to requested format. Returns an
2688
+     * empty string on failure.
2689
+     * @access private
2690
+     * @return string
2691
+     */
2692
+    function EncodeString ($str, $encoding = "base64") {
2693
+        $encoded = "";
2694
+        switch(strtolower($encoding)) {
2695
+          case "base64":
2696
+              // chunk_split is found in PHP >= 3.0.6
2697
+              $encoded = chunk_split(base64_encode($str), 76, $this->LE);
2698
+              break;
2699
+          case "7bit":
2700
+          case "8bit":
2701
+              $encoded = $this->FixEOL($str);
2702
+              if (substr($encoded, -(strlen($this->LE))) != $this->LE)
2703
+                $encoded .= $this->LE;
2704
+              break;
2705
+          case "binary":
2706
+              $encoded = $str;
2707
+              break;
2708
+          case "quoted-printable":
2709
+              $encoded = $this->EncodeQP($str);
2710
+              break;
2711
+          default:
2712
+              $this->SetError($this->Lang("encoding") . $encoding);
2713
+              break;
2714
+        }
2715
+        return $encoded;
2716
+    }
2717
+
2718
+    /**
2719
+     * Encode a header string to best of Q, B, quoted or none.  
2720
+     * @access private
2721
+     * @return string
2722
+     */
2723
+    function EncodeHeader ($str, $position = 'text') {
2724
+      $x = 0;
2725
+      
2726
+      switch (strtolower($position)) {
2727
+        case 'phrase':
2728
+          if (!preg_match('/[\200-\377]/', $str)) {
2729
+            // Can't use addslashes as we don't know what value has magic_quotes_sybase.
2730
+            $encoded = addcslashes($str, "\0..\37\177\\\"");
2731
+
2732
+            if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str))
2733
+              return ($encoded);
2734
+            else
2735
+              return ("\"$encoded\"");
2736
+          }
2737
+          $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
2738
+          break;
2739
+        case 'comment':
2740
+          $x = preg_match_all('/[()"]/', $str, $matches);
2741
+          // Fall-through
2742
+        case 'text':
2743
+        default:
2744
+          $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
2745
+          break;
2746
+      }
2747
+
2748
+      if ($x == 0)
2749
+        return ($str);
2750
+
2751
+      $maxlen = 75 - 7 - strlen($this->CharSet);
2752
+      // Try to select the encoding which should produce the shortest output
2753
+      if (strlen($str)/3 < $x) {
2754
+        $encoding = 'B';
2755
+        $encoded = base64_encode($str);
2756
+        $maxlen -= $maxlen % 4;
2757
+        $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
2758
+      } else {
2759
+        $encoding = 'Q';
2760
+        $encoded = $this->EncodeQ($str, $position);
2761
+        $encoded = $this->WrapText($encoded, $maxlen, true);
2762
+        $encoded = str_replace("=".$this->LE, "\n", trim($encoded));
2763
+      }
2764
+
2765
+      $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
2766
+      $encoded = trim(str_replace("\n", $this->LE, $encoded));
2767
+      
2768
+      return $encoded;
2769
+    }
2770
+    
2771
+    /**
2772
+     * Encode string to quoted-printable.  
2773
+     * @access private
2774
+     * @return string
2775
+     */
2776
+    function EncodeQP ($str) {
2777
+        $encoded = $this->FixEOL($str);
2778
+        if (substr($encoded, -(strlen($this->LE))) != $this->LE)
2779
+            $encoded .= $this->LE;
2780
+
2781
+        // Replace every high ascii, control and = characters
2782
+        $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',
2783
+                  "'='.sprintf('%02X', ord('\\1'))", $encoded);
2784
+        // Replace every spaces and tabs when it's the last character on a line
2785
+        $encoded = preg_replace("/([\011\040])".$this->LE."/e",
2786
+                  "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);
2787
+
2788
+        // Maximum line length of 76 characters before CRLF (74 + space + '=')
2789
+        $encoded = $this->WrapText($encoded, 74, true);
2790
+
2791
+        return $encoded;
2792
+    }
2793
+
2794
+    /**
2795
+     * Encode string to q encoding.  
2796
+     * @access private
2797
+     * @return string
2798
+     */
2799
+    function EncodeQ ($str, $position = "text") {
2800
+        // There should not be any EOL in the string
2801
+        $encoded = preg_replace("[\r\n]", "", $str);
2802
+
2803
+        switch (strtolower($position)) {
2804
+          case "phrase":
2805
+            $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
2806
+            break;
2807
+          case "comment":
2808
+            $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
2809
+          case "text":
2810
+          default:
2811
+            // Replace every high ascii, control =, ? and _ characters
2812
+            $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
2813
+                  "'='.sprintf('%02X', ord('\\1'))", $encoded);
2814
+            break;
2815
+        }
2816
+        
2817
+        // Replace every spaces to _ (more readable than =20)
2818
+        $encoded = str_replace(" ", "_", $encoded);
2819
+
2820
+        return $encoded;
2821
+    }
2822
+
2823
+    /**
2824
+     * Adds a string or binary attachment (non-filesystem) to the list.
2825
+     * This method can be used to attach ascii or binary data,
2826
+     * such as a BLOB record from a database.
2827
+     * @param string $string String attachment data.
2828
+     * @param string $filename Name of the attachment.
2829
+     * @param string $encoding File encoding (see $Encoding).
2830
+     * @param string $type File extension (MIME) type.
2831
+     * @return void
2832
+     */
2833
+    function AddStringAttachment($string, $filename, $encoding = "base64", 
2834
+                                 $type = "application/octet-stream") {
2835
+        // Append to $attachment array
2836
+        $cur = count($this->attachment);
2837
+        $this->attachment[$cur][0] = $string;
2838
+        $this->attachment[$cur][1] = $filename;
2839
+        $this->attachment[$cur][2] = $filename;
2840
+        $this->attachment[$cur][3] = $encoding;
2841
+        $this->attachment[$cur][4] = $type;
2842
+        $this->attachment[$cur][5] = true; // isString
2843
+        $this->attachment[$cur][6] = "attachment";
2844
+        $this->attachment[$cur][7] = 0;
2845
+    }
2846
+    
2847
+    /**
2848
+     * Adds an embedded attachment.  This can include images, sounds, and 
2849
+     * just about any other document.  Make sure to set the $type to an 
2850
+     * image type.  For JPEG images use "image/jpeg" and for GIF images 
2851
+     * use "image/gif".
2852
+     * @param string $path Path to the attachment.
2853
+     * @param string $cid Content ID of the attachment.  Use this to identify 
2854
+     *        the Id for accessing the image in an HTML form.
2855
+     * @param string $name Overrides the attachment name.
2856
+     * @param string $encoding File encoding (see $Encoding).
2857
+     * @param string $type File extension (MIME) type.  
2858
+     * @return bool
2859
+     */
2860
+    function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64", 
2861
+                              $type = "application/octet-stream") {
2862
+    
2863
+        if(!@is_file($path))
2864
+        {
2865
+            $this->SetError($this->Lang("file_access") . $path);
2866
+            return false;
2867
+        }
2868
+
2869
+        $filename = basename($path);
2870
+        if($name == "")
2871
+            $name = $filename;
2872
+
2873
+        // Append to $attachment array
2874
+        $cur = count($this->attachment);
2875
+        $this->attachment[$cur][0] = $path;
2876
+        $this->attachment[$cur][1] = $filename;
2877
+        $this->attachment[$cur][2] = $name;
2878
+        $this->attachment[$cur][3] = $encoding;
2879
+        $this->attachment[$cur][4] = $type;
2880
+        $this->attachment[$cur][5] = false; // isStringAttachment
2881
+        $this->attachment[$cur][6] = "inline";
2882
+        $this->attachment[$cur][7] = $cid;
2883
+    
2884
+        return true;
2885
+    }
2886
+    
2887
+    /**
2888
+     * Returns true if an inline attachment is present.
2889
+     * @access private
2890
+     * @return bool
2891
+     */
2892
+    function InlineImageExists() {
2893
+        $result = false;
2894
+        for($i = 0; $i < count($this->attachment); $i++)
2895
+        {
2896
+            if($this->attachment[$i][6] == "inline")
2897
+            {
2898
+                $result = true;
2899
+                break;
2900
+            }
2901
+        }
2902
+        
2903
+        return $result;
2904
+    }
2905
+
2906
+    /////////////////////////////////////////////////
2907
+    // MESSAGE RESET METHODS
2908
+    /////////////////////////////////////////////////
2909
+
2910
+    /**
2911
+     * Clears all recipients assigned in the TO array.  Returns void.
2912
+     * @return void
2913
+     */
2914
+    function ClearAddresses() {
2915
+        $this->to = array();
2916
+    }
2917
+
2918
+    /**
2919
+     * Clears all recipients assigned in the CC array.  Returns void.
2920
+     * @return void
2921
+     */
2922
+    function ClearCCs() {
2923
+        $this->cc = array();
2924
+    }
2925
+
2926
+    /**
2927
+     * Clears all recipients assigned in the BCC array.  Returns void.
2928
+     * @return void
2929
+     */
2930
+    function ClearBCCs() {
2931
+        $this->bcc = array();
2932
+    }
2933
+
2934
+    /**
2935
+     * Clears all recipients assigned in the ReplyTo array.  Returns void.
2936
+     * @return void
2937
+     */
2938
+    function ClearReplyTos() {
2939
+        $this->ReplyTo = array();
2940
+    }
2941
+
2942
+    /**
2943
+     * Clears all recipients assigned in the TO, CC and BCC
2944
+     * array.  Returns void.
2945
+     * @return void
2946
+     */
2947
+    function ClearAllRecipients() {
2948
+        $this->to = array();
2949
+        $this->cc = array();
2950
+        $this->bcc = array();
2951
+    }
2952
+
2953
+    /**
2954
+     * Clears all previously set filesystem, string, and binary
2955
+     * attachments.  Returns void.
2956
+     * @return void
2957
+     */
2958
+    function ClearAttachments() {
2959
+        $this->attachment = array();
2960
+    }
2961
+
2962
+    /**
2963
+     * Clears all custom headers.  Returns void.
2964
+     * @return void
2965
+     */
2966
+    function ClearCustomHeaders() {
2967
+        $this->CustomHeader = array();
2968
+    }
2969
+
2970
+
2971
+    /////////////////////////////////////////////////
2972
+    // MISCELLANEOUS METHODS
2973
+    /////////////////////////////////////////////////
2974
+
2975
+    /**
2976
+     * Adds the error message to the error container.
2977
+     * Returns void.
2978
+     * @access private
2979
+     * @return void
2980
+     */
2981
+    function SetError($msg) {
2982
+        $this->error_count++;
2983
+        $this->ErrorInfo = $msg;
2984
+    }
2985
+
2986
+    /**
2987
+     * Returns the proper RFC 822 formatted date. 
2988
+     * @access private
2989
+     * @return string
2990
+     */
2991
+    function RFCDate() {
2992
+        $tz = date("Z");
2993
+        $tzs = ($tz < 0) ? "-" : "+";
2994
+        $tz = abs($tz);
2995
+        $tz = ($tz/3600)*100 + ($tz%3600)/60;
2996
+        $result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);
2997
+
2998
+        return $result;
2999
+    }
3000
+    
3001
+    /**
3002
+     * Returns the appropriate server variable.  Should work with both 
3003
+     * PHP 4.1.0+ as well as older versions.  Returns an empty string 
3004
+     * if nothing is found.
3005
+     * @access private
3006
+     * @return mixed
3007
+     */
3008
+    function ServerVar($varName) {
3009
+        global $HTTP_SERVER_VARS;
3010
+        global $HTTP_ENV_VARS;
3011
+
3012
+        if(!isset($_SERVER))
3013
+        {
3014
+            $_SERVER = $HTTP_SERVER_VARS;
3015
+            if(!isset($_SERVER["REMOTE_ADDR"]))
3016
+                $_SERVER = $HTTP_ENV_VARS; // must be Apache
3017
+        }
3018
+        
3019
+        if(isset($_SERVER[$varName]))
3020
+            return $_SERVER[$varName];
3021
+        else
3022
+            return "";
3023
+    }
3024
+
3025
+    /**
3026
+     * Returns the server hostname or 'localhost.localdomain' if unknown.
3027
+     * @access private
3028
+     * @return string
3029
+     */
3030
+    function ServerHostname() {
3031
+        if ($this->Hostname != "")
3032
+            $result = $this->Hostname;
3033
+        elseif ($this->ServerVar('SERVER_NAME') != "")
3034
+            $result = $this->ServerVar('SERVER_NAME');
3035
+        else
3036
+            $result = "localhost.localdomain";
3037
+
3038
+        return $result;
3039
+    }
3040
+
3041
+    /**
3042
+     * Returns a message in the appropriate language.
3043
+     * @access private
3044
+     * @return string
3045
+     */
3046
+    function Lang($key) {
3047
+        if(count($this->language) < 1)
3048
+            $this->SetLanguage("en"); // set the default language
3049
+    
3050
+        if(isset($this->language[$key]))
3051
+            return $this->language[$key];
3052
+        else
3053
+            return "Language string failed to load: " . $key;
3054
+    }
3055
+    
3056
+    /**
3057
+     * Returns true if an error occurred.
3058
+     * @return bool
3059
+     */
3060
+    function IsError() {
3061
+        return ($this->error_count > 0);
3062
+    }
3063
+
3064
+    /**
3065
+     * Changes every end of line from CR or LF to CRLF.  
3066
+     * @access private
3067
+     * @return string
3068
+     */
3069
+    function FixEOL($str) {
3070
+        $str = str_replace("\r\n", "\n", $str);
3071
+        $str = str_replace("\r", "\n", $str);
3072
+        $str = str_replace("\n", $this->LE, $str);
3073
+        return $str;
3074
+    }
3075
+
3076
+    /**
3077
+     * Adds a custom header. 
3078
+     * @return void
3079
+     */
3080
+    function AddCustomHeader($custom_header) {
3081
+        $this->CustomHeader[] = explode(":", $custom_header, 2);
3082
+    }
3083
+}
3084
+
3085
+?>
(-)b/security/mailzu/files/patch-lib_Pager.class.php (+1262 lines)
Added Link Here
1
--- lib/Pager.class.php.orig	2007-06-14 19:00:15 UTC
2
+++ lib/Pager.class.php
3
@@ -1,629 +1,629 @@
4
-<?php
5
-/**
6
-* Paging class to iterate through limited recordsets
7
-* @author Nick Korbel <lqqkout13@users.sourceforge.net>
8
-* @version 02-02-05
9
-* @package Pager
10
-*
11
-* Copyright (C) 2003 - 2005 phpScheduleIt
12
-* License: GPL, see LICENSE
13
-* /
14
-/**
15
-* To actually print out page links, call printPages() function
16
-*
17
-* In order for this object to work correctly, total records
18
-*  must be set in either the constructor or by calling
19
-*  setTotRecords()
20
-*
21
-* + Warning - The printPages() function cannot be called
22
-* 			from within a form
23
-*
24
-* === EXAMPLE OF HOW TO USE PAGER ===
25
-* // Initialize new Pager object with default values
26
-* $pager = new Pager();
27
-*
28
-* // Get total # of pages
29
-* $query = "SELECT COUNT(*) as num FROM table";
30
-* $result = $db->query($query);    
31
-* $rs = $result->fetchRow();
32
-* $num = $rs['num'];              // # of records
33
-*
34
-* $pager->setTotRecords($num);
35
-* $recordset_offset = $pager->getOffset();
36
-* $limit = $pager->getLimit();
37
-*
38
-* // Execute Query (using $offset and $limit values) //
39
-*
40
-* $pager->printPages();
41
-* ==========================================
42
-*
43
-*/
44
-
45
-// Should we use the Link class?
46
-$use_link = true;
47
-
48
-if ($use_link) {
49
-	//include_once('Link.class.php');
50
-	$link = new Link();
51
-}
52
-
53
-class Pager {
54
-	// Application set variables
55
-	var $cur_page;
56
-	var $query_string;
57
-	var $tot_pages;
58
-	var $page_var;
59
-	var $limit_var;
60
-	
61
-	// Application variables with user modify option
62
-	var $limit;
63
-	var $tot_records;
64
-	var $print_limit_select = true;
65
-	
66
-	// User modifiable variables
67
-	var $prev_link = '&laquo;';
68
-	var $next_link = '&raquo;';
69
-	var $limits = array(10, 25, 50, 100);
70
-	var $view_pages = 3;
71
-	var $table_width = '100%';
72
-	var $table_align = 'center';
73
-	var $link_class;
74
-	var $tb_class;
75
-	var $tb_style;
76
-	var $text_class;
77
-	var $text_style;
78
-	
79
-		
80
-	/**
81
-	* Pager Constructor
82
-	* Sets up Pager variables and initializes values
83
-	*
84
-	* - All parameters are optional and have default values of:
85
-	*    $tot_records = 0
86
-	*    $limit = 25
87
-	*    $page_var = "page"
88
-	*    $limit_var = "limit"
89
-	*
90
-	* @param int $tot_records optional total number of records
91
-	* @param int $limit optional limit of recordset
92
-	* @param string $page_var optional name of var to use in querystring for page value
93
-	* @param string $limit_var optional name of var to use in querystring for limit value
94
-	*/
95
-	function Pager($tot_records=0, $limit=25, $page_var='page', $limit_var='limit') {
96
-		$this->tot_records = $tot_records;
97
-		$this->limit = $limit;
98
-		$this->page_var = $page_var;
99
-		$this->limit_var = $limit_var;
100
-		
101
-		// Call all system setter functions
102
-		$this->initCurPage();
103
-		$this->initLimit();
104
-		$this->initTotPages();
105
-		$this->initQueryString();
106
-	}
107
-	
108
-	
109
-	/**
110
-	* Print out the pages as links
111
-	* Prints out a table of all the pages as links
112
-	*  and a jump menu to change the number of records
113
-	*  per page
114
-	*
115
-	* setCurPage() and setTotPages() must be called
116
-	*  before this function can be called
117
-	*
118
-	* @param none
119
-	* @see printPrev()
120
-	* @see printLink()
121
-	* @see printPage()
122
-	* @see printNext()
123
-	* @see printTotal()
124
-	* @see startTable()
125
-	* @see startPagesCell()
126
-	* @see endPagesCell()
127
-	* @see printLimitCell()
128
-	* @see endTable()
129
-	*/
130
-	function printPages() {
131
-		$p = $this->view_pages;			// How many pages to view
132
-		$cur_page = $this->cur_page;	// Current page
133
-		$tot_pages = $this->tot_pages;	// Total pages
134
-		
135
-		// Open up the HTML table
136
-		$this->startTable();
137
-		// Open up cell for page links
138
-		$this->startPagesCell();
139
-		
140
-		// Page to start printing bulk of links
141
-		$start = ($cur_page > $p) ? $cur_page - $p : 1;
142
-		// Page to end printing bulk of links
143
-		$end = ($cur_page + $p) < $tot_pages ? $cur_page + $p : $tot_pages;
144
-		
145
-		// Print 'prev' link
146
-		$this->printPrev();
147
-		
148
-		// Print link to first page, if not already there
149
-		if ($start != 1) {
150
-			$this->printPage(1);
151
-		}
152
-		
153
-		// Print '...' if necessary (with link to center page)
154
-		if ($cur_page > $p+2) {
155
-			$this->printLink(ceil( ($start+1)/2 ), '...');
156
-		}
157
-		
158
-		// Print links to pages before current page (up to first page)
159
-		// Print current page
160
-		// Print links to pages after current page (up to last page)		
161
-		for ($pg = $start; $pg <= $end; $pg++) {
162
-			$this->printPage($pg);
163
-		}
164
-				
165
-		// Print '...' if necessary (with link to center page)
166
-		if ( $cur_page < ($tot_pages - ($p+1)) ) {
167
-			$this->printLink(ceil( ($tot_pages+$end)/2 ), '...' );
168
-		}
169
-		
170
-		// Print link to last page, if not already there
171
-		if ($end != $tot_pages) {
172
-			$this->printPage($tot_pages);
173
-		}
174
-		
175
-		// Print 'next' link
176
-		$this->printNext();
177
-		
178
-		// Print total records
179
-		$this->printTotal();
180
-		
181
-		// Close page links cell
182
-		$this->endPagesCell();
183
-		// Print out cell with limit jump menu
184
-		if ($this->print_limit_select) { $this->printLimitCell(); }
185
-		// Close table
186
-		$this->endTable();
187
-	}
188
-	
189
-	//-----------------------------------------
190
-	// Application setter functions
191
-	//-----------------------------------------
192
-	/**
193
-	* Sets current page variable
194
-	* @param none
195
-	*/
196
-	function initCurPage() {
197
-		$this->cur_page = isset($_GET[$this->page_var]) ? intval($_GET[$this->page_var]) : 1;
198
-	}
199
-	
200
-	/**
201
-	* Sets the limit variable if it is passed from querystring
202
-	* @param none
203
-	*/
204
-	function initLimit() {
205
-		if (isset($_GET[$this->limit_var]))
206
-			$this->limit = intval($_GET[$this->limit_var]);
207
-		if (isset($_POST[$this->limit_var]))
208
-			$this->limit = intval($_POST[$this->limit_var]);
209
-	}
210
-	
211
-	/**
212
-	* Pull page information from query string and set $query_string
213
-	*
214
-	* setLimit() must be called before this function for it to work correctly
215
-	* @param none
216
-	*/
217
-	function initQueryString() {
218
-	    if (isset($_SERVER['QUERY_STRING'])) {
219
-			// Remove page from query string and convert all "&" to "&amp;"
220
-			$this->query_string = str_replace('&', '&amp;', preg_replace("/(&|&amp;)?$this->page_var=\d*/",'',$_SERVER['QUERY_STRING']));
221
-			
222
-			// Insert limit into querystring, if it's not there
223
-			if ( !strstr($this->query_string, "$this->limit_var=") )
224
-				$this->query_string .= "&amp;$this->limit_var=" . $this->limit;
225
-		}
226
-		else {
227
-			$this->query_string = '';
228
-		}
229
-
230
-	}
231
-	
232
-	/**
233
-	* Sets the tot_pages variable
234
-	*
235
-	* tot_records must be set and setLimit() must be called before
236
-	*  this function can be called
237
-	*
238
-	* @param none
239
-	*/
240
-	function initTotPages() {
241
-		$this->tot_pages = ceil($this->tot_records/$this->limit);
242
-	}
243
-	//===========================================
244
-	
245
-	//-------------------------------------------
246
-	// Output functions
247
-	//-------------------------------------------	
248
-	/**
249
-	* Print out link to a page
250
-	* @param int $p page number to print
251
-	*/
252
-	function printPage($p) {
253
-		if ($p == $this->cur_page) {
254
-			echo " <b>[$p]</b> ";
255
-		}
256
-		else {
257
-			$this->printLink($p, $p);
258
-		}
259
-	}
260
-	
261
-	/**
262
-	* Print 'prev' link, if necessary
263
-	* @param none
264
-	*/
265
-	function printPrev() {
266
-		$cur_page = $this->cur_page;
267
-		if ($cur_page > 1)
268
-			$this->printLink($cur_page-1, $this->prev_link);
269
-	}
270
-	
271
-	/**
272
-	* Print 'next' link, if necessary
273
-	* @param none
274
-	*/
275
-	function printNext() {
276
-		$cur_page = $this->cur_page;
277
-		if ($cur_page < $this->tot_pages && $this->tot_records > 0)
278
-			$this->printLink($cur_page+1, $this->next_link);
279
-	}
280
-	
281
-	/**
282
-	* Print out link to a certain page
283
-	* @param int $page page to link to
284
-	* @param string $text link text
285
-	*/
286
-	function printLink($page, $text) {
287
-		global $link;
288
-		global $use_link;
289
-		
290
-		if ($use_link) {
291
-			$link->doLink(
292
-				$_SERVER['PHP_SELF'] . "?$this->page_var=$page&amp;" . $this->query_string . '"',
293
-				$text,
294
-				$this->link_class,
295
-				'',
296
-				'Page ' . $page
297
-				);
298
-		}
299
-		else {
300
-			echo ' <a href="' . $_SERVER['PHP_SELF'] . "?$this->page_var=$page&amp;" . $this->query_string . '"'
301
-				. ' class="$this->class"'
302
-				. '>'
303
-				. $text . '</a> ';
304
-		}
305
-	}
306
-	
307
-	/**
308
-	* Prints out opening table tag
309
-	* @param none
310
-	*/
311
-	function startTable() {
312
-		echo "<table align=\"$this->table_align\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"$this->table_width\">\n"
313
-			. "<tr class=\"$this->text_class\" style=\"$this->text_style\">\n";	
314
-	}
315
-	
316
-	/**
317
-	* Begins cell containing page links
318
-	* @param none
319
-	*/
320
-	function startPagesCell() {
321
-		echo '<td>' . translate('Page') . ' ';
322
-	}
323
-	
324
-	/**
325
-	* Closes cell containing page links
326
-	* @param none
327
-	*/
328
-	function endPagesCell() {
329
-		echo '</td>';
330
-	} 
331
-	
332
-	/**
333
-	* Prints out cell containing limit jump menu
334
-	* @param none
335
-	*/
336
-	function printLimitCell() {
337
-		$limits = $this->limits;
338
-		echo "<td align=\"right\">\n"
339
-			. "<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"
340
-			. translate('Per page') . " <select name=\"$this->limit_var\" onchange=\"document.limit_jump.submit();\" class=\"$this->tb_class\" style=\"$this->tb_style\">\n";
341
-		for ($i = 0; $i < count($limits); $i++) {
342
-			echo '<option value="' . $limits[$i] . '"';
343
-			if ($limits[$i] == $this->limit)
344
-				echo ' selected="selected"';
345
-			echo '>' . $limits[$i] . "</option>\n";
346
-		}
347
-		echo "</select>\n"
348
-			. "</form>\n"
349
-			. "</td>\n";
350
-	}
351
-	
352
-	/**
353
-	* Prints out the closing row and table HTML tags
354
-	* @param none
355
-	*/
356
-	function endTable() {
357
-		echo "</tr>\n</table>\n";
358
-	}
359
-	
360
-	/**
361
-	* Prints out total number of records returned
362
-	* @param none
363
-	*/
364
-	function printTotal() {
365
-		echo '(' . $this->tot_records . ')';
366
-	}
367
-	//============================================
368
-
369
-	//--------------------------------------------
370
-	// User-Modified Setter Functions
371
-	//--------------------------------------------	
372
-	/**
373
-	* Sets the total records for this recordset
374
-	* 
375
-	* - Default setting is 0 (in constructor)
376
-	*
377
-	* @param int $tot total number of records
378
-	*/
379
-	function setTotRecords($tot) {
380
-		$this->tot_records = intval($tot);
381
-		// Call initTotPages again to reset paging
382
-		$this->initTotPages();
383
-	}
384
-	
385
-	/**
386
-	* Sets the default recordset limit
387
-	* Note: A limit value set in the querystring
388
-	*  or in a post value will override this
389
-	*
390
-	* - Default setting is 25 (in constructor)
391
-	*
392
-	* @param int $limit new limit value
393
-	*/
394
-	function setLimit($limit) {
395
-		$this->limit = intval($limit);
396
-		// Call initLimit() to reinitialzie limit
397
-		$this->initLimit();
398
-	}
399
-	
400
-	/**
401
-	* Sets the text for 'prev' link
402
-	*
403
-	* - Default setting is "&laquo;"
404
-	*
405
-	* @param string $text link text
406
-	*/
407
-	function setPrevLink($text) {
408
-		$this->prev_link = trim($text);
409
-	}
410
-	
411
-	/**
412
-	* Sets the text for 'next' link
413
-	*
414
-	* - Default setting is "&raquo;"
415
-	*
416
-	* @param string $text link text
417
-	*/
418
-	function setNextLink($text) {
419
-		$this->next_link = trim($text);
420
-	}
421
-		
422
-	/**
423
-	* Sets the value of view_pages
424
-	* How many pages to print on either side of
425
-	* the currently viewed page number
426
-	*
427
-	* - Default setting is 3
428
-	*
429
-	* @param int $view_page how many pages to view
430
-	*/
431
-	function setViewPages($view_page) {
432
-		$this->view_pages = intval($view_page);
433
-	}
434
-	
435
-	/**
436
-	* Sets the array of limits
437
-	* Pass in an array of ints to use
438
-	* for the limit pull down menu
439
-	*
440
-	* - Default setting is (10, 25, 50, 100)
441
-	*
442
-	* @param int $new_limits array of limits
443
-	*/
444
-	function setLimits($new_limits) {
445
-		$this->limits = $new_limits;
446
-	}
447
-	
448
-	/**
449
-	* Sets the name of the class to be used for the links
450
-	*
451
-	* - Default setting is null
452
-	*
453
-	* @param string $link_class name of class
454
-	*/
455
-	function setLinkClass($link_class) {
456
-		$this->link_class = $link_class;
457
-	}
458
-	
459
-	/**
460
-	* Sets the name of the class to be used for the pull down box
461
-	*
462
-	* - Default setting is null
463
-	*
464
-	* @param string $tb_class name of class
465
-	*/
466
-	function setTbClass($tb_class) {
467
-		$this->tb_class = $tb_class;
468
-	}
469
-	
470
-	/**
471
-	* Sets the inline style of the limit jump menu
472
-	* This setting overrides the tb_class value
473
-	*
474
-	* - Default setting is null
475
-	* @param string $tb_style style of limit jump menu box
476
-	*/
477
-	function setTbStyle($tb_style) {
478
-		$this->tb_style = $tb_style;
479
-	}
480
-	
481
-	/**
482
-	* Sets the name of the class to be used for the text
483
-	*  ie) "Page:" and "Per page:"
484
-	* Should be used to modify all paging text font -amily, size, etc
485
-	*
486
-	* - Default setting is null
487
-	*
488
-	* @param string $text_class name of class
489
-	*/
490
-	function setTextClass($text_class) {
491
-		$this->text_class = $text_class;
492
-	}
493
-	
494
-	/**
495
-	* Sets the inline style to be used for the text
496
-	* Should be used to modifiy all paging text font-family, size, etc
497
-	* This will override the text_class setting
498
-	*
499
-	* - Default setting is null
500
-	*
501
-	* @param string $text_style style to use for the text
502
-	*/
503
-	function setTextStyle($text_style) {
504
-		$this->text_style = $text_style;
505
-	}
506
-	
507
-	/**
508
-	* Sets the width of the table bounding the pages/jump box
509
-	*
510
-	* - Default setting is "100%"
511
-	*
512
-	* @param string $table_width width of table
513
-	*/
514
-	function setTableWidth($table_width) {
515
-		$this->table_width = $table_width;
516
-	}
517
-	
518
-	/**
519
-	* Sets the horizontial alignment of the table bounding the paging
520
-	*
521
-	* - Default setting is "center"
522
-	*
523
-	* @param string $table_align alignment value for table align
524
-	*/
525
-	function setTableAlign($table_align) {
526
-		$this->table_align = $table_align;
527
-	}
528
-	
529
-	/**
530
-	* Sets the page variable name for the querystring
531
-	* @param string $page_var page variable name
532
-	*/
533
-	function setPageVar($page_var) {
534
-		$this->page_var = $page_var;
535
-	}
536
-	
537
-	/**
538
-	* Sets the limit variable name for the querystring
539
-	* @param string $limit_var limit variable name
540
-	*/
541
-	function setLimitVar($limit_var) {
542
-		$this->limit_var = $limit_var;
543
-	}
544
-	
545
-	/**
546
-	* Sets the print_limit_select variable to decide if we should show the limit select pulldown
547
-	* @param bool $view_limit_select if we should show the select pulldown or not
548
-	*/
549
-	function setViewLimitSelect($view_limit_select) {
550
-		$this->print_limit_select = $view_limit_select;
551
-	}
552
-	//============================================
553
-	
554
-	//--------------------------------------------
555
-	// Getter methods
556
-	//--------------------------------------------	
557
-	/**
558
-	* Returns the recordset offset
559
-	* @param none
560
-	* @return integer recorset offset
561
-	*/
562
-	function getOffset() {
563
-		return $this->limit * $this->cur_page - $this->limit;
564
-	}
565
-	
566
-	/**
567
-	* Returns the total number of pages
568
-	* @param none
569
-	* @return integer number of pages total
570
-	*/
571
-	function getTotPages() {
572
-		return $this->tot_pages;
573
-	}
574
-	
575
-	/**
576
-	* Returns the current page number
577
-	* @param none
578
-	* @return integer current page number
579
-	*/
580
-	function getPageNum() {
581
-		return $this->cur_page;
582
-	}
583
-	
584
-	/**
585
-	* Returns the current recordset limit
586
-	* @param none
587
-	* @return integer recordset limit
588
-	*/
589
-	function getLimit() {
590
-		return $this->limit;
591
-	}
592
-	
593
-	/**
594
-	* Returns value of previous link text
595
-	* @param none
596
-	* @return string previous link text
597
-	*/
598
-	function getPrevLink() {
599
-		return $this->prev_link;
600
-	}
601
-	
602
-	/**
603
-	* Returns value of next link text
604
-	* @param none
605
-	* @return string next link text
606
-	*/
607
-	function getNextLink() {
608
-		return $this->next_link;
609
-	}
610
-	
611
-	/**
612
-	* Returns the name used for the page querystring variable
613
-	* @param none
614
-	* @return string page variable name
615
-	*/
616
-	function getPageVar() {
617
-		return $this->page_var;
618
-	}
619
-	
620
-	/**
621
-	* Returns the name used for the limit querystring variable
622
-	* @param none
623
-	* @return string limit variable name
624
-	*/
625
-	function getLimitVar() {
626
-		return $this->limit_var;
627
-	}
628
-	//===========================================
629
-	
630
-// End class
631
-}
632
-?>
633
\ No newline at end of file
634
+<?php
635
+/**
636
+* Paging class to iterate through limited recordsets
637
+* @author Nick Korbel <lqqkout13@users.sourceforge.net>
638
+* @version 02-02-05
639
+* @package Pager
640
+*
641
+* Copyright (C) 2003 - 2005 phpScheduleIt
642
+* License: GPL, see LICENSE
643
+* /
644
+/**
645
+* To actually print out page links, call printPages() function
646
+*
647
+* In order for this object to work correctly, total records
648
+*  must be set in either the constructor or by calling
649
+*  setTotRecords()
650
+*
651
+* + Warning - The printPages() function cannot be called
652
+* 			from within a form
653
+*
654
+* === EXAMPLE OF HOW TO USE PAGER ===
655
+* // Initialize new Pager object with default values
656
+* $pager = new Pager();
657
+*
658
+* // Get total # of pages
659
+* $query = "SELECT COUNT(*) as num FROM table";
660
+* $result = $db->query($query);    
661
+* $rs = $result->fetchRow();
662
+* $num = $rs['num'];              // # of records
663
+*
664
+* $pager->setTotRecords($num);
665
+* $recordset_offset = $pager->getOffset();
666
+* $limit = $pager->getLimit();
667
+*
668
+* // Execute Query (using $offset and $limit values) //
669
+*
670
+* $pager->printPages();
671
+* ==========================================
672
+*
673
+*/
674
+
675
+// Should we use the Link class?
676
+$use_link = true;
677
+
678
+if ($use_link) {
679
+	//include_once('Link.class.php');
680
+	$link = new Link();
681
+}
682
+
683
+class Pager {
684
+	// Application set variables
685
+	var $cur_page;
686
+	var $query_string;
687
+	var $tot_pages;
688
+	var $page_var;
689
+	var $limit_var;
690
+	
691
+	// Application variables with user modify option
692
+	var $limit;
693
+	var $tot_records;
694
+	var $print_limit_select = true;
695
+	
696
+	// User modifiable variables
697
+	var $prev_link = '&laquo;';
698
+	var $next_link = '&raquo;';
699
+	var $limits = array(10, 25, 50, 100);
700
+	var $view_pages = 3;
701
+	var $table_width = '100%';
702
+	var $table_align = 'center';
703
+	var $link_class;
704
+	var $tb_class;
705
+	var $tb_style;
706
+	var $text_class;
707
+	var $text_style;
708
+	
709
+		
710
+	/**
711
+	* Pager Constructor
712
+	* Sets up Pager variables and initializes values
713
+	*
714
+	* - All parameters are optional and have default values of:
715
+	*    $tot_records = 0
716
+	*    $limit = 25
717
+	*    $page_var = "page"
718
+	*    $limit_var = "limit"
719
+	*
720
+	* @param int $tot_records optional total number of records
721
+	* @param int $limit optional limit of recordset
722
+	* @param string $page_var optional name of var to use in querystring for page value
723
+	* @param string $limit_var optional name of var to use in querystring for limit value
724
+	*/
725
+	function __construct($tot_records=0, $limit=25, $page_var='page', $limit_var='limit') {
726
+		$this->tot_records = $tot_records;
727
+		$this->limit = $limit;
728
+		$this->page_var = $page_var;
729
+		$this->limit_var = $limit_var;
730
+		
731
+		// Call all system setter functions
732
+		$this->initCurPage();
733
+		$this->initLimit();
734
+		$this->initTotPages();
735
+		$this->initQueryString();
736
+	}
737
+	
738
+	
739
+	/**
740
+	* Print out the pages as links
741
+	* Prints out a table of all the pages as links
742
+	*  and a jump menu to change the number of records
743
+	*  per page
744
+	*
745
+	* setCurPage() and setTotPages() must be called
746
+	*  before this function can be called
747
+	*
748
+	* @param none
749
+	* @see printPrev()
750
+	* @see printLink()
751
+	* @see printPage()
752
+	* @see printNext()
753
+	* @see printTotal()
754
+	* @see startTable()
755
+	* @see startPagesCell()
756
+	* @see endPagesCell()
757
+	* @see printLimitCell()
758
+	* @see endTable()
759
+	*/
760
+	function printPages() {
761
+		$p = $this->view_pages;			// How many pages to view
762
+		$cur_page = $this->cur_page;	// Current page
763
+		$tot_pages = $this->tot_pages;	// Total pages
764
+		
765
+		// Open up the HTML table
766
+		$this->startTable();
767
+		// Open up cell for page links
768
+		$this->startPagesCell();
769
+		
770
+		// Page to start printing bulk of links
771
+		$start = ($cur_page > $p) ? $cur_page - $p : 1;
772
+		// Page to end printing bulk of links
773
+		$end = ($cur_page + $p) < $tot_pages ? $cur_page + $p : $tot_pages;
774
+		
775
+		// Print 'prev' link
776
+		$this->printPrev();
777
+		
778
+		// Print link to first page, if not already there
779
+		if ($start != 1) {
780
+			$this->printPage(1);
781
+		}
782
+		
783
+		// Print '...' if necessary (with link to center page)
784
+		if ($cur_page > $p+2) {
785
+			$this->printLink(ceil( ($start+1)/2 ), '...');
786
+		}
787
+		
788
+		// Print links to pages before current page (up to first page)
789
+		// Print current page
790
+		// Print links to pages after current page (up to last page)		
791
+		for ($pg = $start; $pg <= $end; $pg++) {
792
+			$this->printPage($pg);
793
+		}
794
+				
795
+		// Print '...' if necessary (with link to center page)
796
+		if ( $cur_page < ($tot_pages - ($p+1)) ) {
797
+			$this->printLink(ceil( ($tot_pages+$end)/2 ), '...' );
798
+		}
799
+		
800
+		// Print link to last page, if not already there
801
+		if ($end != $tot_pages) {
802
+			$this->printPage($tot_pages);
803
+		}
804
+		
805
+		// Print 'next' link
806
+		$this->printNext();
807
+		
808
+		// Print total records
809
+		$this->printTotal();
810
+		
811
+		// Close page links cell
812
+		$this->endPagesCell();
813
+		// Print out cell with limit jump menu
814
+		if ($this->print_limit_select) { $this->printLimitCell(); }
815
+		// Close table
816
+		$this->endTable();
817
+	}
818
+	
819
+	//-----------------------------------------
820
+	// Application setter functions
821
+	//-----------------------------------------
822
+	/**
823
+	* Sets current page variable
824
+	* @param none
825
+	*/
826
+	function initCurPage() {
827
+		$this->cur_page = isset($_GET[$this->page_var]) ? intval($_GET[$this->page_var]) : 1;
828
+	}
829
+	
830
+	/**
831
+	* Sets the limit variable if it is passed from querystring
832
+	* @param none
833
+	*/
834
+	function initLimit() {
835
+		if (isset($_GET[$this->limit_var]))
836
+			$this->limit = intval($_GET[$this->limit_var]);
837
+		if (isset($_POST[$this->limit_var]))
838
+			$this->limit = intval($_POST[$this->limit_var]);
839
+	}
840
+	
841
+	/**
842
+	* Pull page information from query string and set $query_string
843
+	*
844
+	* setLimit() must be called before this function for it to work correctly
845
+	* @param none
846
+	*/
847
+	function initQueryString() {
848
+	    if (isset($_SERVER['QUERY_STRING'])) {
849
+			// Remove page from query string and convert all "&" to "&amp;"
850
+			$this->query_string = str_replace('&', '&amp;', preg_replace("/(&|&amp;)?$this->page_var=\d*/",'',$_SERVER['QUERY_STRING']));
851
+			
852
+			// Insert limit into querystring, if it's not there
853
+			if ( !strstr($this->query_string, "$this->limit_var=") )
854
+				$this->query_string .= "&amp;$this->limit_var=" . $this->limit;
855
+		}
856
+		else {
857
+			$this->query_string = '';
858
+		}
859
+
860
+	}
861
+	
862
+	/**
863
+	* Sets the tot_pages variable
864
+	*
865
+	* tot_records must be set and setLimit() must be called before
866
+	*  this function can be called
867
+	*
868
+	* @param none
869
+	*/
870
+	function initTotPages() {
871
+		$this->tot_pages = ceil($this->tot_records/$this->limit);
872
+	}
873
+	//===========================================
874
+	
875
+	//-------------------------------------------
876
+	// Output functions
877
+	//-------------------------------------------	
878
+	/**
879
+	* Print out link to a page
880
+	* @param int $p page number to print
881
+	*/
882
+	function printPage($p) {
883
+		if ($p == $this->cur_page) {
884
+			echo " <b>[$p]</b> ";
885
+		}
886
+		else {
887
+			$this->printLink($p, $p);
888
+		}
889
+	}
890
+	
891
+	/**
892
+	* Print 'prev' link, if necessary
893
+	* @param none
894
+	*/
895
+	function printPrev() {
896
+		$cur_page = $this->cur_page;
897
+		if ($cur_page > 1)
898
+			$this->printLink($cur_page-1, $this->prev_link);
899
+	}
900
+	
901
+	/**
902
+	* Print 'next' link, if necessary
903
+	* @param none
904
+	*/
905
+	function printNext() {
906
+		$cur_page = $this->cur_page;
907
+		if ($cur_page < $this->tot_pages && $this->tot_records > 0)
908
+			$this->printLink($cur_page+1, $this->next_link);
909
+	}
910
+	
911
+	/**
912
+	* Print out link to a certain page
913
+	* @param int $page page to link to
914
+	* @param string $text link text
915
+	*/
916
+	function printLink($page, $text) {
917
+		global $link;
918
+		global $use_link;
919
+		
920
+		if ($use_link) {
921
+			$link->doLink(
922
+				$_SERVER['PHP_SELF'] . "?$this->page_var=$page&amp;" . $this->query_string . '"',
923
+				$text,
924
+				$this->link_class,
925
+				'',
926
+				'Page ' . $page
927
+				);
928
+		}
929
+		else {
930
+			echo ' <a href="' . $_SERVER['PHP_SELF'] . "?$this->page_var=$page&amp;" . $this->query_string . '"'
931
+				. ' class="$this->class"'
932
+				. '>'
933
+				. $text . '</a> ';
934
+		}
935
+	}
936
+	
937
+	/**
938
+	* Prints out opening table tag
939
+	* @param none
940
+	*/
941
+	function startTable() {
942
+		echo "<table align=\"$this->table_align\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"$this->table_width\">\n"
943
+			. "<tr class=\"$this->text_class\" style=\"$this->text_style\">\n";	
944
+	}
945
+	
946
+	/**
947
+	* Begins cell containing page links
948
+	* @param none
949
+	*/
950
+	function startPagesCell() {
951
+		echo '<td>' . translate('Page') . ' ';
952
+	}
953
+	
954
+	/**
955
+	* Closes cell containing page links
956
+	* @param none
957
+	*/
958
+	function endPagesCell() {
959
+		echo '</td>';
960
+	} 
961
+	
962
+	/**
963
+	* Prints out cell containing limit jump menu
964
+	* @param none
965
+	*/
966
+	function printLimitCell() {
967
+		$limits = $this->limits;
968
+		echo "<td align=\"right\">\n"
969
+			. "<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"
970
+			. translate('Per page') . " <select name=\"$this->limit_var\" onchange=\"document.limit_jump.submit();\" class=\"$this->tb_class\" style=\"$this->tb_style\">\n";
971
+		for ($i = 0; $i < count($limits); $i++) {
972
+			echo '<option value="' . $limits[$i] . '"';
973
+			if ($limits[$i] == $this->limit)
974
+				echo ' selected="selected"';
975
+			echo '>' . $limits[$i] . "</option>\n";
976
+		}
977
+		echo "</select>\n"
978
+			. "</form>\n"
979
+			. "</td>\n";
980
+	}
981
+	
982
+	/**
983
+	* Prints out the closing row and table HTML tags
984
+	* @param none
985
+	*/
986
+	function endTable() {
987
+		echo "</tr>\n</table>\n";
988
+	}
989
+	
990
+	/**
991
+	* Prints out total number of records returned
992
+	* @param none
993
+	*/
994
+	function printTotal() {
995
+		echo '(' . $this->tot_records . ')';
996
+	}
997
+	//============================================
998
+
999
+	//--------------------------------------------
1000
+	// User-Modified Setter Functions
1001
+	//--------------------------------------------	
1002
+	/**
1003
+	* Sets the total records for this recordset
1004
+	* 
1005
+	* - Default setting is 0 (in constructor)
1006
+	*
1007
+	* @param int $tot total number of records
1008
+	*/
1009
+	function setTotRecords($tot) {
1010
+		$this->tot_records = intval($tot);
1011
+		// Call initTotPages again to reset paging
1012
+		$this->initTotPages();
1013
+	}
1014
+	
1015
+	/**
1016
+	* Sets the default recordset limit
1017
+	* Note: A limit value set in the querystring
1018
+	*  or in a post value will override this
1019
+	*
1020
+	* - Default setting is 25 (in constructor)
1021
+	*
1022
+	* @param int $limit new limit value
1023
+	*/
1024
+	function setLimit($limit) {
1025
+		$this->limit = intval($limit);
1026
+		// Call initLimit() to reinitialzie limit
1027
+		$this->initLimit();
1028
+	}
1029
+	
1030
+	/**
1031
+	* Sets the text for 'prev' link
1032
+	*
1033
+	* - Default setting is "&laquo;"
1034
+	*
1035
+	* @param string $text link text
1036
+	*/
1037
+	function setPrevLink($text) {
1038
+		$this->prev_link = trim($text);
1039
+	}
1040
+	
1041
+	/**
1042
+	* Sets the text for 'next' link
1043
+	*
1044
+	* - Default setting is "&raquo;"
1045
+	*
1046
+	* @param string $text link text
1047
+	*/
1048
+	function setNextLink($text) {
1049
+		$this->next_link = trim($text);
1050
+	}
1051
+		
1052
+	/**
1053
+	* Sets the value of view_pages
1054
+	* How many pages to print on either side of
1055
+	* the currently viewed page number
1056
+	*
1057
+	* - Default setting is 3
1058
+	*
1059
+	* @param int $view_page how many pages to view
1060
+	*/
1061
+	function setViewPages($view_page) {
1062
+		$this->view_pages = intval($view_page);
1063
+	}
1064
+	
1065
+	/**
1066
+	* Sets the array of limits
1067
+	* Pass in an array of ints to use
1068
+	* for the limit pull down menu
1069
+	*
1070
+	* - Default setting is (10, 25, 50, 100)
1071
+	*
1072
+	* @param int $new_limits array of limits
1073
+	*/
1074
+	function setLimits($new_limits) {
1075
+		$this->limits = $new_limits;
1076
+	}
1077
+	
1078
+	/**
1079
+	* Sets the name of the class to be used for the links
1080
+	*
1081
+	* - Default setting is null
1082
+	*
1083
+	* @param string $link_class name of class
1084
+	*/
1085
+	function setLinkClass($link_class) {
1086
+		$this->link_class = $link_class;
1087
+	}
1088
+	
1089
+	/**
1090
+	* Sets the name of the class to be used for the pull down box
1091
+	*
1092
+	* - Default setting is null
1093
+	*
1094
+	* @param string $tb_class name of class
1095
+	*/
1096
+	function setTbClass($tb_class) {
1097
+		$this->tb_class = $tb_class;
1098
+	}
1099
+	
1100
+	/**
1101
+	* Sets the inline style of the limit jump menu
1102
+	* This setting overrides the tb_class value
1103
+	*
1104
+	* - Default setting is null
1105
+	* @param string $tb_style style of limit jump menu box
1106
+	*/
1107
+	function setTbStyle($tb_style) {
1108
+		$this->tb_style = $tb_style;
1109
+	}
1110
+	
1111
+	/**
1112
+	* Sets the name of the class to be used for the text
1113
+	*  ie) "Page:" and "Per page:"
1114
+	* Should be used to modify all paging text font -amily, size, etc
1115
+	*
1116
+	* - Default setting is null
1117
+	*
1118
+	* @param string $text_class name of class
1119
+	*/
1120
+	function setTextClass($text_class) {
1121
+		$this->text_class = $text_class;
1122
+	}
1123
+	
1124
+	/**
1125
+	* Sets the inline style to be used for the text
1126
+	* Should be used to modifiy all paging text font-family, size, etc
1127
+	* This will override the text_class setting
1128
+	*
1129
+	* - Default setting is null
1130
+	*
1131
+	* @param string $text_style style to use for the text
1132
+	*/
1133
+	function setTextStyle($text_style) {
1134
+		$this->text_style = $text_style;
1135
+	}
1136
+	
1137
+	/**
1138
+	* Sets the width of the table bounding the pages/jump box
1139
+	*
1140
+	* - Default setting is "100%"
1141
+	*
1142
+	* @param string $table_width width of table
1143
+	*/
1144
+	function setTableWidth($table_width) {
1145
+		$this->table_width = $table_width;
1146
+	}
1147
+	
1148
+	/**
1149
+	* Sets the horizontial alignment of the table bounding the paging
1150
+	*
1151
+	* - Default setting is "center"
1152
+	*
1153
+	* @param string $table_align alignment value for table align
1154
+	*/
1155
+	function setTableAlign($table_align) {
1156
+		$this->table_align = $table_align;
1157
+	}
1158
+	
1159
+	/**
1160
+	* Sets the page variable name for the querystring
1161
+	* @param string $page_var page variable name
1162
+	*/
1163
+	function setPageVar($page_var) {
1164
+		$this->page_var = $page_var;
1165
+	}
1166
+	
1167
+	/**
1168
+	* Sets the limit variable name for the querystring
1169
+	* @param string $limit_var limit variable name
1170
+	*/
1171
+	function setLimitVar($limit_var) {
1172
+		$this->limit_var = $limit_var;
1173
+	}
1174
+	
1175
+	/**
1176
+	* Sets the print_limit_select variable to decide if we should show the limit select pulldown
1177
+	* @param bool $view_limit_select if we should show the select pulldown or not
1178
+	*/
1179
+	function setViewLimitSelect($view_limit_select) {
1180
+		$this->print_limit_select = $view_limit_select;
1181
+	}
1182
+	//============================================
1183
+	
1184
+	//--------------------------------------------
1185
+	// Getter methods
1186
+	//--------------------------------------------	
1187
+	/**
1188
+	* Returns the recordset offset
1189
+	* @param none
1190
+	* @return integer recorset offset
1191
+	*/
1192
+	function getOffset() {
1193
+		return $this->limit * $this->cur_page - $this->limit;
1194
+	}
1195
+	
1196
+	/**
1197
+	* Returns the total number of pages
1198
+	* @param none
1199
+	* @return integer number of pages total
1200
+	*/
1201
+	function getTotPages() {
1202
+		return $this->tot_pages;
1203
+	}
1204
+	
1205
+	/**
1206
+	* Returns the current page number
1207
+	* @param none
1208
+	* @return integer current page number
1209
+	*/
1210
+	function getPageNum() {
1211
+		return $this->cur_page;
1212
+	}
1213
+	
1214
+	/**
1215
+	* Returns the current recordset limit
1216
+	* @param none
1217
+	* @return integer recordset limit
1218
+	*/
1219
+	function getLimit() {
1220
+		return $this->limit;
1221
+	}
1222
+	
1223
+	/**
1224
+	* Returns value of previous link text
1225
+	* @param none
1226
+	* @return string previous link text
1227
+	*/
1228
+	function getPrevLink() {
1229
+		return $this->prev_link;
1230
+	}
1231
+	
1232
+	/**
1233
+	* Returns value of next link text
1234
+	* @param none
1235
+	* @return string next link text
1236
+	*/
1237
+	function getNextLink() {
1238
+		return $this->next_link;
1239
+	}
1240
+	
1241
+	/**
1242
+	* Returns the name used for the page querystring variable
1243
+	* @param none
1244
+	* @return string page variable name
1245
+	*/
1246
+	function getPageVar() {
1247
+		return $this->page_var;
1248
+	}
1249
+	
1250
+	/**
1251
+	* Returns the name used for the limit querystring variable
1252
+	* @param none
1253
+	* @return string limit variable name
1254
+	*/
1255
+	function getLimitVar() {
1256
+		return $this->limit_var;
1257
+	}
1258
+	//===========================================
1259
+	
1260
+// End class
1261
+}
1262
+?>
(-)b/security/mailzu/files/patch-lib_Template.class.php (+9 lines)
Lines 1-5 Link Here
1
--- lib/Template.class.php.orig	2007-06-14 19:00:15 UTC
1
--- lib/Template.class.php.orig	2007-06-14 19:00:15 UTC
2
+++ lib/Template.class.php
2
+++ lib/Template.class.php
3
@@ -30,7 +30,7 @@ class Template {
4
 	* @param string $title title of page
5
 	* @param int $depth depth of the current page relative to phpScheduleIt root
6
 	*/
7
-	function Template($title = '', $depth = 0) {
8
+	function __construct($title = '', $depth = 0) {
9
 		global $conf;
10
 		
11
 		$this->title = (!empty($title)) ? $title : $conf['ui']['welcome'];
3
@@ -57,21 +57,21 @@ class Template {
12
@@ -57,21 +57,21 @@ class Template {
4
 	?>
13
 	?>
5
 	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
14
 	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
(-)b/security/mailzu/files/patch-lib_htmlfilter.php (-3 / +137 lines)
Lines 1-11 Link Here
1
--- lib/htmlfilter.php.orig	2007-06-14 19:00:15 UTC
1
--- lib/htmlfilter.php.orig	2007-06-14 19:00:15 UTC
2
+++ lib/htmlfilter.php
2
+++ lib/htmlfilter.php
3
@@ -106,7 +106,7 @@ function casenormalize(&$val){
3
@@ -106,8 +106,8 @@ function casenormalize(&$val){
4
 function skipspace($body, $offset){
4
 function skipspace($body, $offset){
5
     $me = 'skipspace';
5
     $me = 'skipspace';
6
     preg_match('/^(\s*)/s', substr($body, $offset), $matches);
6
     preg_match('/^(\s*)/s', substr($body, $offset), $matches);
7
-    if (sizeof($matches{1})){
7
-    if (sizeof($matches{1})){
8
+    if (is_array($matches{1}) && sizeof($matches{1})){
8
-        $count = strlen($matches{1});
9
         $count = strlen($matches{1});
9
+    if (is_array($matches[1]) && sizeof($matches[1])){
10
+        $count = strlen($matches[1]);
10
         spew("$me: skipped $count chars\n");
11
         spew("$me: skipped $count chars\n");
11
         $offset += $count;
12
         $offset += $count;
13
     }
14
@@ -159,10 +159,10 @@ function findnxreg($body, $offset, $reg){
15
         spew("$me: No matches found.\n");
16
         $retarr = false;
17
     } else {
18
-        $retarr{0} = $offset + strlen($matches{1});
19
-        $retarr{1} = $matches{1};
20
-        $retarr{2} = $matches{2};
21
-        spew("$me: '$reg' found at pos $offset matching '".$matches{2}."'\n");
22
+        $retarr[0] = $offset + strlen($matches[1]);
23
+        $retarr[1] = $matches[1];
24
+        $retarr[2] = $matches[2];
25
+        spew("$me: '$reg' found at pos $offset matching '".$matches[2]."'\n");
26
     }
27
     return $retarr;
28
 }
29
@@ -335,13 +335,13 @@ function getnxtag($body, $offset){
30
          */
31
         $matches = Array();
32
         preg_match('%^(\s*)(>|/>)%s', substr($body, $pos), $matches);
33
-        if (isset($matches{0}) && $matches{0}){
34
+        if (isset($matches[0]) && $matches[0]){
35
             /**
36
              * Yep. So we did.
37
              */
38
             spew("$me: Arrived at the end of the tag.\n");
39
-            $pos += strlen($matches{1});
40
-            if ($matches{2} == '/>'){
41
+            $pos += strlen($matches[1]);
42
+            if ($matches[2] == '/>'){
43
                 $tagtype = 3;
44
                 $pos++;
45
             }
46
@@ -409,7 +409,7 @@ function getnxtag($body, $offset){
47
             spew("$me: Additionally, end of tag found at $pos\n");
48
             spew("$me: Attname is '$attname'\n");
49
             spew("$me: Setting attvalue to 'yes'\n");
50
-            $attary{$attname} = '"yes"';
51
+            $attary[$attname] = '"yes"';
52
             return Array($tagname, $attary, $tagtype, $lt, $pos);
53
             break;
54
         default:
55
@@ -449,7 +449,7 @@ function getnxtag($body, $offset){
56
                     list($pos, $attval, $match) = $regary;
57
                     spew("$me: Attvalue is '$attval'\n");
58
                     $pos++;
59
-                    $attary{$attname} = '\'' . $attval . '\'';
60
+                    $attary[$attname] = '\'' . $attval . '\'';
61
                 } else if ($quot == '"'){
62
                     spew("$me: In fact, this is attribute type 2\n");
63
                     spew("$me: looking for closing quote\n");
64
@@ -462,7 +462,7 @@ function getnxtag($body, $offset){
65
                     list($pos, $attval, $match) = $regary;
66
                     spew("$me: Attvalue is \"$attval\"\n");
67
                     $pos++;
68
-                    $attary{$attname} = '"' . $attval . '"';
69
+                    $attary[$attname] = '"' . $attval . '"';
70
                 } else {
71
                     spew("$me: This looks like attribute type 3\n");
72
                     /**
73
@@ -482,7 +482,7 @@ function getnxtag($body, $offset){
74
                     spew("$me: translating '\"' into &quot;\n");
75
                     $attval = preg_replace('/\"/s', '&quot;', $attval);
76
                     spew("$me: wrapping in quotes\n");
77
-                    $attary{$attname} = '"' . $attval . '"';
78
+                    $attary[$attname] = '"' . $attval . '"';
79
                 }
80
             } else if (preg_match('|[\w/>]|', $char)) {
81
                 /**
82
@@ -490,7 +490,7 @@ function getnxtag($body, $offset){
83
                  */
84
                 spew("$me: attribute type 4 found.\n");
85
                 spew("$me: Setting value to 'yes'\n");
86
-                $attary{$attname} = '"yes"';
87
+                $attary[$attname] = '"yes"';
88
             } else {
89
                 /**
90
                  * An illegal character. Find next '>' and return.
91
@@ -533,7 +533,7 @@ function deent(&$attvalue, $regex, $hex=false){
92
                 $numval = hexdec($numval);
93
                 spew("$me: hex! Numval is now $numval\n");
94
             }
95
-            $repl{$matches[0][$i]} = chr($numval);
96
+            $repl[$matches[0][$i]] = chr($numval);
97
         }
98
         $attvalue = strtr($attvalue, $repl);
99
         spew("$me: attvalue after translation: $attvalue\n");
100
@@ -621,7 +621,7 @@ function fixatts($tagname, 
101
                     if (preg_match($matchattr, $attname)){
102
                         spew("$me: Attribute '$attname' defined as bad.\n");
103
                         spew("$me: Removing.\n");
104
-                        unset($attary{$attname});
105
+                        unset($attary[$attname]);
106
                         continue;
107
                     }
108
                 }
109
@@ -652,7 +652,7 @@ function fixatts($tagname, 
110
                         $newvalue = preg_replace($valmatch,$valrepl,$attvalue);
111
                         if ($newvalue != $attvalue){
112
                             spew("$me: attvalue is now $newvalue\n");
113
-                            $attary{$attname} = $newvalue;
114
+                            $attary[$attname] = $newvalue;
115
                         }
116
                     }
117
                 }
118
@@ -927,10 +927,10 @@ function sanitize($body, 
119
                     $skip_content = false;
120
                 } else {
121
                     if ($skip_content == false){
122
-                        if (isset($open_tags{$tagname}) && 
123
-                            $open_tags{$tagname} > 0){
124
+                        if (isset($open_tags[$tagname]) && 
125
+                            $open_tags[$tagname] > 0){
126
                             spew("$me: popping '$tagname' from open_tags\n");
127
-                            $open_tags{$tagname}--;
128
+                            $open_tags[$tagname]--;
129
                         } else {
130
                             spew("$me: '$tagname' was never opened\n");
131
                             spew("$me: removing\n");
132
@@ -972,10 +972,10 @@ function sanitize($body, 
133
                         } else {
134
                             if ($tagtype == 1){
135
                                 spew("$me: adding '$tagname' to open_tags\n");
136
-                                if (isset($open_tags{$tagname})){
137
-                                    $open_tags{$tagname}++;
138
+                                if (isset($open_tags[$tagname])){
139
+                                    $open_tags[$tagname]++;
140
                                 } else {
141
-                                    $open_tags{$tagname} = 1;
142
+                                    $open_tags[$tagname] = 1;
143
                                 }
144
                             }
145
                             /**

Return to bug 263614