2011-10-12 13:03:17 +00:00
|
|
|
<?php
|
|
|
|
class EmailText{
|
|
|
|
|
|
|
|
var $tmpid;
|
|
|
|
var $db;
|
|
|
|
var $data;
|
2011-10-13 09:09:42 +00:00
|
|
|
var $tmpinfo;
|
2011-10-12 13:03:17 +00:00
|
|
|
|
|
|
|
function __construct()
|
|
|
|
{
|
2011-10-13 07:52:05 +00:00
|
|
|
if(empty($this->tmpid))
|
2011-10-12 13:03:17 +00:00
|
|
|
{
|
|
|
|
$this->tmpid = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-13 09:09:42 +00:00
|
|
|
public function getinfo(){
|
|
|
|
|
|
|
|
if(is_numeric($this->tmpid))
|
|
|
|
$sql = "select * from emailtext where id='".$this->tmpid."'";
|
|
|
|
else
|
|
|
|
$sql = "select * from emailtext where template='".$this->tmpid."'";
|
|
|
|
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
|
|
|
|
$this->tmpinfo = $rs->fetch();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-10-12 13:03:17 +00:00
|
|
|
public function loadtmp(){
|
|
|
|
|
|
|
|
if(empty($this->tmpid))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}else{
|
|
|
|
|
2011-10-13 09:09:42 +00:00
|
|
|
$this->getinfo();
|
|
|
|
|
|
|
|
$c = $this->tmpinfo;
|
|
|
|
|
2011-10-12 13:03:17 +00:00
|
|
|
if(!empty($c['id']))
|
|
|
|
{
|
|
|
|
if(count($this->data)==0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$patterns = array();
|
|
|
|
$replacements = array();
|
|
|
|
foreach($this->data as $k=>$v)
|
|
|
|
{
|
|
|
|
$patterns[]='/{'.$k.'}/i';
|
|
|
|
$replacements[]=$v;
|
|
|
|
}
|
|
|
|
ksort($patterns);
|
|
|
|
ksort($replacements);
|
|
|
|
$newString=preg_replace($patterns, $replacements, $c['body']);
|
|
|
|
return $newString;
|
|
|
|
}//count($this->data)
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}//empty($this->tmpid)
|
|
|
|
}//function loadtmp
|
|
|
|
}
|