Featured post
php - url or content as a variable in the header of the page -
i designing site external links form various being shown on page. using
$url=$_get['url']; $website_data = file_get_contents($url); echo $website_data;
so user click on hyperlink www.test.com/display_page.php?url=http://www.xyz.com/article/2.jpg
my page, list_of_images.php, typically has list of images href each image above on page , when image clicked go display_page.php, show our banner on top of page, text , image beneath that. image website.
i sending url directly , grabbing using get. understand users/hackers can coding , send commands url variable , break server or harmful , avoid method or sending url directly in header. alternate approach problem?
i make sure url starts http://
or https://
:
if(preg_match("`^https?://`i", $_get['url'])) // stuff
you may want make sure isn't pointing anywhere internal:
if(preg_match('`^https?://(?!localhost|127\.|192\.|10\.0\.)`i', $_get['url'])) // stuff
rather big dirty regex, go more elegant host black-list approach, drift...
- Get link
- X
- Other Apps
Comments
Post a Comment