function httpget($url,$dir="/data/",$filename = '') {
if(!is_dir(DIR_IMAGE.$dir)){
@mkdir(DIR_IMAGE.$dir,0755,true);
}
$url = trim(str_replace(" ","%20",$url));
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$temp = curl_exec($ch);
$fileext = pathinfo($url, PATHINFO_EXTENSION);
$fileext = empty($fileext) ? "jpg" : $fileext;
$filename = empty($filename) ? md5($url.time().rand()).".".$fileext : $filename.'_'.rand(1,9999999).".".$fileext;
if($temp && file_put_contents(DIR_IMAGE.$dir.$filename,$temp)){
return $dir.$filename;
} else {
return false;
}
}