//CUrl请求调用接口functioncurl_call($url,$method='get',$data=''){$ch=curl_init();$header=array('Accept-Charset: utf-8');curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_CUSTOMREQUEST,strtoupper($method));curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);curl_setopt($ch,CURLOPT_HTTPHEADER,$header);curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);curl_setopt($ch,CURLOPT_AUTOREFERER,1);curl_setopt($ch,CURLOPT_POSTFIELDS,$data);curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);$result=curl_exec($ch);if($error=curl_error($ch)){return$error;}curl_close($ch);return$result;}
<?php/**
* Created by PhpStorm.
* User: Admin
* Date: 2020/5/6
* Time: 16:17
*/if(!defined('URLCHECK')){echo'request error';exit;}classbfapiControllerextendscommon{//保存数据publicfunctionindexModel(){$modle=$this->Model('onlinesave');$info=$modle->GetInfo($_POST['id']);if(empty($info)){$model=$this->Model('onlinesave');$model->AddData($_POST);}else{$model=$this->Model('onlinesave');$model->saveInfo($_POST['id'],$_POST);}}//保存文件publicfunctionsavefileModel(){$newfilepath=$_POST['newfilepath'];$file=$_POST['oldfilepath'];$arr=explode('/',$file);$filename=end($arr);$path='./file/'.$newfilepath.'/';if(!is_dir($path)){mkdir(iconv("GBK","UTF-8",$path),0777,true);}file_put_contents($path.$filename,file_get_contents($file));}}