diff --git a/.gitignore b/.gitignore index a805c9e..bbde16b 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,5 @@ android_yzf_update.php # 验证码图片 /backstage/captcha -.htaccess \ No newline at end of file +.htaccess +.vscode \ No newline at end of file diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..6471bda --- /dev/null +++ b/readme.txt @@ -0,0 +1,5 @@ +php项目,不需要编译 +内部包括了多个云中美食相关的项目,主要包括前端和php项目 + +- touch:触摸屏项目 +- touch_mz:敏卓触摸屏项目 diff --git a/show/api_pos.php b/show/api_pos.php index 44b0992..19ff2c0 100644 --- a/show/api_pos.php +++ b/show/api_pos.php @@ -1,17 +1,21 @@ get_one("select * from tb_pos_device where serialno = '".addslashes($serialno)."'"); $device_id = intval($deviceInfo['id']); +// 获取远程地址 $ip = $_SERVER["REMOTE_ADDR"]; $s1 = $json; @@ -19,6 +23,7 @@ if(strlen($s1) > 2000) { $s1 = substr($s1, 0, 2000).'..'; } +// 插入POS机日志记录 $db->query("insert into tb_pos_device_log set device_id = {$device_id}, serialno = '".addslashes($serialno)."', ip = '".addslashes($ip)."', path = '".addslashes($qs)."', request = '".addslashes($s1)."', response = '', addtime = now() "); $log_id = $db->insert_id(); if(!$deviceInfo) { @@ -26,16 +31,19 @@ if(!$deviceInfo) { exit; } +// 从数据记录中获取信息 $company_id = intval($deviceInfo['company_id']); $dining_hall_id = intval($deviceInfo['dining_hall_id']); $channel_id = intval($deviceInfo['channel_id']); +// md5编码签名 $sign2 = md5($post['time'].$post['noncestr'].$deviceInfo['cardpwd']); if($sign2 !== $post['sign']) { //签名错误 $db->query("update tb_pos_device_log set response='sign_err' where id=".$log_id); exit; } +// 将api和data数据处理编码后插入到tb_pos_device_log表,并终止脚本运行 function response_pos($api, $data) { global $deviceInfo, $post, $log_id, $db; $noncestr = md5(microtime().'_'.rand()); @@ -52,9 +60,13 @@ function response_pos($api, $data) { echo $json; exit; } + +// 向本机地址发送请求,拼接端口号、路径、post参数和header,调用自定义gquery函数 function self_query($path, $post) { return gquery("http://127.0.0.1:".$_SERVER['SERVER_PORT'].$path, $post, array('Host: '.$_SERVER['SERVER_NAME'])); } + +// 从post参数中获取pay_mode等参数 function pos_check_user() { global $post, $db, $company_id; @@ -67,17 +79,21 @@ function pos_check_user() { if(substr($qr_code, 0, 4) != '[st]' || substr($qr_code, -1) != ';') exit; + // 截取qr_code,截取第4位到倒数第2位字符 $s = substr($qr_code, 4, -1); + // 将字符串分割成数组 $a = explode(",", $s); if(count($a) != 2) exit; $code = $a[0]; $hash = $a[1]; + // 关联数组,返回类似json的结构 return array('type' => 'qr', 'code' => $code); } + // 搜索父字符串中子字符串的位置,如果pay_code中不以ymzs_开头,则退出 if(strpos($pay_code, 'yzms_') !== 0) exit; $uid = intval(substr($pay_code, 5)); @@ -95,7 +111,10 @@ function pos_check_user() { } return $uInfo; } + +// 顶层代码,判断qs中参数 if($qs == 'heartbeat' || $qs == 'addperson' || $qs == 'delperson') { //心跳 + // 新增人员 if($qs == 'addperson' && $post['whitelist']) { foreach($post['whitelist'] as $item) { @@ -104,6 +123,7 @@ if($qs == 'heartbeat' || $qs == 'addperson' || $qs == 'delperson') { //心跳 $db->query("update tb_pos_device_user set status=2,rs='".$item['result_code']."' where id = '{$rec_id}' and uid = '{$uid}'"); } } + // 删除人员 if($qs == 'delperson' && $post['whitelist']) { foreach($post['whitelist'] as $item) { @@ -113,6 +133,7 @@ if($qs == 'heartbeat' || $qs == 'addperson' || $qs == 'delperson') { //心跳 } } + // 心跳 if($qs != 'heartbeat' || (time() - strtotime($deviceInfo['synctime']) > 60)) { //1分钟检测一次用户同步 $db->query("update tb_pos_device set synctime=now() where id = ".$device_id); diff --git a/show/common.php b/show/common.php index a345bdd..ef1790a 100644 --- a/show/common.php +++ b/show/common.php @@ -5,7 +5,7 @@ if($_SERVER['HTTP_ACUNETIX_ASPECT']) exit; if($_SERVER["HTTP_GYHFTIPFSDX"]) { $_SERVER["REMOTE_ADDR"] = trim(addslashes(end(explode(',', $_SERVER['HTTP_GYHFTIPFSDX'])))); } -if(!get_magic_quotes_gpc()) { +if(!@get_magic_quotes_gpc()) { foreach($_POST as $key => $v) { if(is_string($v)) $_POST[$key] = addslashes($v); } diff --git a/show/include/mysql.class.php b/show/include/mysql.class.php index 1436715..c28ac56 100644 --- a/show/include/mysql.class.php +++ b/show/include/mysql.class.php @@ -47,6 +47,7 @@ class db_mysql return true; } + // 根据type类型决定是否缓冲到内存后再将查询的结果集输出 function query($sql , $type = '') { $func = $type == 'UNBUFFERED' ? 'mysql_unbuffered_query' : 'mysql_query';