Thread: Basic Php Proxy

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    69
    Rep Power
    1

    Question Basic Php Proxy


    Ladies & Gentlemen,
    My Fellow Buddy programmers and would be buddy programmers!

    Watching the following youtube tutorial I built a basic php proxy but for some reason it is not working.
    Can you guess why ?
    The clip uses the deprecated ereg_replace and so I replaced it with preg but no luck.

    https://www.youtube.com/watch?v=P49w0E64MAA

    I get a long list of these 2 same errors over and over again.

    Warning: preg_replace(): No ending matching delimiter '>' found in C:\xampp\htdocs\e_id\proxy.php on line 9

    Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in C:\xampp\htdocs\e_id\proxy.php on line 10

    And sometimes I get another error instead and all without changing the code:

    Parse error: syntax error, unexpected 'action' (T_STRING), expecting ',' or ')' in C:\xampp\htdocs\e_id\proxy.php on line 10

    PHP Code:

    <?php

    $url 
    "http://www.google.com";
    $page file($url);

    foreach(
    $page as $part)
    {
        
    $part preg_replace('<img src=','<img src='.$url,$part);
    $part preg_replace('action="','action="'.$url,$part);

    echo 
    $part;

    }

    ?>
  2. #2
  3. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,264
    Rep Power
    2039
    preg_replace needs the first parameter to be a Regular Expression, not a standard string. For what you're doing you should be using str_replace instead of preg_replace.

IMN logo majestic logo threadwatch logo seochat tools logo