#1
  1. Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    16
    Rep Power
    0

    Post Advanced Search and Replace or remote file


    Right, let me give you the background:

    i have a file with a list of words in the format of lookfor|replace with

    eg

    a|b
    c|d

    I need some code which will grab a remote file, eg www.somesite.com/somedir/site.html

    perform the replacements, and spew out the results on the local server

    further, i need it to skip any code such as javascript/html tags, embeded flash files

    i dont want the images downloaded to the local server so image urls need to be modified so they point to the file on the remote server, eg images/image.gif would be changed to www.somesite.com/somedir/images/image.gif

    i also need the ability to change links in the same way!

    if you have anything that can do this let me know!

    Thanks

    Tom
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,643
    Rep Power
    4248
    Is this for your cockneyizer site? Why don't you show us what you've got so far? Just out of curiosity, does it have to be C/C++ or can it be any language?
  4. #3
  5. Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    16
    Rep Power
    0
    could be ;)

    ive got it sort of working in php, but id prefer it in C because it would be far more efficient

    Code:
    <?PHP
    $input = implode("", file($file));
    
    include('dictionary.inc.php');
      while(list($text,$image) = each($replace)){
       $patterns[0] = "//src=\"..//";
       $replacements[0] = "//src=\"$file//";
    
       $input = preg_replace($patterns, $replacements, $input);
       $input = str_replace($text, $image, $input);
      }
      echo $input;
    ?>

IMN logo majestic logo threadwatch logo seochat tools logo