| 1 | 
        
            1386
         | 
        
            Luisehahne
         | 
        <?php
  | 
      
      
        | 2 | 
        
         | 
        
         | 
        
  | 
      
      
        | 3 | 
        
         | 
        
         | 
        // $Id$
  | 
      
      
        | 4 | 
        
         | 
        
         | 
        
  | 
      
      
        | 5 | 
        
         | 
        
         | 
        /*
  | 
      
      
        | 6 | 
        
         | 
        
         | 
        
  | 
      
      
        | 7 | 
        
         | 
        
         | 
         Website Baker Project <http://www.websitebaker.org/>
  | 
      
      
        | 8 | 
        
         | 
        
         | 
         Copyright (C) 2004-2009, Ryan Djurovich
  | 
      
      
        | 9 | 
        
         | 
        
         | 
        
  | 
      
      
        | 10 | 
        
         | 
        
         | 
         Website Baker is free software; you can redistribute it and/or modify
  | 
      
      
        | 11 | 
        
         | 
        
         | 
         it under the terms of the GNU General Public License as published by
  | 
      
      
        | 12 | 
        
         | 
        
         | 
         the Free Software Foundation; either version 2 of the License, or
  | 
      
      
        | 13 | 
        
         | 
        
         | 
         (at your option) any later version.
  | 
      
      
        | 14 | 
        
         | 
        
         | 
        
  | 
      
      
        | 15 | 
        
         | 
        
         | 
         Website Baker is distributed in the hope that it will be useful,
  | 
      
      
        | 16 | 
        
         | 
        
         | 
         but WITHOUT ANY WARRANTY; without even the implied warranty of
  | 
      
      
        | 17 | 
        
         | 
        
         | 
         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  | 
      
      
        | 18 | 
        
         | 
        
         | 
         GNU General Public License for more details.
  | 
      
      
        | 19 | 
        
         | 
        
         | 
        
  | 
      
      
        | 20 | 
        
         | 
        
         | 
         You should have received a copy of the GNU General Public License
  | 
      
      
        | 21 | 
        
         | 
        
         | 
         along with Website Baker; if not, write to the Free Software
  | 
      
      
        | 22 | 
        
         | 
        
         | 
         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  | 
      
      
        | 23 | 
        
         | 
        
         | 
        
  | 
      
      
        | 24 | 
        
         | 
        
         | 
        */
  | 
      
      
        | 25 | 
        
            1496
         | 
        
            DarkViper
         | 
        /* -------------------------------------------------------- */
  | 
      
      
        | 26 | 
        
         | 
        
         | 
        // Must include code to stop this file being accessed directly
  | 
      
      
        | 27 | 
        
            1499
         | 
        
            DarkViper
         | 
        if(!defined('WB_PATH')) {
 | 
      
      
        | 28 | 
        
         | 
        
         | 
        	require_once(dirname(__FILE__).'/globalExceptionHandler.php');
  | 
      
      
        | 29 | 
        
         | 
        
         | 
        	throw new IllegalFileException();
  | 
      
      
        | 30 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 31 | 
        
            1496
         | 
        
            DarkViper
         | 
        /* -------------------------------------------------------- */
  | 
      
      
        | 32 | 
        
            1386
         | 
        
            Luisehahne
         | 
        // Include PHPMailer class
  | 
      
      
        | 33 | 
        
         | 
        
         | 
        require_once(WB_PATH."/include/phpmailer/class.phpmailer.php");
  | 
      
      
        | 34 | 
        
         | 
        
         | 
        
  | 
      
      
        | 35 | 
        
         | 
        
         | 
        class wbmailer extends PHPMailer
  | 
      
      
        | 36 | 
        
         | 
        
         | 
        {
 | 
      
      
        | 37 | 
        
         | 
        
         | 
        	// new websitebaker mailer class (subset of PHPMailer class)
  | 
      
      
        | 38 | 
        
         | 
        
         | 
        	// setting default values
  | 
      
      
        | 39 | 
        
         | 
        
         | 
        
  | 
      
      
        | 40 | 
        
         | 
        
         | 
        	function wbmailer() {
 | 
      
      
        | 41 | 
        
         | 
        
         | 
        		global $database;
  | 
      
      
        | 42 | 
        
         | 
        
         | 
        		// set mailer defaults (PHP mail function)
  | 
      
      
        | 43 | 
        
         | 
        
         | 
        		$db_wbmailer_routine = "phpmail";
  | 
      
      
        | 44 | 
        
         | 
        
         | 
        		$db_wbmailer_smtp_host = "";
  | 
      
      
        | 45 | 
        
         | 
        
         | 
        		$db_wbmailer_default_sendername = "WB Mailer";
  | 
      
      
        | 46 | 
        
         | 
        
         | 
        		$db_server_email = SERVER_EMAIL;
  | 
      
      
        | 47 | 
        
         | 
        
         | 
        
  | 
      
      
        | 48 | 
        
         | 
        
         | 
        		// get mailer settings from database
  | 
      
      
        | 49 | 
        
         | 
        
         | 
        		// $database = new database();
  | 
      
      
        | 50 | 
        
         | 
        
         | 
        		$query = "SELECT * FROM " .TABLE_PREFIX. "settings";
  | 
      
      
        | 51 | 
        
         | 
        
         | 
        		$results = $database->query($query);
  | 
      
      
        | 52 | 
        
         | 
        
         | 
        		while($setting = $results->fetchRow()) {
 | 
      
      
        | 53 | 
        
         | 
        
         | 
        			if ($setting['name'] == "wbmailer_routine") { $db_wbmailer_routine = $setting['value']; }
 | 
      
      
        | 54 | 
        
         | 
        
         | 
        			if ($setting['name'] == "wbmailer_smtp_host") { $db_wbmailer_smtp_host = $setting['value']; }
 | 
      
      
        | 55 | 
        
         | 
        
         | 
        			if ($setting['name'] == "wbmailer_smtp_auth") { $db_wbmailer_smtp_auth = (bool)$setting['value']; }
 | 
      
      
        | 56 | 
        
         | 
        
         | 
        			if ($setting['name'] == "wbmailer_smtp_username") { $db_wbmailer_smtp_username = $setting['value']; }
 | 
      
      
        | 57 | 
        
         | 
        
         | 
        			if ($setting['name'] == "wbmailer_smtp_password") { $db_wbmailer_smtp_password = $setting['value']; }
 | 
      
      
        | 58 | 
        
         | 
        
         | 
        			if ($setting['name'] == "wbmailer_default_sendername") { $db_wbmailer_default_sendername = $setting['value']; }
 | 
      
      
        | 59 | 
        
         | 
        
         | 
        			if ($setting['name'] == "server_email") { $db_server_email = $setting['value']; }
 | 
      
      
        | 60 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 61 | 
        
         | 
        
         | 
        
  | 
      
      
        | 62 | 
        
         | 
        
         | 
        		// set method to send out emails
  | 
      
      
        | 63 | 
        
         | 
        
         | 
        		if($db_wbmailer_routine == "smtp" AND strlen($db_wbmailer_smtp_host) > 5) {
 | 
      
      
        | 64 | 
        
         | 
        
         | 
        			// use SMTP for all outgoing mails send by Website Baker
  | 
      
      
        | 65 | 
        
         | 
        
         | 
        			$this->IsSMTP();
  | 
      
      
        | 66 | 
        
         | 
        
         | 
        			$this->Host = $db_wbmailer_smtp_host;
  | 
      
      
        | 67 | 
        
         | 
        
         | 
        			// check if SMTP authentification is required
  | 
      
      
        | 68 | 
        
         | 
        
         | 
        			if ($db_wbmailer_smtp_auth == "true" && strlen($db_wbmailer_smtp_username) > 1 && strlen($db_wbmailer_smtp_password) > 1) {
 | 
      
      
        | 69 | 
        
         | 
        
         | 
        				// use SMTP authentification
  | 
      
      
        | 70 | 
        
         | 
        
         | 
        				$this->SMTPAuth = true;     	  								// enable SMTP authentification
  | 
      
      
        | 71 | 
        
         | 
        
         | 
        				$this->Username = $db_wbmailer_smtp_username;  	// set SMTP username
  | 
      
      
        | 72 | 
        
         | 
        
         | 
        				$this->Password = $db_wbmailer_smtp_password;	  // set SMTP password
  | 
      
      
        | 73 | 
        
         | 
        
         | 
        			}
  | 
      
      
        | 74 | 
        
         | 
        
         | 
        		} else {
 | 
      
      
        | 75 | 
        
         | 
        
         | 
        			// use PHP mail() function for outgoing mails send by Website Baker
  | 
      
      
        | 76 | 
        
         | 
        
         | 
        			$this->IsMail();
  | 
      
      
        | 77 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 78 | 
        
         | 
        
         | 
        
  | 
      
      
        | 79 | 
        
         | 
        
         | 
        		// set language file for PHPMailer error messages
  | 
      
      
        | 80 | 
        
         | 
        
         | 
        		if(defined("LANGUAGE")) {
 | 
      
      
        | 81 | 
        
         | 
        
         | 
        			$this->SetLanguage(strtolower(LANGUAGE),"language");    // english default (also used if file is missing)
  | 
      
      
        | 82 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 83 | 
        
         | 
        
         | 
        
  | 
      
      
        | 84 | 
        
         | 
        
         | 
        		// set default charset
  | 
      
      
        | 85 | 
        
         | 
        
         | 
        		if(defined('DEFAULT_CHARSET')) {
 | 
      
      
        | 86 | 
        
         | 
        
         | 
        			$this->CharSet = DEFAULT_CHARSET;
  | 
      
      
        | 87 | 
        
         | 
        
         | 
        		} else {
 | 
      
      
        | 88 | 
        
         | 
        
         | 
        			$this->CharSet='utf-8';
  | 
      
      
        | 89 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 90 | 
        
         | 
        
         | 
        
  | 
      
      
        | 91 | 
        
            638
         | 
        
            thorn
         | 
        		// set default sender name
  | 
      
      
        | 92 | 
        
            1386
         | 
        
            Luisehahne
         | 
        		if($this->FromName == 'Root User') {
 | 
      
      
        | 93 | 
        
         | 
        
         | 
        			if(isset($_SESSION['DISPLAY_NAME'])) {
 | 
      
      
        | 94 | 
        
         | 
        
         | 
        				$this->FromName = $_SESSION['DISPLAY_NAME'];            // FROM NAME: display name of user logged in
  | 
      
      
        | 95 | 
        
         | 
        
         | 
        			} else {
 | 
      
      
        | 96 | 
        
         | 
        
         | 
        				$this->FromName = $db_wbmailer_default_sendername;			// FROM NAME: set default name
  | 
      
      
        | 97 | 
        
         | 
        
         | 
        			}
  | 
      
      
        | 98 | 
        
            638
         | 
        
            thorn
         | 
        		}
  | 
      
      
        | 99 | 
        
            1386
         | 
        
            Luisehahne
         | 
        
  | 
      
      
        | 100 | 
        
         | 
        
         | 
        		/*
  | 
      
      
        | 101 | 
        
         | 
        
         | 
        			some mail provider (lets say mail.com) reject mails send out by foreign mail
  | 
      
      
        | 102 | 
        
         | 
        
         | 
        			relays but using the providers domain in the from mail address (e.g. myname@mail.com)
  | 
      
      
        | 103 | 
        
         | 
        
         | 
        		*/
  | 
      
      
        | 104 | 
        
         | 
        
         | 
        		$this->From = $db_server_email;                           // FROM MAIL: (server mail)
  | 
      
      
        | 105 | 
        
         | 
        
         | 
        
  | 
      
      
        | 106 | 
        
         | 
        
         | 
        		// set default mail formats
  | 
      
      
        | 107 | 
        
         | 
        
         | 
        		$this->IsHTML(true);
  | 
      
      
        | 108 | 
        
         | 
        
         | 
        		$this->WordWrap = 80;
  | 
      
      
        | 109 | 
        
         | 
        
         | 
        		$this->Timeout = 30;
  | 
      
      
        | 110 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 111 | 
        
         | 
        
         | 
        }
  |