<?php

/*Get user ip address*/
$ip_address=$_SERVER['REMOTE_ADDR'];

/*Get user ip address details with geoplugin.net*/
$geopluginURL='http://www.geoplugin.net/php.gp?ip='.$ip_address;
$addrDetailsArr = unserialize(file_get_contents($geopluginURL)); 

/*Get City name by return array*/
$city = $addrDetailsArr['geoplugin_city']; 

/*Get Country name by return array*/
$country = $addrDetailsArr['geoplugin_countryName'];

/*Comment out these line to see all the posible details*/
/*echo '<pre>';
print_r($addrDetailsArr);
die();*/

if(!$city){
   $city='Not Define';
}if(!$country){
   $country='Not Define';
}

// $ip_address1 = explode(".", $ip_address);
// $ip_address1 = explode(":", $ip_address1);
// $ip_address2 = implode("", $ip_address1);

$dateNtime=date('Y:m:dH:i:s');
$time = explode(":", $dateNtime);
//$time0 = explode("-",$time);
$time1 = implode("", $time);

//echo '<strong>IP Address</strong>:- '.$ip_address2.'<br/>';
//echo '<strong>City</strong>:- '.$city.'<br/>';
//echo '<strong>Country</strong>:- '.$country.'<br/><br>';

//echo $ip_address2;

// Ip a podanum yenna ippo wela senjitu irukathu localhost (09/25/2018) ip exploade imploade uncomment pannu
$img_src = $time1;

$url = $_POST["code"];
$imgUrlPart = 'Final_P_Images/'.$img_src.'.jpg';
// file_put_contents($img, file_get_contents($url));

//echo $url;
if (isset($_POST["code"]) && $_POST["code"] != ""){
 $image = file_get_contents($url);
 file_put_contents($imgUrlPart, $image);
}

echo $imgUrlPart;
exit;
?>