stoneyrose
-
Posts
9 -
Joined
-
Last visited
Never
Posts posted by stoneyrose
-
-
-
Yep, these are the two that are being used...
searchValue --- replaceValue --- isPHP
{test:QWERTY} --- qwerty qwerty qwerty success! --- 0
{test:PHP} --- echo 'It Works!'; ?> --- 1
-
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.
-
What do you want the code or the output?
-
Hi all, I've been trying in vain to make the following work correctly and can't for the life of me find anything in .
I'm making a template engine (can't dump the project and use Smarty) from the ground up and it's working by replacing keywords in a html file like
{phpfreaks::isgreat}
with either HTML output or PHP using echo or eval respectively. The database table rows are marked accordingly so no problems there until I examine the output, where I find that eval has worked correctly but instead of putting it where the old keyword was it places it at the very beginning, what am I doing wrong and how can I work around it to get the evaluated PHP code where it should be.
Thanks
-
Thanks very much and I apologize for the double post, the app targets users in the private aviation sector - as it's quite a niche market and I am still in the very early stages I would rather not say more, thanks again for the help.
-
Hi all, I am in the beginning stages of putting together a web based application that once complete will be available for sale, of course one of my concerns is people pirating the software. I have had a couple of ideas as to how to prevent pirating but I can see flaws in all of them, what i'm looking for is a way for the script to connect to a database on my end and validate the products key.
What's the best way for me to go about this?
Thanks in advance.
[SOLVED] Creating a template engine: Using Echo and eval() side-by-side
in PHP Coding Help
Posted
Thanks, that's what I wanted to know and you are quite correct about the echo being later on.