Jump to content

stoneyrose

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Posts posted by stoneyrose

  1. this does not do, what you think it does:

     

    $this->fileContents = str_replace($this->row['searchValue'], eval($this->row['replaceValue']), $this->fileContents);

     

    this is supposed to simply fill the property "fileContents", right? It doesn't. It immediately executes the php code. That's why it turns up at the beginning of the file. You need to get rid of the eval at this place.

     

    I bet you have a different place where you echo "fileContents"? This is where you need to make the distinction between eval and echo. Perhaps make "fileContents" an array and add one entry each time your loop runs. you can loop through it at a later point and decide to either echo or eval the entry.

     

    Bjom

     

    Thanks, that's what I wanted to know and you are quite correct about the echo being later on.

  2. 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.

  3. 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  :rtfm: .

     

    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

  4. 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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.