Warning: filter_input(): INPUT_REQUEST is not yet implemented in

For learning purpose (to gain experience in cURL and web scraping), trying to build a mini proxy.
I know a web proxy will encounter all sorts of pages. Pages that deal with GET method (eg. google search) and pages that deal with POST method (eg. form signup).
Can’t be writing 2 sets of codes where one is for GET and the other for POST. And so, thought best to write just one set of code to deal with both methods. And the best way to do that is write code using REQUEST which will deal with both GET and POST.
Here is my code but for some reason I get error:

Warning: filter_input(): INPUT_REQUEST is not yet implemented in C:\xampp\htdocs\id\proxified_page_2.php on line 50


<?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);

/*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($_REQUEST["url_to_proxify"]) === TRUE)
   {
		$url_to_proxify = filter_input(INPUT_REQUEST, '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);
		
		$domain = parse_url($url_to_proxify, PHP_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
		$string_replaced_data = str_replace('/src="/', 'src="'.$domain.$url_to_proxify, $string_replaced_data);
		
        echo $string_replaced_data;
		curl_close($ch);		
	}



?>

What does the error mean ?
The last line in the following snippet was line 50:

if(isset($_REQUEST["url_to_proxify"]) === TRUE)
   {
		$url_to_proxify = filter_input(INPUT_REQUEST, 'url_to_proxify', FILTER_VALIDATE_URL);

Per the manual, INPUT_REQUEST is not a valid type.

http://php.net/manual/en/function.filter-input.php

3 Likes

cpradio,

Ok. Thanks.
I just signed-up to codeacademy.com like you suggested. It says it estimates I will learn php in 4 hrs. I don’t really think so but let us see how much I progress. :slight_smile:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.