<?php
if (isset($_GET['url']) && eregi("^(http://)?(([0-9a-z_!~*'().&=+$%-]+:)?[0-9a-z_!~*'().&=+$%-]+@)?((([12]?[0-9]{1,2}\.){3}[12]?[0-9]{1,2})|(([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.(com|net|org|edu|mil|gov|int|aero|coop|museum|name|info|biz|pro|[a-z]{2})))(:[1-6]?[0-9]{1,4})?((/?)|(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+(\.jpg|\.gif|\.png|\.jpeg)$", $_GET['url'])) {
$image = file_get_contents($_GET['url']);
if (!$image) {
die("Unable to fetch URL");
}
$f = fopen("imagefile", "w");
if (!$f) {
die("Unable to open file for writing");
}
fwrite($f, $image);
fclose($f);
} else {
die("Invalid Image URL");
}
?>