Code that grabs tags from another page and replace

Discussion in 'PHP' started by Nefarious, Jun 15, 2006.

  1. #1
    Hello all, and thank you for reading the post! hehe

    Well, I'm using an article script that is encrypted with ioncube. With that I cannot add custom php stuff like includes and so forth. Well some have come up with a way to use custom php in encrypted pages.

    This is some code that works. It works by replacing a string in the templates with an include. What I want to know is how much strain does it put on the server for each page view, double,triple, etc.

    
    <?php
    ob_start();
    include 'ad_index.php'; //this is the encoded ioncube page
    $page = ob_get_contents();
    ob_end_clean();
    
    ob_start();
    include 'ads01.php'; //just a sample echo line
    $ads1 = ob_get_contents();
    ob_end_clean();
    
    ob_start();
    include 'ads02.php'; //just a sample echo line
    $ads2 = ob_get_contents();
    ob_end_clean();
    
    ob_start();
    include 'navads.php'; //just a sample scho line
    $navads = ob_get_contents();
    ob_end_clean();
    
    $newpage = str_replace( "** ADS01 **", $ads1, $page );
    $newpage = str_replace( "** ADS02 **", $ads2, $newpage );
    $newpage = str_replace( "** NAVADS **", $navads, $newpage );
    
    echo $newpage;
    ?>
    
    Code (markup):
    With that code it goes through each variable replacing the string, or at least tries to even though it might not be there.

    I was thinking of possibly adding in some sort of if statement on the first include(the initial main page) to check for the actual strings, if they are present then do the replacing.

    This is what I want to do and try to get it as optimized as I can this little piece of code so it doesn't add too much strain, I know its going to add some since its processing more.

    The other option I have is to drop the script, lose the pages I have in SEs and start over. With google acting up (my pages are constantly jumping around from 10k>32>10k>500>400) maybe I should just switch to a non-encoded script.
     
    Nefarious, Jun 15, 2006 IP
  2. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The only way to get a sense of the impact of this script on load time is to run each multiple times and time the event. For instance, create a script to retrrieve 10, 20, 50, 100 instances of the page under each scenario and have it time the process. This will give you a sense of how much more effoirt your machine is going to put into serving pages.

    In this case, there is no advantage to seeing if something is present on a page in order to decide whether or not to replace it. Either way, the program needs to search the entire body of text to first find the text and then to find the text and do an in memory replacement. The only time it might make sense is if the text you were replacing always had common elements, such as the asterixes in your post, and many pages do not contain this common element.

    BTW, you might be able to optimize the replacements with arrays.

    The issue you raise about migrating and its effect on SERPs is an interesting one. This is a potential issue with moving from one CMS to another. The key is to initially convert all CMSes so they display pages in SE friendly ways -- something all CMS writers should have done from the start by default IMHO -- and then coax future ones yo use the identical directory structure and keep the old file names intact. Then, old search results for the pages will never wear out.
     
    clancey, Jun 16, 2006 IP