
<?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*/

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


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

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

$data = $_POST['str'];

list($type, $data) = explode(';', $data);
list(, $data)      = explode(',', $data);
$data = base64_decode($data);

file_put_contents('./Final_P_Images/'.$img_src.'.png', $data);

echo './Final_P_Images/'.$img_src.'.png';

?>