FilePath = $F; return 0; } else { return -1; } } function AddVar($VN, $RL = 'null') { $this->VarList[] = "{$VN}\x01{$RL}"; return 0; } function DelVar($VN, $RL = 'null') { if (array_key_exists("$VN\x01$RL", $this->VarList)) { foreach ($this->VarList as $del) { if (!strstr("$VN\x01$RL", $del)) { $lcp[] = $del; } } for ($x = 0; $x < count($this->VarList); $x++) { $this->VarList[$x] = null; } for ($x = 0; $x < count($lcp); $x++) { $this->VarList[$x] = $lcp[$x]; } unset($lcp, $del, $x); } else { return -1; } } function SetTemplate($file) { if (is_file($file)) { $this->FilePath = $file; return 0; } else { return -1; } } function VarExists($VN) { if (is_file($this->FilePath)) { $this->FileContent = file_get_contents($this->FilePath); if (preg_match("/\{{$VN}\}/", $this->FileContent)) { return 0; } else { return 1; } } else { return -1; } } function Display() { if (is_file($this->FilePath)) { $this->FileContent = file_get_contents($this->FilePath); foreach ($this->VarList as $list) { $list = explode("\x01", $list, 2); $VNS[] = "{{$list[0]}}"; $RLS[] = $list[1]; } $content = str_replace($VNS, $RLS, $this->FileContent); if (preg_match_all("/\[(.*)\]/", $content, $match)) { for ($x = 0; $x < count($match[1]); $x++) { ob_start(); eval($match[1][$x]); $repl[$x] = ob_get_contents(); ob_end_clean(); } for ($x = 0; $x < count($match[1]); $x++) { $match[1][$x] = "[{$match[1][$x]}]"; } $content = str_replace($match[1], $repl, $content); } return $content; } else { return -1; } } } ?>