|
...
|
...
|
@@ -154,4 +154,74 @@ class Template extends Common{ |
|
|
|
$this->assign ( 'files',$templates );
|
|
|
|
return $this->fetch();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 二维码生成
|
|
|
|
*/
|
|
|
|
public function createcode(){
|
|
|
|
if(request()->isPost()){
|
|
|
|
$num = intval(input('post.num'));
|
|
|
|
$flag = intval(input('post.flag'));
|
|
|
|
if($num<=0){
|
|
|
|
$result['msg'] = '请输入正整数!';
|
|
|
|
$result['status'] = 0;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
if($flag<0 || $flag >2){
|
|
|
|
$result['msg'] = '请输入1或者2或者不输入!';
|
|
|
|
$result['status'] = 0;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
//调用API
|
|
|
|
//http://www.dc-api.com/public/index.php?service=App.Tables.BatchQRcode
|
|
|
|
$param=array(
|
|
|
|
'num' =>$num,
|
|
|
|
'flag' =>$flag,
|
|
|
|
);
|
|
|
|
$url = "http://xt04.colorcun.com/?service=App.Tables.BatchQRcode";
|
|
|
|
$status = json_decode($this->requesthttp($url,$param),true);
|
|
|
|
if($status['ret']==200){
|
|
|
|
$result['msg'] = '添加成功!';
|
|
|
|
$result['code'] = 1;
|
|
|
|
return $result;
|
|
|
|
}else{
|
|
|
|
$result['msg'] = $status['msg'];
|
|
|
|
$result['code'] = $status['ret'];
|
|
|
|
return $status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->assign ( 'title','二维码生成' );
|
|
|
|
return $this->fetch();
|
|
|
|
}
|
|
|
|
public function requesthttp($url,$param,$post_file=false){
|
|
|
|
$oCurl = curl_init();
|
|
|
|
if(stripos($url,"https://")!==FALSE){
|
|
|
|
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
|
|
|
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
|
|
|
|
curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1
|
|
|
|
}
|
|
|
|
if (is_string($param) || $post_file) {
|
|
|
|
$strPOST = $param;
|
|
|
|
} else{
|
|
|
|
$aPOST = array();
|
|
|
|
foreach($param as $key=>$val){
|
|
|
|
$aPOST[] = $key."=".urlencode($val);
|
|
|
|
}
|
|
|
|
$strPOST = join("&", $aPOST);
|
|
|
|
}
|
|
|
|
curl_setopt($oCurl, CURLOPT_URL, $url);
|
|
|
|
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
|
|
|
|
curl_setopt($oCurl, CURLOPT_POST,true);
|
|
|
|
curl_setopt($oCurl, CURLOPT_POSTFIELDS,$strPOST);
|
|
|
|
$sContent = curl_exec($oCurl);
|
|
|
|
$aStatus = curl_getinfo($oCurl);
|
|
|
|
curl_close($oCurl);
|
|
|
|
//dump(json_decode($sContent));
|
|
|
|
if(intval($aStatus["http_code"])==200){
|
|
|
|
return $sContent;
|
|
|
|
}else{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|