yzms/show/get.php

787 lines
25 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?
require_once(dirname(__FILE__)."/common.php");
$act = trim($_GET['act']);
//if(!in_array($act,array("hkface_get_face_data","get_face"))) {
if($_SERVER["HTTP_GYHFTIPFSDX"]) {
$ip = trim(addslashes(current(explode(',', $_SERVER['HTTP_GYHFTIPFSDX']))));
} else {
$ip = $_SERVER["REMOTE_ADDR"];
}
$chk_server_log_table = $db->get_one("show tables like 'tb_show_get_log'");
if($chk_server_log_table){
$request = serialize($_REQUEST);
$sql = "insert into tb_show_get_log set act = '".$act."', ip = '".addslashes($ip)."', request = '".addslashes($request)."', record_datetime = now()";
$db->query($sql);
}
//}
if($act == 'getTakeCount') {
$hids = array(1 => '信息大厦饭堂', 2 => '魁奇饭堂');
$d = date("Y-m-d");
$data = array();
foreach($hids as $hid => $hname) {
$st = strtotime($d." 11:30:00");
$et = strtotime($d." 13:00:00");
$x = array();
$y = array();
while($st < $et) {
$st1 = date("Y-m-d H:i:s", $st);
$st += 300;
$et1 = date("Y-m-d H:i:s", $st-1);
$sql = "select count(*) from tb_order a,tb_date b where a.date_id = b.id and b.dining_hall_id={$hid} and type=1 and take_food_time >= '{$st1}' and take_food_time <= '{$et1}' and state_id=3";
$c = $db->get_colume($sql);
/*$x[] = array(
'start_time' => $st1,
'end_time' => $et1,
'take_count' => $c,
);*/
if(count($x)%2 == 0) $x[] = substr($st1, 11, 5);
else $x[] = '';
$y[] = $c;
}
//$x[count($x)-1] = substr($st1, 11, 5);
$data[] = array('ftid' => $hid, 'ftname' => $hname,'x' => $x, 'y' => $y, 'title' => date("n")."".date("j")."");
}
echo json_encode($data);
}
if($act == 'getQRCode') {
$takecode = trim($_GET['takecode']);
if(!$takecode) exit;
$px = trim($_GET['px']);
if($px){
$size = $px*(1/29);
}else{
$size = 7;
}
$original = trim($_GET['original']);
if($original == '1'){
// 用原来的数据
$data = $takecode;
}else{
// 拼接,原来的付款码
$data = getEncodeStr($takecode);
}
require 'include/qrcode/qrlib.php';
$t = "qr_".time()."_".rand().".png";
QRcode::png($data, $t, 'L',$size , 0);
header("Content-Type: image/png");
echo file_get_contents($t);
@unlink($t);
exit;
}
if($act == 'wxpay_unifiedorder') {
$type = $_GET['type'];
$isjsapi = ($type == 'jsapi' || strstr($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger'));
$user = check_token();
$uid = $user['id'];
//$uid = 3;
$total_fee = round(floatval($_GET['total_fee'])*100);
if($total_fee <= 0) exit;
$company_id = $user['company_id'];
if(!$company_id) exit;
$cInfo = $db->get_one("select * from tb_company where id=". $company_id);
if(!$cInfo) exit;
$wxpay_mch_id = $cInfo['wxpay_mch_id'];
$wxpay_appid = $cInfo['wxpay_appid'];
$wxpay_key = $cInfo['wxpay_key'];
$wxpay_sub_mch_id = $cInfo['wxpay_sub_mch_id'];
if(!$wxpay_mch_id || !$wxpay_appid || !$wxpay_key) {
echoRs(0, '不支持微信支付!');
}
$openid = '';
if($isjsapi) {
$openid = $user['weixin_openid'];
if(!$openid) {
echoRs(0, '非微信注册用户!不能使用公众号支付!');
}
}
$host = $_SERVER['HTTP_HOST'];
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
//$row = $db->get_one("select * from tb_recharge_pay_weixin where uid={$uid} and state=0 and total_fee=".($total_fee/100)." and addtime>'".date('YmdHis', time()-300)."'");
if(false) {
$prepay_id = $row['prepay_id'];
$code = $row['code'];
$mweb_url = $row['mweb_url'];
} else {
$code = get_code('tb_recharge_pay_weixin', 'code', 12, 'num', "FTDC".date("Ymd"));
$time_expire = date("YmdHis", time()+600);
$data = array();
$data['appid'] = $wxpay_appid;
$data['body'] = '订餐系统-充值'.($total_fee/100)."";
$data['mch_id'] = $wxpay_mch_id;
$data['nonce_str'] = md5(time()."_".rand());
$data['notify_url'] = "https://yzms.fsecity.com/show/wxpay_recv.php";
$data['out_trade_no'] = $code;
$data['spbill_create_ip'] = $_SERVER['REMOTE_ADDR'];
$data['total_fee'] = $total_fee;
$data['time_expire'] = $time_expire;
$trade_type = $isjsapi?'JSAPI':'MWEB';;
$data['trade_type'] = $trade_type;
if($openid) $data['openid'] = $openid;
if($wxpay_sub_mch_id) $data['sub_mch_id'] = $wxpay_sub_mch_id;
ksort($data);
$s1 = '';
foreach($data as $key => $item) {
if($s1 != '') $s1 .= "&";
$s1 .= $key."=".$item;
}
$s1 .= "&key=".$wxpay_key;
$sign = strtoupper(md5($s1));
$xml = "<xml>\n";
foreach($data as $key => $item) {
$xml .= "\t<{$key}>{$item}</{$key}>\n";
}
$xml .= "\t<sign>".$sign."</sign>\n";
$xml .= "</xml>\n";
$prepay_id = '';
$c = gquery("https://api.mch.weixin.qq.com/pay/unifiedorder", $xml);//echo $xml;exit;
if($c) {
preg_match("/<prepay_id>(.+)<\/prepay_id>/i", $c, $m);
if($m[1]) {
$prepay_id = str_replace(array('<![CDATA[', ']]>'), '', $m[1]);
$mweb_url = '';
preg_match("/<mweb_url>(.+)<\/mweb_url>/i", $c, $m);
if($m[1]) {
$mweb_url = str_replace(array('<![CDATA[', ']]>'), '', $m[1]);
}
$code_url = '';
preg_match("/<code_url>(.+)<\/code_url>/i", $c, $m);
if($m[1]) {
$code_url = str_replace(array('<![CDATA[', ']]>'), '', $m[1]);
}
}
}
if(!$prepay_id) {
echoRs(0, '下单失败请重试1');
}
//临时增加redirect_url
$ua = $_SERVER['HTTP_USER_AGENT'];
if(!stristr($ua, "android")) $mweb_url.= "&redirect_url=".urlencode($protocol.$host."/m/wx.html");
$sql = "insert into tb_recharge_pay_weixin set code='{$code}', trade_type='{$trade_type}', uid={$uid}, prepay_id='{$prepay_id}', mweb_url='".addslashes($mweb_url)."', total_fee=".($total_fee/100).", time_expire='{$time_expire}', state=0, addtime=now()";
//echo $sql;
$db->query($sql, 'SILENT');
if($db->affected_rows() != 1) {
echoRs(0, '下单失败请重试2');
}
}
$data = array();
if($isjsapi) {
$return_url = "https://yzms.fsecity.com/m/recharge.html?code=".$code;
$sign = md5($prepay_id."_".date("Y-m-d")."_vfj389umk9o3");
$data['mweb_url'] = "https://dc.fsecity.com/show/wxpay/ft_pay.php?prepay_id=".urlencode($prepay_id)."&return_url=".urlencode($return_url)."&sign=".$sign;
} else {
$data['mweb_url'] = $mweb_url;
}
$data['code'] = $code;
echoRs(1, 'ok', array('data' => $data));
exit;
}
if($act == 'applet_unifiedorder') {
$type = $_GET['type'];
$isjsapi = ($type == 'jsapi' || strstr($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger'));
$user = check_token();
$uid = $user['id'];
//$uid = 3;
$total_fee = round(floatval($_GET['total_fee'])*100);
if($total_fee <= 0) exit;
$company_id = $user['company_id'];
if(!$company_id) exit;
$cInfo = $db->get_one("select * from tb_company where id=". $company_id);
if(!$cInfo) exit;
$applet_appid = $cInfo['wxpay_appid'];
$applet_mch_id = $cInfo['wxpay_mch_id'];
$applet_key = $cInfo['wxpay_key'];
if(!$applet_mch_id || !$applet_appid || !$applet_key) {
echoRs(0, '不支持小程序支付!');
}
$openid = '';
if($isjsapi) {
$openid = $user['applet_openid'];
if(!$openid) {
echoRs(0, '非小程序注册用户!不能使用小程序支付!');
}
}
$host = $_SERVER['HTTP_HOST'];
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$code = get_code('tb_recharge_pay_weixin', 'code', 12, 'num', "FTDC".date("Ymd"));
$time_expire = date("YmdHis", time()+600);
$data = array();
$data['appid'] = $applet_appid;
$data['body'] = '订餐系统-充值'.($total_fee/100)."";
$data['mch_id'] = $applet_mch_id;
$data['nonce_str'] = md5(time()."_".rand());
$data['notify_url'] = "https://yzms.fsecity.com/show/wxpay_recv.php";
$data['out_trade_no'] = $code;
$data['spbill_create_ip'] = $_SERVER['REMOTE_ADDR'];
$data['total_fee'] = $total_fee;
$data['time_expire'] = $time_expire;
$trade_type = $isjsapi?'JSAPI':'MWEB';;
$data['trade_type'] = $trade_type;
if($openid) $data['openid'] = $openid;
// if($wxpay_sub_mch_id) $data['sub_mch_id'] = $wxpay_sub_mch_id;
ksort($data);
$s1 = '';
foreach($data as $key => $item) {
if($s1 != '') $s1 .= "&";
$s1 .= $key."=".$item;
}
$s1 .= "&key=".$applet_key;
$sign = strtoupper(md5($s1));
$xml = "<xml>\n";
foreach($data as $key => $item) {
$xml .= "\t<{$key}>{$item}</{$key}>\n";
}
$xml .= "\t<sign>".$sign."</sign>\n";
$xml .= "</xml>\n";
$prepay_id = '';
$c = gquery("https://api.mch.weixin.qq.com/pay/unifiedorder", $xml);//echo $xml;exit;
echo "<pre>";
print_r($c);
echo "</pre>";
exit;
if($c) {
preg_match("/<prepay_id>(.+)<\/prepay_id>/i", $c, $m);
if($m[1]) {
$prepay_id = str_replace(array('<![CDATA[', ']]>'), '', $m[1]);
// $mweb_url = '';
// preg_match("/<mweb_url>(.+)<\/mweb_url>/i", $c, $m);
// if($m[1]) {
// $mweb_url = str_replace(array('<![CDATA[', ']]>'), '', $m[1]);
// }
//
// $code_url = '';
// preg_match("/<code_url>(.+)<\/>/i", $c, $m);
// if($m[1]) {
// $code_url = str_replace(array('<![CDATA[', ']]>'), '', $m[1]);
// }
}
}
if(!$prepay_id) {
echoRs(0, '下单失败请重试1');
}
//临时增加redirect_url
$ua = $_SERVER['HTTP_USER_AGENT'];
// if(!stristr($ua, "android")) $mweb_url.= "&redirect_url=".urlencode($protocol.$host."/m/wx.html");
$sql = "insert into tb_recharge_pay_weixin set code='{$code}', trade_type='{$trade_type}', uid={$uid}, prepay_id='{$prepay_id}', total_fee=".($total_fee/100).", time_expire='{$time_expire}', state=0, is_applet=1, addtime=now()";
//echo $sql;
$db->query($sql, 'SILENT');
if($db->affected_rows() != 1) {
echoRs(0, '下单失败请重试2');
}
$data = array();
// if($isjsapi) {
//
// $return_url = "https://yzms.fsecity.com/m/recharge.html?code=".$code;
// $sign = md5($prepay_id."_".date("Y-m-d")."_vfj389umk9o3");
// $data['mweb_url'] = "https://dc.fsecity.com/show/wxpay/ft_pay.php?prepay_id=".urlencode($prepay_id)."&return_url=".urlencode($return_url)."&sign=".$sign;
// } else {
// $data['mweb_url'] = $mweb_url;
// }
$data['code'] = $code;
// $data['prepay_id'] = $prepay_id;
$signData['appId'] = $applet_mch_id;
$signData['timeStamp'] = time();
$signData['nonceStr'] = md5(time()."_".rand());
$signData['package'] = "prepay_id=".$prepay_id;
$signData['signType'] = "MD5";
ksort($signData);
$s2 = '';
foreach($signData as $key => $item) {
if($s2 != '') $s2 .= "&";
$s2 .= $key."=".$item;
}
$s2 .= "&key=".$applet_key;
$signData['paySign'] = strtoupper(md5($s2));
unset($signData['appId']);
$data['requestPayment'] = $signData;
echoRs(1, 'ok', array('data' => $data));
exit;
}
if($act == 'get_wxpay_status') {
$code = trim($_GET['code']);
if(!$code) exit;
$orderInfo = $db->get_one("select * from tb_recharge_pay_weixin where code = '{$code}'");
if(!$orderInfo) {
echoRs(0, '订单不存在!');
}
if($orderInfo['state'] == 1) {
echoRs(1, '支付成功!');
}
$uid = $orderInfo['uid'];
$user = $db->get_one("select * from tb_user where id=". $uid);
$company_id = $user['company_id'];
if(!$company_id) exit;
$cInfo = $db->get_one("select * from tb_company where id=". $company_id);
if(!$cInfo) exit;
$wxpay_mch_id = $cInfo['wxpay_mch_id'];
$wxpay_appid = $cInfo['wxpay_appid'];
$wxpay_key = $cInfo['wxpay_key'];
$wxpay_sub_mch_id = $cInfo['wxpay_sub_mch_id'];
if(!$wxpay_mch_id || !$wxpay_appid || !$wxpay_key) {
echoRs(0, '不支持微信支付!');
}
//$port = $db->get_colume("select value from tb_config where class='PORT'");
$data = array();
$data['appid'] = $wxpay_appid;
$data['mch_id'] = $wxpay_mch_id;
$data['nonce_str'] = md5(time()."_".rand());
$data['out_trade_no'] = $code;
if($wxpay_sub_mch_id) $data['sub_mch_id'] = $wxpay_sub_mch_id;
ksort($data);
$s1 = '';
foreach($data as $key => $item) {
if($item != '') {
if($s1 != '') $s1 .= "&";
$s1 .= $key."=".$item;
}
}
$s1 .= "&key=".$wxpay_key;
$sign = strtoupper(md5($s1));
$xml = "<xml>\n";
foreach($data as $key => $item) {
$xml .= "\t<{$key}>{$item}</{$key}>\n";
}
$xml .= "\t<sign>".$sign."</sign>\n";
$xml .= "</xml>\n";
$c = gquery("https://api.mch.weixin.qq.com/pay/orderquery", $xml);
if(!$c) {
echoRs(0, '查询失败!请重试!');
}
$wxpay_recvxml = $c;
$wxrecv_isinclude = true;
require("wxpay_recv.php");
//gquery("http://127.0.0.1:{$port}/show/wxpay_recv.php", $c);
$orderInfo = $db->get_one("select * from tb_recharge_pay_weixin where id=". $orderInfo['id']);
if($orderInfo['state'] == 1) {
echoRs(1, '支付成功!');
} else {
echoRs(0, '未支付!');
}
}
if($act == 'get_yzfpay_status') {
$code = trim($_GET['code']);
if(!$code) exit;
$orderInfo = $db->get_one("select * from tb_recharge_pay where ORDERSEQ = '{$code}'");
if(!$orderInfo) {
echoRs(0, '订单不存在!');
}
if($orderInfo['RETNCODE'] == 'SUCCESS') {
$pay_suc = $db->get_one("select * from tb_recharge_pay_suc where ORDERSEQ = '{$code}'");
if(empty($pay_suc)){
echoRs(0, '订单没有支付成功记录!');
}else{
echoRs(1, '支付成功!');
}
}
echoRs(0, '订单支付失败!');
}
if($act == 'getAllUser') {
$ip = $_SERVER['REMOTE_ADDR'];
//if(substr($ip, 0, 7) != '172.16.' && $ip != '36.111.42.57' && $ip != '59.36.172.164') exit;
ini_set("memory_limit", '512M');
$data = $db->get_all("select a.id, a.type_id, a.username, a.cellphone, a.cellphone2, b.short_name as deptname, a.enabled from tb_user a, tb_company b where a.company_id=b.id");
$s = gzcompress(serialize($data));
$s = aes_encrypt($s, '8e1xkkv921xiaOFA', '', true);
echo $s;
exit;
}
if($act == 'sgo' || $act == 'sga' || $act == 'sq') {
$ip = $_SERVER['REMOTE_ADDR'];
//if(substr($ip, 0, 7) != '172.16.' && $ip != '36.111.42.57' && $ip != '59.36.172.164' && $ip != '127.0.0.1') exit;
$ps = file_get_contents("php://input");
if(!$ps) exit;
$enkey = '8e1xkkv921xiaOFA';
$sql = aes_decrypt($ps, $enkey, '', true);
if(!$sql) exit;
if(!$sql) exit;
if($act == 'sq') {
$rs = $db->query($sql);
$id = $db->insert_id();
$data = array('rs' => $rs, 'id' => $id);
}
else if($act == 'sga') $data = $db->get_all($sql);
else if($act == 'sgo') $data = $db->get_one($sql);
$s = gzcompress(serialize($data));
$s = aes_encrypt($s, $enkey, '', true);
echo $s;
exit;
}
if($act == 'get_rest') {
$ftid = intval($_GET['ftid']);
$date = date("Y-m-d");
$time = date("H:i:s");
$dateList = $db->get_all("select a.*, b.name as meal_name from tb_date a, tb_meal_type b where a.dc_type=b.id and a.dining_hall_id = {$ftid} and dc_date = '{$date}' and b.start_time<='{$time}' and b.end_time>='{$time}' order by a.id ");
$restList = array();
foreach($dateList as $item) {
$date_id = $item['id'];
$row = $db->get_all("select c.id, c.dish_name, IFNULL(sum(b.dish_amount), 0) rest_num from (select c.id, c.dish_name from tb_dish c, tb_date_dish e where c.id = e.dish_id and e.date_id={$date_id} and c.dish_type) c
LEFT JOIN (select b.id, b.dish_id, b.dish_amount from tb_order a, tb_order_detail b where date_id = {$date_id} and a.id = b.order_id and a.state_id=6 and a.type=1 ) b
on b.dish_id = c.id
group by c.id");
foreach($row as $k=>$v) {
if(mb_strlen($v['dish_name'],"utf-8")>5) {
$row[$k]['dish_name'] = mb_substr($v['dish_name'],0,2,"utf-8")."*".mb_substr($v['dish_name'],mb_strlen($v['dish_name'],"utf-8") - 4,3,"utf-8");
}
}
$restList[] = array('meal_name' => $item['dc_date'].$item['meal_name'], 'date_id' => $date_id, 'rest_info' => $row);
}
echoRs(1, 'ok', array('restList' => $restList));
}
function get_facecode($path, $rotate) {
$s = md5($path."_".$rotate, true);
$n = ord($s[0])."".ord($s[1])."".ord($s[2])."".ord($s[3])."".ord($s[4])."".ord($s[5])."".ord($s[6])."".ord($s[7])."".ord($s[8]);
$n = ltrim($n, "0");
if(strlen($n) > 8) $n = substr($n, 0, 8);
return $n;
}
if($act == 'hkface_get_face_list') {
if(function_exists('check_isfsip')) {
check_isfsip();
}
$dining_hall_id = intval($_GET['dining_hall_id']);
if(!$dining_hall_id) {
echoRs(0, '公司id不能为空');
}
$trs = $db->get_one("select company_id from tb_dining_hall where id = ".$dining_hall_id);
$company_id = $trs['company_id'];
$data = $db->get_all("select a.id, a.user_id, a.card, a.facecode, b.cellphone, b.username,(select cardno from tb_user_idcard where user_id =b.id and state = '1' limit 1) as cardno from tb_user_face a, tb_user b where a.user_id=b.id and b.enabled not in (0, -99) and b.company_id = ".$company_id);
$list = array();
foreach($data as $item) {
$card = $item['card'];
unset($item['card']);
$list[$card] = $item;
}
echoRs(1, 'ok!', array('list' => $list));
}
if($act == 'hkface_get_face_data' || $act == 'get_face') {
if(function_exists('check_isfsip')) {
check_isfsip();
}
if($act == 'hkface_get_face_data') {
if (is_numeric($_GET['uid']))$uid = intval($_GET['uid']);
else $uid = intval(dbdec($_GET['uid']));
// $uid = intval($_GET['uid']);
$raw = intval($_GET['raw']);
} else {
$user = check_token();
$uid = $user['id'];
$raw = 1;
}
$info = $db->get_one("select a.* from tb_user_face a, tb_user b where a.user_id=b.id and b.enabled not in (0, -99) and a.user_id=".$uid);
if(!$info) exit;
$path = "../backstage/".$info['path'];
$rotate = $info['rotate'];
if($rotate == 0) {
if(!is_file($path)) {
exit;
}
$data = @file_get_contents($path);
} else {
$path2 = substr($path, 0, -4)."_{$rotate}.jpg";
if(is_file($path2)) {
$data = @file_get_contents($path2);
} else {
if($rotate == 1) $deg = 90;
else if($rotate == 2) $deg = -90;
else if($rotate == 3) $deg = 180;
else exit;
$img = @imagecreatefromjpeg($path);
if(!$img) {
exit;
}
$color = imagecolorallocate($img, 255, 255, 255);
$img = imagerotate($img, $deg, $color);
imagejpeg($img, $path2, 90);
imagedestroy($img);
if(!is_file($path2)) {
exit;
}
$data = @file_get_contents($path2);
}
}
if($raw) {
header("Content-Type: image/jpeg");
echo $data;
exit;
}
unset($info['path']);
$info['data'] = base64_encode($data);
echoRs(1, 'ok!', array('info' => $info));
}
if($act == 'upload_face') {
//$jsonpfunc = $_GET['uploadfunc'];
//if(!$jsonpfunc) exit;
$user = check_token();
$uid = $user['id'];
$row = $db->get_one("select * from tb_user_face where user_id = {$uid}");
if($row && $row['width'] > 100 && $row['height'] > 100 && $user['company_id'] != 54) {
echoRs(0, '系统中已经有您的照片,如需修改请到饭堂现场处理!');
}
$data = stripslashes($_POST["data"]);
if(!$data) {
echoRs(0, '参数不完整!');
}
//$allow_ext = array('jpg', 'jpeg', 'png');
//$fn = $file['name'];
//if(!strstr($fn, ".")) echoRs(0, '文件名错误!');
//$ext = strtolower(end(explode(".", $fn)));
//if(!in_array($ext, $allow_ext)) echoRs(0, '只允许上传jpg或png图片文件');
$imgkey = md5(microtime()."_".rand());
$imgpath = "../backstage/uploadfiles/userfaces/".$imgkey.".jpg";
$data = str_ireplace("data:image/jpeg;base64,", '', $data);
$data = str_ireplace("data:image/png;base64,", '', $data);
$imgs = base64_decode($data);
if(!$imgs) echoRs(0, '上传失败!');
$img = @imagecreatefromstring($imgs);
if(!$img) {
echoRs(0, '图片解析错误!');
}
$maxsize = 600;
$width = imagesx($img);
$height = imagesy($img);
if($width >= $height) {
$height2 = $maxsize;
$width2 = ceil($width*$height2/$height);
} else {
$width2 = $maxsize;
$height2 = ceil($height*$width2/$width);
}
if($width2 >= $width || $height2 >= $height) {
$width2 = $width;
$height2 = $height;
}
$img2 = imagecreatetruecolor($width2, $height2);
imagecopyresized($img2, $img, 0, 0, 0, 0, $width2, $height2, $width, $height);
imagejpeg($img2, $imgpath, 90);
imagedestroy($img);
imagedestroy($img2);
if(!file_exists($imgpath) || filesize($imgpath) <= 0) {
//header('HTTP/1.1 500 err');
echoRs(0, '上传失败!');
}
$card = substr(md5("yzms".$uid), 10, 10);
$tfn = "uploadfiles/userfaces/".$imgkey.".jpg";
$facecode = get_facecode($tfn, 0);
if($row) {
$db->query("update tb_user_face set facecode = '{$facecode}', path = '{$tfn}', rotate = '0', `addtime` = now(),upload_from=2 where id=".$row['id']);
} else {
$db->query("insert into tb_user_face set user_id = {$uid}, card = '{$card}', facecode = '{$facecode}', path = '{$tfn}', rotate = '0', upload_from=2, width={$width2},height={$height2}, `addtime` = now()");
}
echoRs(1, 'ok', array('url' => '/show/get.php?act=get_face&token='.$_GET['token']."&code=".$facecode));
}
if($act == 'is_push_check_box'){
$user = check_token();
$is_check = trim($_REQUEST['is_check']);
if(empty($user['id'])){
echoRs(0, '获取用户信息失败');
}
if($is_check === false){
echoRs(0, '参数缺失');
}
$list_info = $db->get_one("select * from tb_notice_push_blacklist where user_id='{$user['id']}'");
if(!empty($list_info)){
// 有记录update
$db->query("update tb_notice_push_blacklist set is_receive='{$is_check}' where user_id='{$user['id']}'");
}else{
// 没记录,insert
$db->query("insert into tb_notice_push_blacklist set user_id='{$user['id']}', add_time='".date('Y-m-d H:i:s')."', is_receive='{$is_check}'");
}
echoRs(1, '设置成功');
}
if($act == 'cancel_account'){
$user = check_token();
if(!empty($user) && $user['enabled'] != 1){
echoRs(0, '该账号当前状态不能注销。');
}
$update = $db->query("update tb_user set enabled='0' where id=" . $user['id']);
if($update){
echoRs(1, '注销成功。');
}else{
echoRs(0, '注销失败,请联系管理员。');
}
}
if($act == 'download_cert') {
$company_id = intval($_REQUEST['company_id']);
$posid = intval($_REQUEST['posid']);
$channel_id = intval($_REQUEST['channel_id']);
$ft_id = intval($_REQUEST['ft_id']);
if(!$company_id && $ft_id) {
$row = $db->get_one("select * from tb_dining_hall where id = ".$ft_id);
if(!$row) exit;
$company_id = $row['company_id'];
}
$list = $db->get_all("select * from tb_hk_cert where company_id=".$company_id);
if(!$list) exit;
$info = array();
foreach($list as $item) {
$info[$item['ftid']."_".$item['channel_id']."_".$item['posid']] = $item;
}
$keys = array(
$ft_id ."_". $channel_id ."_". $posid,
$ft_id ."_". $channel_id ."_0",
$ft_id ."_0_". $posid,
"0_". $channel_id ."_". $posid,
$ft_id ."_0_0",
"0_". $channel_id ."_0",
"0_0_". $posid,
"0_0_0",
);
foreach($keys as $key) {
if($info[$key]) {
$row = $info[$key];
echo '"{""serial"":""'.$row['serial'].'"",""key"":""'.$row['key'].'""}"'."\n";
exit;
}
}
exit;
}
if(substr($act, 0, 4) == 'jtj_') require_once("get_jtj.php");
//记录人脸错误信息
if($act == 'hk_fail') {
$s = file_get_contents("php://input");
$info = $_REQUEST['info'];
$a = json_decode($info, true);
if(!$a['list']) exit;
$diningHallId = $a['ftID'];
$channelId = $a['posID'];
foreach($a['list'] as $item) {
$uniqueCode = $item['uniqueCode'];
$facecode = $item['facecode'];
$card = $item['uniqueCode'];
$status = $item['status'];
$sql = "INSERT tb_face_error (dining_hall_id,channel_id,card,facecode,datetime,status) VALUES ( '".addslashes($diningHallId). "' , '".addslashes($channelId)."' , '".addslashes($card)."' , '".addslashes($facecode)."' ,now() ".$status." ) ";
if(in_array($item['status'],array(3,4,5,7))) {
//echo "update tb_user_face set fail=1,fail_time=now() where card = '".addslashes($uniqueCode)."' and facecode = '".addslashes($facecode)."'\n";
$db->query("update tb_user_face set fail=1,fail_time=now() where card = '".addslashes($uniqueCode)."' and facecode = '".addslashes($facecode)."'", 'SILENT');
$db->query("INSERT tb_face_error (dining_hall_id,channel_id,card,facecode,datetime,status) VALUES ( '".addslashes($diningHallId). "' , '".addslashes($channelId)."' , '".addslashes($card)."' , '".addslashes($facecode)."' , now() , ".$status." ) ");
}
}
echo 'ok';
}
if($act == 'saveEmail'){
$user = check_token();
$email = trim(addslashes($_POST['email']));
if(empty($email)){
echoRs(0, '邮箱不能为空');
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echoRs(0, '请输入一个有效的邮箱');
}
$check = $db->get_one("select * from tb_privacy_download where user_id='{$user['id']}' and add_time BETWEEN CURRENT_DATE and DATE_ADD(CURRENT_DATE,INTERVAL 1 day)");
if($check){
echoRs(0, '你今天已经提交过。');
}
$userInfo = $db->get_one("select * from tb_user where enabled in (1, -1) and id='{$user['id']}'");
if(empty($userInfo)){
echoRs(0, '用户不存在。');
}
$insert_id = $db->query("insert into tb_privacy_download set cellphone='{$userInfo['cellphone']}', username='{$userInfo['username']}', email='{$email}', is_send=0, add_time=now(), user_id='{$user['id']}'");
if($insert_id){
echoRs(1, '提交成功');
}else{
echoRs(0, '提交失败');
}
}