Reply to your question:
As numerous others have said - simplify your script by not doing too many operations or statements on a single line and use var_dump($val); die; If it is not the desired result then correct the errors before moving on.
I actually created 3 versions of my script and have been experimenting for weeks. One way or the other, I come across a variety of stumbling blocks. At the end, I created a 4th version.
The first 3, had code like this to which you are suggesting it seems:
$pattern = array("https://", "http://", "localhost");
$replace = array("proxified_page.php/?url_to_proxify=https://", "proxified_page.php/?url_to_proxify=http://", "proxified_page.php/?url_to_proxify=");
$phrase = str_replace($pattern, $replace, $curl_result);
print_r($phrase);
$pattern = array("https://", "http://", "localhost");
$replace = array("proxified_page_2.php/?url_to_proxify=https://\"$domain\"", "proxified_page_2.php/?url_to_proxify=http://\"$domain\"", "proxified_page_2.php/?url_to_proxify=http://\"$domain\"");
$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='");
$replace = array('src="proxified_page_2.php/?url_to_proxify=\"$domain\""', 'src = "proxified_page_2.php/?url_to_proxify=\"$domain\""', 'src= "proxified_page_2.php/?url_to_proxify=\"$domain\""', 'src ="proxified_page_2.php/?url_to_proxify=\"$domain\""', "src='proxified_page_2.php/?url_to_proxify=\"$domain\"'", "src = 'proxified_page_2.php/?url_to_proxify=\"$domain\"'", "src= 'proxified_page_2.php/?url_to_proxify=\"$domain\"'", "src ='proxified_page_2.php/?url_to_proxify=\"$domain\"'");
$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='");
$replace = array('action="proxified_page_2.php/?url_to_proxify=\"$domain\""', 'action = "proxified_page_2.php/?url_to_proxify=\"$domain\""', 'action= "proxified_page_2.php/?url_to_proxify=\"$domain\""', 'action ="proxified_page_2.php/?url_to_proxify=\"$domain\""', "action='proxified_page_2.php/?url_to_proxify=\"$domain\"'", "action = 'proxified_page_2.php/?url_to_proxify=\"$domain\"'", "action= 'proxified_page_2.php/?url_to_proxify=\"$domain\"'", "action ='proxified_page_2.php/?url_to_proxify=\"$domain\"'");
$string_replaced_data = str_replace($pattern, $replace, $curl_result);
print_r($curl_result);
$pattern = array("https://", "http://", "localhost");
$replace = array("proxified_page_3.php/?url_to_proxify=https://", "proxified_page_3.php/?url_to_proxify=http://", "proxified_page_3.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='");
$replace = array('src="proxified_page_3.php/?url_to_proxify="', 'src = "proxified_page_3.php?/url_to_proxify="', 'src= "proxified_page_3.php/?url_to_proxify="', 'src ="proxified_page_3.php/?url_to_proxify="', "src='proxified_page_3.php?url_to_proxify='", "src = 'proxified_page_3.php/?url_to_proxify='", "src= 'proxified_page_3.php/?url_to_proxify='", "src ='proxified_page_3.php/?url_to_proxify='");
$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='");
$replace = array('action="proxified_page_3.php/?url_to_proxify="', 'action = "proxified_page_3.php/?url_to_proxify="', 'action= "proxified_page_3.php/?url_to_proxify="', 'action ="proxified_page_3.php/?url_to_proxify="', "action='proxified_page_3.php/?url_to_proxify='", "action = 'proxified_page_3.php/?url_to_proxify='", "action= 'proxified_page_3.php/?url_to_proxify='", "action ='proxified_page_3.php/?url_to_proxify='");
$string_replaced_data = str_replace($pattern, $replace, $curl_result);
print_r($curl_result);
But then I thought, hell, why have 3 different sections and just combine them into 1:
//Proxify Links, Deal with Image Files (Eg. Google Img File), Deal with all the links presented by the searchengine result pages (SERPS). Eg. Google Search Pages (SERPs)
$pattern = array("https://", "http://", "localhost", "/", 'src="', 'src = "', 'src= "', 'src ="', "src='", "src = '", "src= '", "src='", 'action="', 'action = "', 'action= "', 'action ="', "action='", "action = '", "action= '", "action='", "<a href=\"n", "<a href='n");
$replace = array("proxified_page_test.php/?url_to_proxify=https://\"$domain\"", "proxified_page_test.php/?url_to_proxify=http://\"$domain\"", "proxified_page_test.php/?url_to_proxify=http://\"$domain\"", "proxified_page_test.php/?url_to_proxify=http://\"$domain\"", 'src="proxified_page_test.php/?url_to_proxify=\"$domain\""', 'src = "proxified_page_test.php/?url_to_proxify=\"$domain\""', 'src= "proxified_page_test.php/?url_to_proxify=\"$domain\""', 'src ="proxified_page_test.php/?url_to_proxify=\"$domain\""', "src='proxified_page_test.php/?url_to_proxify=\"$domain\"'", "src = 'proxified_page_test.php/?url_to_proxify=\"$domain\"'", "src= 'proxified_page_test.php/?url_to_proxify=\"$domain\"'", "src ='proxified_page_test.php/?url_to_proxify=\"$domain\"'", 'action="proxified_page_test.php/?url_to_proxify=\"$domain\""', 'action = "proxified_page_test.php/?url_to_proxify=\"$domain\""', 'action= "proxified_page_test.php/?url_to_proxify=\"$domain\""', 'action ="proxified_page_test.php/?url_to_proxify=\"$domain\""', "action='proxified_page_test.php/?url_to_proxify=\"$domain\"'", "action = 'proxified_page_test.php/?url_to_proxify=\"$domain\"'", "action= 'proxified_page_test.php/?url_to_proxify=\"$domain\"'", "action ='proxified_page_test.php/?url_to_proxify=\"$domain\"'", "<a href=\'proxified_page_test.php/?url_to_proxify=http://\"$domain\"/n'", "<a href=\'proxified_page_test.php/?url_to_proxify=http://\"$domain\"/n'");
$string_replaced_data = str_replace($pattern, $replace, $curl_result);
print_r($curl_result);
Replying to your question:
As previously mentioned try creating and echoing a function getCurlResult( $domain ) {…}
I actually did as you suggested. But I get a complete blank page and following the method I mentioned to TechnoBear above that rids the white blank page is not working on this particular version of the script, even if the method is working on other versions of the script. Check above to see what I just replied to TechnoBear.
Here is the code that shows a complete white blank page and nothing seems to rid this problem. Note, I don’t use you guy’s recent suggestions such as use var_dump etc. as this is a version I stopped working on about a wk ago. But, I’m just mentioning it here to show you that I did use your suggested:
getCurlResult( $domain ) {…}
But I did ask you later-on on another post of mine if I placed that line in the right line or not. Because, I suspect I did not. Looking at the code below, do you mind telling me this ? That way, I might solve the issue of the blank white page.
This was version 2 of the script.
<?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);
/* STEP 2:
The IF gets triggered as soon as the "submit" button is clicked in the text box labeled: Url
Following IF code deals with GET method.
*/
if(isset($_GET["url_to_proxify"]) === TRUE)
{
function get_parse_results($url_to_proxify, $curl_result=NULL) {
echo "IF got triggered!";
$url_to_proxify = filter_input(INPUT_GET, 'url_to_proxify', FILTER_VALIDATE_URL);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$url_to_proxify");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$curl_result = curl_exec($ch);
curl_close($ch);
$domain = parse_url($url_to_proxify, PHP_URL_HOST);
$pattern = array("https://", "http://", "localhost");
$replace = array("proxified_page_2.php/?url_to_proxify=https://\"$domain\"", "proxified_page_2.php/?url_to_proxify=http://\"$domain\"", "proxified_page_2.php/?url_to_proxify=http://\"$domain\"");
$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='");
$replace = array('src="proxified_page_2.php/?url_to_proxify=\"$domain\""', 'src = "proxified_page_2.php/?url_to_proxify=\"$domain\""', 'src= "proxified_page_2.php/?url_to_proxify=\"$domain\""', 'src ="proxified_page_2.php/?url_to_proxify=\"$domain\""', "src='proxified_page_2.php/?url_to_proxify=\"$domain\"'", "src = 'proxified_page_2.php/?url_to_proxify=\"$domain\"'", "src= 'proxified_page_2.php/?url_to_proxify=\"$domain\"'", "src ='proxified_page_2.php/?url_to_proxify=\"$domain\"'");
$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='");
$replace = array('action="proxified_page_2.php/?url_to_proxify=\"$domain\""', 'action = "proxified_page_2.php/?url_to_proxify=\"$domain\""', 'action= "proxified_page_2.php/?url_to_proxify=\"$domain\""', 'action ="proxified_page_2.php/?url_to_proxify=\"$domain\""', "action='proxified_page_2.php/?url_to_proxify=\"$domain\"'", "action = 'proxified_page_2.php/?url_to_proxify=\"$domain\"'", "action= 'proxified_page_2.php/?url_to_proxify=\"$domain\"'", "action ='proxified_page_2.php/?url_to_proxify=\"$domain\"'");
$string_replaced_data = str_replace($pattern, $replace, $curl_result);
print_r($curl_result);
}
}
else
{
echo "ELSE got triggered!";
//Html Form
?>
<html>
<body>
<form action = "<?php echo $_SERVER['PHP_SELF']; ?>" method = "GET">
Url: <input type = "text" name = "url_to_proxify" />
<input type = "submit" />
</form>
</body>
</html>
<?php
}
?>
Replying to your question:
Why use echo when it has been previously stated that using var_dump($val); will return the value which may hav been 0 or and empty string which will not show $val?
Oops! I forgot to make use of the var_dump on version 4 of the script to which you are referring to. I had actually added that echo when you suggested it a few days earlier before SamA74 or somebody suggested the var_dump.
Check your post #183. I’m afraid my memory was stuck at your post #183 or my code was.