In front of the member introduced some of the functions to achieve, you can also have a look

The first paper: https://blog.csdn.net/weixin_…

Article 2: https://blog.csdn.net/weixin_…

This is a column developed by an international multilingual dating website:

https://blog.csdn.net/weixin_…

If you have any questions, please call me, everybody, my buckle is 2360248-666

This is the function diagram

The following are some of the system Settings to achieve the function

Upload directly to OSS

Public function MJDR (){// Upload directly to OSS

$p = I("get.p"); if(! $p) $p=0; $page = 10; $list = M()->table("lx_users")->limit($p*$page,$page)->order('userid asc')->select(); foreach($list as $val){ if($val["avatar"] && ! strstr('http:',$val["avatar"])){ $re = $this->oos_upimg('http://www.aiqing.com/'.$val["avatar"]); if($re) M()->table("lx_users")->where("userid=".$val['userid'])->setField("avatar",$re); echo $val['userid']."<img src='".$re."' width='100'>"; } } $p++; $nexurl = U("mjdr",array("p"=>$p)); echo '<script>window.location.href="'.$nexurl.'"; </script>'; exit;

}

public function mjdr2(){

$p = I("get.p"); if(! $p) $p=0; $page = 50; $list = M()->table("lx_users")->limit($p*$page,$page)->order('userid asc')->select(); if(! $list) exit("none"); foreach($list as $val){ if($val["avatar"] && ! strstr($val["avatar"],'http:')){ $uid = md5($val["userid"]-652); $filename1 = $uid.".jpg"; $re = $this->GrabImage2('http://www.aiqing.com/'.$val['avatar'],$filename1,'http://www.aiqing.com'); if(file_exists($re)){ $re2 = "http://www.yueai.me/".$re; M()->table("lx_users")->where("userid=".$val['userid'])->setField("avatar",$re2); } echo $val['userid']."<img src='".$re."' width='100'>"; } } $p++; $nexurl = U("mjdr2",array("p"=>$p)); echo '<script>window.location.href="'.$nexurl.'"; </script>'; exit;

}

Collection album

Public function mjdr3(){public function mjdr3()

$p = I("get.p"); if(! $p) $p=0; $page = 10; $list = M()->table("lx_user_photo")->limit($p*$page,$page)->order('photoid asc')->select(); if(! $list) exit("none"); foreach($list as $val){ if($val["uploadfiles"] && ! strstr($val["uploadfiles"],'http:')){ $uid = md5($val["photoid"]); $filename1 = $uid.".jpg"; $re = $this->GrabImage3('http://www.aiqing.com/'.$val['uploadfiles'],$filename1,'http://www.aiqing.com'); if(file_exists($re)){ $re2 = "http://www.yueai.me/".$re; M()->table("lx_user_photo")->where("photoid=".$val['photoid'])->setField("uploadfiles",$re2); } echo $val['photoid']."<img src='".$re."' width='100'>"; } } $p++; $nexurl = U("mjdr3",array("p"=>$p)); echo '<script>window.location.href="'.$nexurl.'"; </script>'; exit;

}

/ *

  • There are hotlinking proof pictures
  • $url image address
  • $filename image save address
  • Return the path and name of the downloaded image, and the size of the image
  • $fromurl source URL, fill in the source image URL can crack anti hotlinking

* /

function GrabImage3($url,$filename=””,$fromurl=””,$filepath=””) {

if($url==””) return false;

if(! $filepath){

  $filepath="photo/".date("mdHi")."/";

! is_dir($filepath)? mkdir($filepath):null; // Create a folder

}

$randip = A(“Weixin”)->randip();

$re = A(“Weixin”)->curlg($url,$fromurl,$randip);

$size = file_put_contents($filepath.$filename,$re); // return size

if($size)

return $filepath.$filename;

}

/ *

  • There are hotlinking proof pictures
  • $url image address
  • $filename image save address
  • Return the path and name of the downloaded image, and the size of the image
  • $fromurl source URL, fill in the source image URL can crack anti hotlinking

* /

function GrabImage2($url,$filename=””,$fromurl=””,$filepath=””) {

if($url==””) return false;

if(! $filepath){

  $filepath="Uploads/".date("ymdHi")."/";

! is_dir($filepath)? mkdir($filepath):null; // Create a folder

}

$randip = A(“Weixin”)->randip();

$re = A(“Weixin”)->curlg($url,$fromurl,$randip);

$size = file_put_contents($filepath.$filename,$re); // return size

if($size)

return $filepath.$filename;

}

Map plug-in implementation

class Api2Controller extends SiteController {

public function getarea($lat,$lon){ if(! $lon || ! $lat) return false; $url = 'http://api.map.baidu.com/geocoder/v2/?ak='.C('ak').'&callback=&location='.$lat.','.$lon.'&output=json&pois=0'; //echo $url; $re = $this->curl_get_contents($url); $re = json_decode($re,true); return $re; dump($re); } public function bdlbsapi2($lat,$lon){ $data['title']=$this->uinfo['user_nicename']; $data['latitude']=$lat; $data['tel']=$this->uinfo['user_login']; $data['sex']=$this->uinfo['sex']; $data['longitude']=$lon; $data['hash']=C('SITE_HASH_KEY'); $re = $this->bdlbsapi($data); return $re; } private function bdlbsapi($data,$lbsid=0){ $ak = C('ak2'); if($lbsid<=0){ $purl = 'http://api.map.baidu.com/geodata/v3/poi/create';

}else{

$data['id']=$lbsid;
$purl = "http://api.map.baidu.com/geodata/v3/poi/update";

}

$data['ak']=$ak;
$data['geotable_id']=C('LBS_DB');
$data['coord_type']="1";
$re = A("Weixin")->curlparr($purl,$data);
$re = json_decode($re,true);
if($re["status"]==0){
    $lbsid =$re['id']; 
}else{
    $lbsid = -1;
}
return  $lbsid;

}

}

? >