Location: PHPKode > projects > Bloggie Lite > includes/classes.php
<?

///Coded by : Sean myWebland.com
/// simple template for email notification

// Copyright (C) Bloggie Lite Written by : Sean
// http://www.mywebland.com , http://mybloggie.mywebland.com

// You are requested to retain this copyright notice in order to use
// this software.

//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

class email  {

    var $msg ;
    function assign_vars($vars)  {
      $this->vars = (empty($this->vars)) ? $vars : $this->vars . $vars;
    }

    function parse($msg) {
    $msg = str_replace ("'", "\'", $msg);
    $msg = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "' . $\\1 . '", $msg);

    reset ($this->vars);
    while (list($key, $val) = each($this->vars)) {
            $$key = $val;
    }
    @eval("\$msg = '$msg';");
    return  $msg  ;
   }

   function stemplate($template)  {
        global $pref_data, $bloggie_root_path;

        if (empty($this->msg_tpl[$template]))
        {
            $tpl = './language/' . $template . '.tpl';
            if (!@file_exists(@realpath($tpl_file)))
            {
                $tpl = './language/' . $template . '.tpl';
                if (!@file_exists(@realpath($tpl)))
                {
                    error("Error", "Template file not found");
                }
            }
            if (!($fd = @fopen($tpl, 'r')))
            {
                error("Error", 'Failed opening template file ');
               // echo  'Failed opening template file';
            }
            $this->msg_tpl[$template] = fread($fd, filesize($tpl));
            fclose($fd);
        }
        $this->msg = $this->msg_tpl[$template];
        //echo $this->msg;
        return true;
    }

   function sendmail($reply_to, $from, $to, $date, $subject, $msg ) {
         global $pref_data;
          $this->headers  = (($reply_to != '') ? "Reply-to: $reply_to\n" : '');
          $this->headers .= (($from != '') ? "From: $from\n" : "From: " . $pref_data . "\n");
          $this->headers .= "Return-Path: " . $pref_data['email'] . "\n";
          $this->headers .= "MIME-Version: 1.0\n";
          $this->headers .= "Content-type: text/plain; charset=" . $pref_data['encoding'] . "\n";
          $this->headers .= "Content-transfer-encoding: 8bit\nDate: " . date('r', time()) . "\n";
          $this->headers .= "X-Priority: 3\n";
          $this->headers .= "X-MSMail-Priority: Normal\n";
          $this->headers .= "X-Mailer: PHP\n";
          $this->headers .= "X-MimeOLE: Bloggie Lite\n";
          $result = mail( $to, $subject, $msg, $this->headers );
          if( $result ) return true;
   }
}

class link_modifier {

    function assign_vars($vars)  {
     // $this->vars = (empty($this->vars)) ? $vars : $this->vars . $vars;
        $this->vars = $vars;
    //print_r($this->vars);
    }

    function parse($link_format) {

    $link_format = str_replace ("'", "\'", $link_format);
    $link = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "' . $\\1 . '", $link_format);
//    echo $link;
    reset ($this->vars);

    while (list($key, $val) = each($this->vars)) {
        $$key = $val; //echo $val;
    }
    @eval("\$link = '$link';");

    reset ($this->vars);
    while (list($key, $val) = each($this->vars)) {
       unset($$key);
    }

    return  $link  ;
   }

}

?>
Return current item: Bloggie Lite