Heres the code, the first loop searches and replaces HTML and the second PHP.
//Search and replace template terms that are not PHP
$this->res = mysql_query("select * from " . PRE . "confTemplateEngine where isPHP='0'");
while($this->row = mysql_fetch_array($this->res))
{
$this->fileContents = str_replace($this->row['searchValue'], $this->row['replaceValue'], $this->fileContents);
}
//Search for markup used to generate PHP, then eval them and return to fileContents
$this->res = mysql_query("select * from " . PRE . "confTemplateEngine where isPHP='1'");
while($this->row = mysql_fetch_array($this->res))
{
$this->fileContents = str_replace($this->row['searchValue'], eval($this->row['replaceValue']), $this->fileContents);
}
The output source is this...
It Works!<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background-color: #F00;
}
#apDiv1 {
position:absolute;
width:200px;
height:115px;
z-index:1;
left: 224px;
top: 56px;
background-color: #00CCFF;
}
.sfg {
font-weight: bold;
font-family: "Lucida Console", Monaco, monospace;
font-size: 24px;
}
#apDiv2 {
position:absolute;
width:435px;
height:115px;
z-index:2;
left: 582px;
top: 183px;
}
-->
</style></head>
<body>
<div id="apDiv1">qwerty qwerty qwerty success!</div>
<p class="sfg"> </p>
<p class="sfg"> </p>
<p class="sfg">qwerty qwerty qwerty success!
</p>
<p class="sfg"> </p>
<p class="sfg">qwerty qwerty qwerty success!</p>
<div id="apDiv2"></div>
</body>
</html>
The "qwerty qwerty qwerty ect" is a successful HTML replace (for example in its place was {qwerty} and it successfully changed it and placed it in the correct location. However the "It Works!" at the top of the page is evaluated code that should be inside "<div id="apDiv2"></div>" where the original "{php::itworks}" was.