|
@@ -154,4 +154,74 @@ class Template extends Common{ |
|
@@ -154,4 +154,74 @@ class Template extends Common{ |
|
154
|
$this->assign ( 'files',$templates );
|
154
|
$this->assign ( 'files',$templates );
|
|
155
|
return $this->fetch();
|
155
|
return $this->fetch();
|
|
156
|
}
|
156
|
}
|
|
|
|
157
|
+
|
|
|
|
158
|
+ /**
|
|
|
|
159
|
+ * 二维码生成
|
|
|
|
160
|
+ */
|
|
|
|
161
|
+ public function createcode(){
|
|
|
|
162
|
+ if(request()->isPost()){
|
|
|
|
163
|
+ $num = intval(input('post.num'));
|
|
|
|
164
|
+ $flag = intval(input('post.flag'));
|
|
|
|
165
|
+ if($num<=0){
|
|
|
|
166
|
+ $result['msg'] = '请输入正整数!';
|
|
|
|
167
|
+ $result['status'] = 0;
|
|
|
|
168
|
+ return $result;
|
|
|
|
169
|
+ }
|
|
|
|
170
|
+ if($flag<0 || $flag >2){
|
|
|
|
171
|
+ $result['msg'] = '请输入1或者2或者不输入!';
|
|
|
|
172
|
+ $result['status'] = 0;
|
|
|
|
173
|
+ return $result;
|
|
|
|
174
|
+ }
|
|
|
|
175
|
+ //调用API
|
|
|
|
176
|
+ //http://www.dc-api.com/public/index.php?service=App.Tables.BatchQRcode
|
|
|
|
177
|
+ $param=array(
|
|
|
|
178
|
+ 'num' =>$num,
|
|
|
|
179
|
+ 'flag' =>$flag,
|
|
|
|
180
|
+ );
|
|
|
|
181
|
+ $url = "http://xt04.colorcun.com/?service=App.Tables.BatchQRcode";
|
|
|
|
182
|
+ $status = json_decode($this->requesthttp($url,$param),true);
|
|
|
|
183
|
+ if($status['ret']==200){
|
|
|
|
184
|
+ $result['msg'] = '添加成功!';
|
|
|
|
185
|
+ $result['code'] = 1;
|
|
|
|
186
|
+ return $result;
|
|
|
|
187
|
+ }else{
|
|
|
|
188
|
+ $result['msg'] = $status['msg'];
|
|
|
|
189
|
+ $result['code'] = $status['ret'];
|
|
|
|
190
|
+ return $status;
|
|
|
|
191
|
+ }
|
|
|
|
192
|
+ }
|
|
|
|
193
|
+ $this->assign ( 'title','二维码生成' );
|
|
|
|
194
|
+ return $this->fetch();
|
|
|
|
195
|
+ }
|
|
|
|
196
|
+ public function requesthttp($url,$param,$post_file=false){
|
|
|
|
197
|
+ $oCurl = curl_init();
|
|
|
|
198
|
+ if(stripos($url,"https://")!==FALSE){
|
|
|
|
199
|
+ curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
|
|
|
200
|
+ curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
|
|
|
|
201
|
+ curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1
|
|
|
|
202
|
+ }
|
|
|
|
203
|
+ if (is_string($param) || $post_file) {
|
|
|
|
204
|
+ $strPOST = $param;
|
|
|
|
205
|
+ } else{
|
|
|
|
206
|
+ $aPOST = array();
|
|
|
|
207
|
+ foreach($param as $key=>$val){
|
|
|
|
208
|
+ $aPOST[] = $key."=".urlencode($val);
|
|
|
|
209
|
+ }
|
|
|
|
210
|
+ $strPOST = join("&", $aPOST);
|
|
|
|
211
|
+ }
|
|
|
|
212
|
+ curl_setopt($oCurl, CURLOPT_URL, $url);
|
|
|
|
213
|
+ curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
|
|
|
|
214
|
+ curl_setopt($oCurl, CURLOPT_POST,true);
|
|
|
|
215
|
+ curl_setopt($oCurl, CURLOPT_POSTFIELDS,$strPOST);
|
|
|
|
216
|
+ $sContent = curl_exec($oCurl);
|
|
|
|
217
|
+ $aStatus = curl_getinfo($oCurl);
|
|
|
|
218
|
+ curl_close($oCurl);
|
|
|
|
219
|
+ //dump(json_decode($sContent));
|
|
|
|
220
|
+ if(intval($aStatus["http_code"])==200){
|
|
|
|
221
|
+ return $sContent;
|
|
|
|
222
|
+ }else{
|
|
|
|
223
|
+ return false;
|
|
|
|
224
|
+ }
|
|
|
|
225
|
+ }
|
|
|
|
226
|
+
|
|
157
|
} |
227
|
} |