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

    Join Date
    Jan 2017
    Posts
    307
    Rep Power
    1
    Sedopati,

    I know the difference between GET, POST and REQUEST. But, I am still raw at php and forget things or don't notice things as usual.
    Last edited by UniqueIdeaMan; July 1st, 2017 at 09:27 AM.
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    307
    Rep Power
    1
    Folks,

    Can anyone spot any errors on the following cURL code ?
    Unless you run it on your xampp/wamp, it might be difficult to figure-out what it does and how it is supposed to work.

    Imagine it is a mini web proxy.
    When you load the page, you will see a text box labeled: Url.
    Now type: 301 Moved.
    And click the button: submit.
    Note: Button uses GET method.

    You will now arrive at proxified page google: **301 Moved Permanently

    So far so good.
    Now, when you search google (proxified page), you will get reverted back to the first page that shows the text box with the label: Url.
    Why is this loop occurring instead of google showing you your keywords search result ?

    PHP Code:

    <?php

    $conn 
    mysqli_connect("localhost""root""""id");

    if (!
    $conn) {
        
    // message to use in development to see errors
        
    die("Database error : " mysqli_error($conn));

        
    // user friendly message
        // die("Database error.");
        
    exit();
    }

    ?>

    <html>
       <body>   
          <form action = "<?php $_PHP_SELF ?>" method = "GET">
             Url: <input type = "text" name = "url_to_proxify" />
                  <input type = "submit" />
          </form>      
       </body>
    </html>


    <?php

    /*
    ERROR HANDLING
    */
    ini_set('display_errors'1);
    ini_set('display_startup_errors'1);

    //For All Error, Warning and Notice
    error_reporting(E_ALL) OR error_reporting(-1);
    //For All Errors
    error_reporting(E_ERROR);
    //For All Warnings
    error_reporting(E_WARNING);
    //For All Notice
    error_reporting(E_NOTICE);

    error_reporting(E_ALL);

    if(isset(
    $_GET["url_to_proxify"]) === TRUE)
       {
            
    $url_to_proxify filter_input(INPUT_GET'url_to_proxify'FILTER_VALIDATE_URL);
            
            
    $ch curl_init();
            
    curl_setopt($chCURLOPT_URL"$url_to_proxify");
            
    curl_setopt($chCURLOPT_FOLLOWLOCATIONTRUE);
            
    curl_setopt($chCURLOPT_HEADER5);
            
    curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
            
    $curl_result curl_exec($ch);
            
            
    $domain parse_url($url_to_proxifyPHP_URL_HOST);
            
            
    //eg: $pattern = array("./", "https://www.", "http://www.", "https://", "http://", "www.");
            
    $pattern = array("./""https://www.""http://www.""https://""http://""www.");
            
    $replace = array("proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'""proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'""proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'""proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'""proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'""proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'");
            
    $string_replaced_data str_replace($pattern$replace$curl_result);
            
            
    //Deal with Google Img File
            
    $preg_replaced_data preg_replace('/src="/''src="'.$domain.$url_to_proxify$string_replaced_data);
            
            
    //Deal with data presented by google search
            
    $preg_replaced_data preg_replace('/action="/''action="proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'"'$string_replaced_data);
            
            echo 
    $preg_replaced_data;
            
            
    curl_close($ch);        
        }

    ?>
    Which part of the code will you change and to what will you change it to ?
    I have a feeling that, this is a GET and POST miss-match issue somewhere. Right ? The POST issue is during the google search. That much I have a clue. Lol!
    Last edited by UniqueIdeaMan; July 1st, 2017 at 09:28 AM.
  4. #18
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,810
    Rep Power
    4536
    There are no errors in your code. Well, none that I care to look for or that are related to this issue.

    The "proxied" form is submitting to EXACTLY the page you've told it to submit to. GET or POST doesn't make a difference in this case. If you want to be a programmer, sometimes you have to look at the HTML source of the page your PHP script created to understand what's going on.

    That much I have a clue.
    lol, no. You're short on that, still.
    -- Cigars, whiskey and wild, wild women. --
  6. #19
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2016
    Location
    Lakewood, WA
    Posts
    207
    Rep Power
    17
    I would avoid using GET for form input unless you really need to.
  8. #20
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    307
    Rep Power
    1
    Php Mates,

    Try this script out. Upload it on your website. And, load the page on your browser.
    On the text box, type: 301 Moved.
    Then, click "submit" button.
    When Google homepage loads, do a keyword search for: cars.
    You will see Google shows you a dead link.
    Eg.
    http://yourdomain.com/search?ie=ISO-...e+Search&gbv=2

    It should've shown the url like this:
    http://yourdomain.com**/proxified_pa...e+Search&gbv=2

    Why is the highlighted parts missing from the url to where you are redirected to ?

    PHP Code:


    <?php

    //STEP 1: ERROR HANDLING

    ini_set('display_errors'1);
    ini_set('display_startup_errors'1);

    //For All Error, Warning and Notice
    error_reporting(E_ALL) OR error_reporting(-1);
    //For All Errors
    error_reporting(E_ERROR);
    //For All Warnings
    error_reporting(E_WARNING);
    //For All Notice
    error_reporting(E_NOTICE);

    error_reporting(E_ALL);


    // STEP 2: Database connection

    $conn mysqli_connect("localhost""root""""id");

    if (!
    $conn) {
        
    // message to use in development to see errors
        
    die("Database error : " mysqli_error($conn));

        
    // user friendly message
        // die("Database error.");
        
    exit();
    }


    /* STEP 3:
    The IF gets triggered as soon as the "submit" button is clicked in the text box labeled: Url
    Following IF code deals wih GET method
    */

    if(isset($_GET["url_to_proxify"]) === TRUE)
       {
            
    $url_to_proxify filter_input(INPUT_GET'url_to_proxify'FILTER_VALIDATE_URL);
            
            
    $ch curl_init();
            
    curl_setopt($chCURLOPT_URL"$url_to_proxify");
            
    curl_setopt($chCURLOPT_FOLLOWLOCATIONTRUE);
            
    curl_setopt($chCURLOPT_HEADER5);
            
    curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
            
    $curl_result curl_exec($ch);
            
            
    $domain parse_url($url_to_proxifyPHP_URL_HOST);
            
            
    //eg: $pattern = array("./", "https://www.", "http://www.", "https://", "http://", "www.");
            
    $pattern = array("./""https://www.""http://www.""https://""http://""www.");
            
    $replace = array("proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'""proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'""proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'""proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'""proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'""proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'");
            
    $string_replaced_data str_replace($pattern$replace$curl_result);
            
            
    //Deal with Image Files (Eg. Google Img File)
            
    $string_replaced_data str_replace('/src="/''src="'.$domain.$url_to_proxify$string_replaced_data);
            
            
    //Deal with all the links presented by the searchengine result pages (SERPS). Eg. Google Search
            
    $string_replaced_data str_replace('/action="/''action="proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'"'$string_replaced_data);
            echo 
    $string_replaced_data;
            
            
    curl_close($ch);        
        }
    else
        {    
            
            
    //Html Form
            
    ?>
            <html>
                <body>   
                    <form action = "<?php $_SERVER['PHP_SELF'?>" method = "GET">
                    Url: <input type = "text" name = "url_to_proxify" />
                    <input type = "submit" />
          </form>      
       </body>
    </html>
    <?php
        
    }

    ?>
    Any idea what is wrong ? Also, any suggestions ?
  10. #21
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    307
    Rep Power
    1
    Originally Posted by Sepodati
    There are no errors in your code. Well, none that I care to look for or that are related to this issue.

    The "proxied" form is submitting to EXACTLY the page you've told it to submit to. GET or POST doesn't make a difference in this case. If you want to be a programmer, sometimes you have to look at the HTML source of the page your PHP script created to understand what's going on.


    lol, no. You're short on that, still.
    The problem is, I'm not programming my script to cURL/fetch a single or a handful of pages. Infact, I don't know what pages the users will fetch. Hence, need a general code. The user is shown a text box labeled "Url". The script will fetch whatever page their url belongs to.
    I can later-on turn this into a web proxy. That is my target as of now. But, like I say, I try living upto my Username and so a few ideas have crept in my mind on the spot just now while I write this post. Later-on, I can build a tool that:

    * sees or displays the page's meta tags (good to check your competitions meta tags);
    * checks whether the page has dofollow status (handy for link builders);
    * extract emails;
    * and so on.

    Yes, yes. These tools already exist but it's fun to build your own and use it than buy from others'.

    My problem as of now is, why the following codes are failing to do their jobs:

    PHP Code:

    //Deal with Img Files 
            
    $preg_replaced_data preg_replace('/src="/''src="'.$domain.$url_to_proxify$string_replaced_data); 
    PHP Code:

    //Deal with all the links presented by the searchengine result pages (SERPS). Eg. Google Search 
            
    $string_replaced_data str_replace('/action="/''action="proxified_page_2.php?url_to_proxify='.$domain.$url_to_proxify.'"'$string_replaced_data); 
            echo 
    $string_replaced_data
    Last edited by UniqueIdeaMan; July 6th, 2017 at 07:25 AM.
  12. #22
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    307
    Rep Power
    1
    Folks,

    Why am I getting this error ?

    Parse error: syntax error, unexpected '=', expecting ')' in C:\xampp\htdocs\id\proxified_page_2.php on line 58

    PHP Code:


    <?php

    //STEP 1: ERROR HANDLING

    ini_set('display_errors'1);
    ini_set('display_startup_errors'1);

    //For All Error, Warning and Notice
    error_reporting(E_ALL) OR error_reporting(-1);
    //For All Errors
    error_reporting(E_ERROR);
    //For All Warnings
    error_reporting(E_WARNING);
    //For All Notice
    error_reporting(E_NOTICE);

    error_reporting(E_ALL);


    // STEP 2: Database connection

    $conn mysqli_connect("localhost""root""""e-id");

    if (!
    $conn) {
        
    // message to use in development to see errors
        
    die("Database error : " mysqli_error($conn));

        
    // user friendly message
        // die("Database error.");
        
    exit();
    }


    /* STEP 3:
    The IF gets triggered as soon as the "submit" button is clicked in the text box labeled: Url
    Following IF code deals wih GET method
    */

    if(isset($_GET["url_to_proxify"]) === TRUE)
       {
            
    $url_to_proxify filter_input(INPUT_GET'url_to_proxify'FILTER_VALIDATE_URL);
            
            
    $ch curl_init();
            
    curl_setopt($chCURLOPT_URL"$url_to_proxify");
            
    curl_setopt($chCURLOPT_FOLLOWLOCATIONTRUE);
            
    curl_setopt($chCURLOPT_HEADER5);
            
    curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
            
    $curl_result curl_exec($ch);
            
            
    $domain parse_url($url_to_proxifyPHP_URL_HOST);
            
            
    $pattern = array("./""https://""http://");
            
    $replace = array("proxified_page_2.php?url_to_proxify=./""proxified_page_2.php?url_to_proxify=https://""proxified_page_2.php?url_to_proxify=http://");
            
    $string_replaced_data str_replace($pattern$replace$curl_result);
            
            
    //Deal with Image Files (Eg. Google Img File)        
            
    $pattern = array("/ src="/", "src ", "src"/""/ src ="" /src="/", " /src "/"" /src= "/", " /src="/""/ src='/""/ src = '/""/ src= '/"" / src='/",  " /src='/"" /src = '/"" /src= '/"" /src='/");
            
    $replace = array("proxified_page_2.php?url_to_proxify=/ src="/", "proxified_page_2.php?url_to_proxify=/ src ", "proxified_page_2.php?url_to_proxify=/ src"/""proxified_page_2.php?url_to_proxify=/ src =""proxified_page_2.php?url_to_proxify= /src="/", "proxified_page_2.php?url_to_proxify= /src "/""proxified_page_2.php?url_to_proxify= /src= "/", "proxified_page_2.php?url_to_proxify= /src="/""proxified_page_2.php?url_to_proxify=/ src='/""proxified_page_2.php?url_to_proxify=/ src = '/""proxified_page_2.php?url_to_proxify=/ src= '/""proxified_page_2.php?url_to_proxify= / src='/",  "proxified_page_2.php?url_to_proxify= /src='/""proxified_page_2.php?url_to_proxify= /src = '/""proxified_page_2.php?url_to_proxify= /src= '/""proxified_page_2.php?url_to_proxify= /src='/");
            
    $string_replaced_data str_replace($pattern$replace$curl_result);
            
            
    //Deal with all the links presented by the searchengine result pages (SERPS). Eg. Google Search Pages (SERPs)
            
    $pattern = array("/ action="/", "action ", "action"/""/ action ="" /action="/", " /action "/"" /action= "/", " /action="/""/ action='/""/ action = '/""/ action= '/"" / action='/",  " /action='/"" /action = '/"" /action= '/"" /action='/");
            
    $replace = array("proxified_page_2.php?url_to_proxify=/ action="/", "proxified_page_2.php?url_to_proxify=/ action ", "proxified_page_2.php?url_to_proxify=/ action"/""proxified_page_2.php?url_to_proxify=/ action =""proxified_page_2.php?url_to_proxify= /action="/", "proxified_page_2.php?url_to_proxify= /action "/""proxified_page_2.php?url_to_proxify= /action= "/", "proxified_page_2.php?url_to_proxify= /action="/""proxified_page_2.php?url_to_proxify=/ action='/""proxified_page_2.php?url_to_proxify=/ action = '/""proxified_page_2.php?url_to_proxify=/ action= '/""proxified_page_2.php?url_to_proxify= / action='/",  "proxified_page_2.php?url_to_proxify= /action='/""proxified_page_2.php?url_to_proxify= /action = '/""proxified_page_2.php?url_to_proxify= /action= '/""proxified_page_2.php?url_to_proxify= /action='/");
            
    $string_replaced_data str_replace($pattern$replace$curl_result);
            
            echo 
    $string_replaced_data;        
            
    curl_close($ch);        
        }
    else
        {            
            
    //Html Form
            
    ?>
            <html>
                <body>   
                    <form action = "<?php $_SERVER['PHP_SELF'?>" method = "GET">
                    Url: <input type = "text" name = "url_to_proxify" />
                    <input type = "submit" />
          </form>      
       </body>
    </html>
    <?php
        
    }

    ?>

    I'm not programming my script to cURL/fetch a single or a handful of pages. Infact, I don't know what pages the users will fetch. Hence, need a general code. The user is shown a text box labeled "Url". The script will fetch whatever page their url belongs to.
    I am trying to precede the following on all links present on the page cURL fetches:

    proxified_page_2.php?url_to_proxify=http://

    The script file is: proxified_page_2.php
    Last edited by UniqueIdeaMan; July 13th, 2017 at 07:35 AM.
  14. #23
  15. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,810
    Rep Power
    4536
    Originally Posted by UniqueIdeaMan
    Why am I getting this error ?
    Because you have no ****ing clue how strings work in PHP.

    PHP Code:
    $pattern = array("/ src="/", "src ", "src"/""/ src ="" /src="/", " /src "/"" /src= "/", " /src="/""/ src='/""/ src = '/""/ src= '/"" / src='/",  " /src='/"" /src = '/"" /src= '/"" /src='/"); 
    What kind of **** ****ing editor do you use that doesn't highlight the crap out of that horribly incorrect code?

    Play along for a second.

    PHP Code:
    $string "Why is there a ****ing " in the middle of the string?"; 
    How the **** do you expect PHP to understand that? It's a programming language with rules that you obviously have no care to learn.

    -John
    -- Cigars, whiskey and wild, wild women. --
  16. #24
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    307
    Rep Power
    1
    Originally Posted by Sepodati
    Because you have no ****ing clue how strings work in PHP.

    PHP Code:
    $pattern = array("/ src="/", "src ", "src"/""/ src ="" /src="/", " /src "/"" /src= "/", " /src="/""/ src='/""/ src = '/""/ src= '/"" / src='/",  " /src='/"" /src = '/"" /src= '/"" /src='/"); 
    What kind of **** ****ing editor do you use that doesn't highlight the crap out of that horribly incorrect code?

    Play along for a second.

    PHP Code:
    $string "Why is there a ****ing " in the middle of the string?"; 
    How the **** do you expect PHP to understand that? It's a programming language with rules that you obviously have no care to learn.

    -John
    Johny Boy,

    FYI: I use Notepad++ latest.

    I have more clue than you, I'm afraid!

    The img files come in these formats ...

    src = "directory/file.jpg". (dbl quotes)
    src = 'directory/file.jpg'. (sngl quotes)

    And, I'm trying to replace the highlighted parts above. That includes the single and double quotes. Therefore, trying to replace the " and the ' too. Atleast, have you ****ing got that yet ?

    Also, note the spaces prior and after the forward slashes. I hope you have the ****ing sense to understand that too. Otherwise, either buy yourself a new pair of glasses or a double large magnifying glass for twits.

    PS - Rename your Username to "Mr ****ing" since you can't live without that word.
    Last edited by UniqueIdeaMan; July 15th, 2017 at 08:44 AM.
  18. #25
  19. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,810
    Rep Power
    4536
    That's a lot of words for you still not understanding how strings work.

    Have you fixed this line, yet?

    PHP Code:
    $pattern = array("/ src="/", "src ", "src"/""/ src ="" /src="/", " /src "/"" /src= "/", " /src="/""/ src='/""/ src = '/""/ src= '/"" / src='/",  " /src='/"" /src = '/"" /src= '/"" /src='/"); 
    -- Cigars, whiskey and wild, wild women. --
  20. #26
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    307
    Rep Power
    1
    Originally Posted by Sepodati
    That's a lot of words for you still not understanding how strings work.

    Have you fixed this line, yet?

    PHP Code:
    $pattern = array("/ src="/", "src ", "src"/""/ src ="" /src="/", " /src "/"" /src= "/", " /src="/""/ src='/""/ src = '/""/ src= '/"" / src='/",  " /src='/"" /src = '/"" /src= '/"" /src='/"); 
    Well atleast you are showing some concerns without using bad language. I hiope you stay that way without showing any tantrums.
    And nah, I haven't been able to fix it yet.
    Here is the original code from youtube video:

    PHP Code:

    <?php

    /*
    ERROR HANDLING
    */
    ini_set('display_errors'1);
    ini_set('display_startup_errors'1);

    //For All Error, Warning and Notice
    error_reporting(E_ALL) OR error_reporting(-1);
    //For All Errors
    error_reporting(E_ERROR);
    //For All Warnings
    error_reporting(E_WARNING);
    //For All Notice
    error_reporting(E_NOTICE);

    error_reporting(E_ALL);

    //Below code from Basic Php Proxy Video and fix from: https://stackoverflow.com/questions/22255241/preg-replace-no-ending-matching-delimiter-gt/22255455#22255455
    //https://www.youtube.com/watch?v=P49w0E64MAA

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

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

    echo 
    $part;

    }

    ?>
    Note that, the youtube video was using ereg_replace. I switched it to preg_replace.
    So, as you can see, that concerned line of our's, really originates from the youtube video. I just derived a bit more out of it.

    The following is my latest derivation:

    PHP Code:


    <?php

    //STEP 1: ERROR HANDLING

    ini_set('display_errors'1);
    ini_set('display_startup_errors'1);

    //For All Error, Warning and Notice
    error_reporting(E_ALL) OR error_reporting(-1);
    //For All Errors
    error_reporting(E_ERROR);
    //For All Warnings
    error_reporting(E_WARNING);
    //For All Notice
    error_reporting(E_NOTICE);

    error_reporting(E_ALL);


    // STEP 2: Database connection

    $conn mysqli_connect("localhost""root""""e-id");

    if (!
    $conn) {
        
    // message to use in development to see errors
        
    die("Database error : " mysqli_error($conn));

        
    // user friendly message
        // die("Database error.");
        
    exit();
    }


    /* STEP 3:
    The IF gets triggered as soon as the "submit" button is clicked in the text box labeled: Url
    Following IF code deals wih GET method
    */

    if(isset($_GET["url_to_proxify"]) === TRUE)
       {
            
    $url_to_proxify filter_input(INPUT_GET'url_to_proxify'FILTER_VALIDATE_URL);
            
            
    $ch curl_init();
            
    curl_setopt($chCURLOPT_URL"$url_to_proxify");
            
    curl_setopt($chCURLOPT_FOLLOWLOCATIONTRUE);
            
    curl_setopt($chCURLOPT_HEADER5);
            
    curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
            
    $curl_result curl_exec($ch);
            
            
    $domain parse_url($url_to_proxifyPHP_URL_HOST);
            
            
    $pattern = array("./""/""https://""http://""localhost");
            
    $replace = array("proxified_page_2.php?url_to_proxify=./""proxified_page_2.php?url_to_proxify=/""proxified_page_2.php?url_to_proxify=https://""proxified_page_2.php?url_to_proxify=http://");
            
    $string_replaced_data str_replace($pattern$replace$curl_result);
            
            
    //Deal with Image Files (Eg. Google Img File)        
            
    $pattern = array("/ src="/", "src ", "src"/""/ src ="" /src="/", " /src "/"" /src= "/", " /src="/""/ src='/""/ src = '/""/ src= '/"" / src='/",  " /src='/"" /src = '/"" /src= '/"" /src='/");
            
    $replace = array("proxified_page_2.php?url_to_proxify=/ src="/", "proxified_page_2.php?url_to_proxify=/ src ", "proxified_page_2.php?url_to_proxify=/ src"/""proxified_page_2.php?url_to_proxify=/ src =""proxified_page_2.php?url_to_proxify= /src="/", "proxified_page_2.php?url_to_proxify= /src "/""proxified_page_2.php?url_to_proxify= /src= "/", "proxified_page_2.php?url_to_proxify= /src="/""proxified_page_2.php?url_to_proxify=/ src='/""proxified_page_2.php?url_to_proxify=/ src = '/""proxified_page_2.php?url_to_proxify=/ src= '/""proxified_page_2.php?url_to_proxify= / src='/",  "proxified_page_2.php?url_to_proxify= /src='/""proxified_page_2.php?url_to_proxify= /src = '/""proxified_page_2.php?url_to_proxify= /src= '/""proxified_page_2.php?url_to_proxify= /src='/");
            
    $string_replaced_data str_replace($pattern$replace$curl_result);
            
            
    //Deal with all the links presented by the searchengine result pages (SERPS). Eg. Google Search Pages (SERPs)
            
    $pattern = array("/ action="/", "action ", "action"/""/ action ="" /action="/", " /action "/"" /action= "/", " /action="/""/ action='/""/ action = '/""/ action= '/"" / action='/",  " /action='/"" /action = '/"" /action= '/"" /action='/");
            
    $replace = array("proxified_page_2.php?url_to_proxify=/ action="/", "proxified_page_2.php?url_to_proxify=/ action ", "proxified_page_2.php?url_to_proxify=/ action"/""proxified_page_2.php?url_to_proxify=/ action =""proxified_page_2.php?url_to_proxify= /action="/", "proxified_page_2.php?url_to_proxify= /action "/""proxified_page_2.php?url_to_proxify= /action= "/", "proxified_page_2.php?url_to_proxify= /action="/""proxified_page_2.php?url_to_proxify=/ action='/""proxified_page_2.php?url_to_proxify=/ action = '/""proxified_page_2.php?url_to_proxify=/ action= '/""proxified_page_2.php?url_to_proxify= / action='/",  "proxified_page_2.php?url_to_proxify= /action='/""proxified_page_2.php?url_to_proxify= /action = '/""proxified_page_2.php?url_to_proxify= /action= '/""proxified_page_2.php?url_to_proxify= /action='/");
            
    $string_replaced_data str_replace($pattern$replace$curl_result);
            
            echo 
    $string_replaced_data;        
            
    curl_close($ch);        
        }
    else
        {            
            
    //Html Form
            
    ?>
            <html>
                <body>   
                    <form action = "<?php $_SERVER['PHP_SELF'?>" method = "GET">
                    Url: <input type = "text" name = "url_to_proxify" />
                    <input type = "submit" />
          </form>      
       </body>
    </html>
    <?php
        
    }

    ?>
    I think I have done well for a newbie. Tried and experimented a variety of ways. What do you think ? You're welcome to check the youtube video out. It is only 4 mins.
    Last edited by UniqueIdeaMan; July 16th, 2017 at 03:54 PM.
  22. #27
  23. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,810
    Rep Power
    4536
    Originally Posted by UniqueIdeaMan
    I think I have done well for a newbie.
    No you haven't. It's been two months and you still can't figure out why this is an invalid string:

    PHP Code:
    $string "Why is there a ****ing " in the middle of the string?"; 
    All you do is copy-and-paste ****.

    Edit: Oh, here's a hint for you. This page highlights PHP strings, like that one above, in red. Only the RED text is considered a string by PHP. You know, because it's a programming language and it has rules. Blue text is considered to be PHP code. Shed any light on your problem?
    -- Cigars, whiskey and wild, wild women. --
  24. #28
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    307
    Rep Power
    1
    Originally Posted by Sepodati
    No you haven't. It's been two months and you still can't figure out why this is an invalid string:

    PHP Code:
    $string "Why is there a ****ing " in the middle of the string?"; 
    All you do is copy-and-paste ****.

    Edit: Oh, here's a hint for you. This page highlights PHP strings, like that one above, in red. Only the RED text is considered a string by PHP. You know, because it's a programming language and it has rules. Blue text is considered to be PHP code. Shed any light on your problem?
    Right from the beginning this is what I have been wondering ....

    Any quotes in the midst of a string needs to be escaped. Eg.

    echo "My name Is \"UI Man\"";

    So, that php does not take the middle quotes as the closing quote. I know that.
    And since I want to replace the following:

    src = "

    Then I should change this:

    PHP Code:

    $pattern 
    = array("/ src="/", "src ", "src"/""/ src ="" /src="/", 
    to this:

    PHP Code:

    $pattern 
    = array("/ src=/" ", "src ", "src= /" ""/ src ="" /src=/" ", 
    In other words, the forward slash should be on the leftside of the middle/center quote mark.
    But guess what, doing it like that does not achieve what I want to do. Neither the error goes away. In other words: It does not make any difference.
    Check it out yourself.
    Plus, checkout the original youtube video code:

    PHP Code:

    <?php 

    /* 
    ERROR HANDLING 
    */ 
    ini_set('display_errors'1); 
    ini_set('display_startup_errors'1); 

    //For All Error, Warning and Notice 
    error_reporting(E_ALL) OR error_reporting(-1); 
    //For All Errors 
    error_reporting(E_ERROR); 
    //For All Warnings 
    error_reporting(E_WARNING); 
    //For All Notice 
    error_reporting(E_NOTICE); 

    error_reporting(E_ALL); 

    //Below code from Basic Php Proxy Video and fix from: [url]https://stackoverflow.com/questions/22255241/preg-replace-no-ending-matching-delimiter-gt/22255455#22255455[/url] 
    //https://www.youtube.com/watch?v=P49w0E64MAA 

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

    foreach(
    $page as $part

         
    $part preg_replace('/src="/''src="'.$url,$part); 
    $part preg_replace('/action="/''action="'.$url,$part); 

    echo 
    $part



    ?>
    He has done it like this (for no reason he escaped the ending sngl quote! And, it is working):

    PHP Code:

    $part 
    preg_replace('/src="/'

    And, that is why, for 2 mnths I am struggling with nonsense like these from php.
    I am not that stupid, like you dreaded. Right ?

    I have a feeling you're wondering why I don't make use of both single and dbl quotes and create my own pattern rather than use the youtubers, if using his pattern makes me come to a dead-end.
    Well, the answer to that is: I might aswell do that tonight and see what the result is.
    I tell you what, you create a result and I create one too and let us see if both our results match or not regardless of whether the errors appear or not. Then, atleast you'll get confirmation that I do know about strings, single quotes and double quotes. Yes ?

    PS - I have noticed that, the youtuber used single quotes on opening and closing quotes while I used double and therefore, my work is not really a continuation from his work but a moderation and I have a feeling the answer or your clue lies in the single & double quotes and escaping. I just mixed both types of codes and made a mess out of things! Need to clean things up. WIll do that tonight. In the meanwhile, need to go out and eat!
    Thanks for your concerns and hints. You are now one of: My men!
    Last edited by UniqueIdeaMan; July 17th, 2017 at 09:36 AM.
  26. #29
  27. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,810
    Rep Power
    4536
    Originally Posted by UniqueIdeaMan
    Any quotes in the midst of a string needs to be escaped. Eg.

    PHP Code:
    echo "My name Is \"UI Man\"";

    $pattern = array("/ src=/" ", "src ", "src= /" ""/ src ="" /src=/" ", 
    How the hell do you write it correct one way and then on the next line screw it up again?

    He has done it like this (for no reason he escaped the ending sngl quote! And, it is working):

    PHP Code:

    $part 
    preg_replace('/src="/'
    No, the FORWARD slashes are there to indicate the beginning and end of the pattern, for the regular expression. You're not even using a regular expression (although you should be; we'll get there later), so you shouldn't even have FORWARD slashes in your strings... Stop trying to pass your blind, stab-in-the-dark copy-and-paste off as "modernization". lol...
    -- Cigars, whiskey and wild, wild women. --
  28. #30
  29. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2006
    Posts
    2,629
    Rep Power
    1811
    Originally Posted by Sepodati
    How the hell do you write it correct one way and then on the next line screw it up again?


    No, the FORWARD slashes are there to indicate the beginning and end of the pattern, for the regular expression. You're not even using a regular expression (although you should be; we'll get there later), so you shouldn't even have FORWARD slashes in your strings... Stop trying to pass your blind, stab-in-the-dark copy-and-paste off as "modernization". lol...
    I think I used one of our favourite words when I spotted he'd done that - in between the laughing, of course

    Comments on this post

    • Sepodati agrees : I have no ****ing clue what's going on with this dude...
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc

IMN logo majestic logo threadwatch logo seochat tools logo