Skip to content

Commit

Permalink
V1.10版本
Browse files Browse the repository at this point in the history
  • Loading branch information
szvone committed Sep 15, 2019
1 parent 25bee53 commit e8b34b3
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 18 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ V免签为完全开源项目,开源项目意味着作者没有任何收入来
+ 微信店员收款推送通知

## 更新记录
+ v1.10(2019.09.15)
+ 调整二维码识别方案,提升二维码识别率
+ 增加第一次安装时,系统自动生成通讯密钥的功能

+ v1.9.1(2019.09.15)
+ 二维码识别出错增加解决方法:在其他网站(草料二维码识别)识别二维码内容后,将内容重新生成成二维码图片上传。

Expand Down
9 changes: 7 additions & 2 deletions application/admin/controller/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function getMain(){
"MySql"=>$v,
"Thinkphp"=>"v".App::VERSION,
"RunTime"=>$this->sys_uptime(),
"ver"=>"v1.9.1",
"ver"=>"v1.10",
"gd"=>$gd,
)));

Expand Down Expand Up @@ -120,7 +120,12 @@ public function getSettings(){
$payQf = Db::name("setting")->where("vkey","payQf")->find();
$wxpay = Db::name("setting")->where("vkey","wxpay")->find();
$zfbpay = Db::name("setting")->where("vkey","zfbpay")->find();

if ($key['vvalue']==""){
$key['vvalue'] = md5(time());
Db::name("setting")->where("vkey","key")->update(array(
"vvalue"=>$key['vvalue']
));
}

return json($this->getReturn(1,"成功",array(
"user"=>$user['vvalue'],
Expand Down
2 changes: 1 addition & 1 deletion application/index/controller/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public function closeEndOrder(){


//发送Http请求
function getCurl($url, $post = 0, $cookie = 0, $header = 0, $nobaody = 0)
private function getCurl($url, $post = 0, $cookie = 0, $header = 0, $nobaody = 0)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
Expand Down
87 changes: 72 additions & 15 deletions public/qr-code/test.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,93 @@
<?php
ini_set ('memory_limit', '256M');
header("Content-type:text/html;charset=utf-8");

session_start();

if(!isset($_SESSION['think'])){
echo "error";
exit();
}
function getCurl($url, $post = 0, $cookie = 0, $header = 0, $nobaody = 0)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$klsf[] = 'Accept:*/*';
$klsf[] = 'Accept-Language:zh-cn';
//$klsf[] = 'Content-Type:application/json';
$klsf[] = 'User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_1 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C153 MicroMessenger/6.6.1 NetType/WIFI Language/zh_CN';
$klsf[] = 'Referer:https://servicewechat.com/wx7c8d593b2c3a7703/5/page-frame.html';
curl_setopt($ch, CURLOPT_HTTPHEADER, $klsf);
if ($post) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if ($header) {
curl_setopt($ch, CURLOPT_HEADER, true);
}
if ($cookie) {
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
if ($nobaody) {
curl_setopt($ch, CURLOPT_NOBODY, 1);
}
curl_setopt($ch, CURLOPT_TIMEOUT,60);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
}


include_once('./lib/QrReader.php');
header("Content-type:text/html;charset=utf-8");

if (isset($_POST['base64'])){
$b64 = $_POST['base64'];
$s = base64_decode($b64);
$img_path = './image/'.md5($s).'.jpg';
file_put_contents($img_path, $s,LOCK_EX);
}else{
$file = file_get_contents($_FILES["file"]["tmp_name"]);
$b64 = base64_encode($file);
$s = file_get_contents($_FILES["file"]["tmp_name"]);
$img_path = './image/'.md5($s).'.jpg';
file_put_contents($img_path, $s,LOCK_EX);
}
$url='http://'.$_SERVER['SERVER_NAME'].str_replace("/test.php","",$_SERVER["REQUEST_URI"]).str_replace("./","/",$img_path);


//echo $b64;
//$qrcode = new QrReader('./qr.png'); //图片路径
try{
$qrcode = new QrReader(base64_decode($b64),QrReader::SOURCE_TYPE_BLOB); //图片路径
$text = $qrcode->text(); //返回识别后的文本
if ($text){
echo json_encode(array("code"=>1,"msg"=>"成功","data"=>$text));
}else{
echo json_encode(array("code"=>-1,"msg"=>"未识别到二维码","data"=>"二维码识别失败,请删除本张图片"));
$res = getCurl("https://cli.im/apis/up/deqrimg","img=".urlencode($url));
$obj = json_decode($res);
$text = $obj->info->data[0];

if ($text==null || $text == ""){
throw new Exception('远程识别失败');
}
echo json_encode(array("code"=>1,"msg"=>"识别成功","data"=>$text));

}catch (Exception $e){
echo json_encode(array("code"=>-1,"msg"=>"二维码识别出错,请在其他网站(草料二维码识别)识别二维码内容后,将内容重新生成成二维码图片上传"));
include_once('./lib/QrReader.php');

if (isset($_POST['base64'])){
$b64 = $_POST['base64'];
}else{
$file = file_get_contents($_FILES["file"]["tmp_name"]);
$b64 = base64_encode($file);
}

try{
$qrcode = new QrReader(base64_decode($b64),QrReader::SOURCE_TYPE_BLOB); //图片路径
$text = $qrcode->text(); //返回识别后的文本
if ($text){
echo json_encode(array("code"=>1,"msg"=>"成功","data"=>$text));
}else{
echo json_encode(array("code"=>-1,"msg"=>"未识别到二维码","data"=>"二维码识别失败,请删除本张图片"));
}
}catch (Exception $e){

echo json_encode(array("code"=>-1,"msg"=>"二维码识别出错,请在其他网站(草料二维码识别)识别二维码内容后,将内容重新生成成二维码图片上传"));
}

}finally{
unlink($img_path);
}

0 comments on commit e8b34b3

Please sign in to comment.