From bc64b12f067b6975e15b5fa3e64056c56f1ea62f Mon Sep 17 00:00:00 2001 From: "cn.yimian.xyz" Date: Sun, 23 Aug 2020 17:34:26 +0800 Subject: [PATCH] fifn --- api/checkout.php | 30 +++++++++++++++++-- api/confirmBalance.php | 4 +-- api/createTable.php | 6 ++-- api/functions.php | 28 ++++++++--------- api/getData.php | 2 +- api/joinTable.php | 11 ++----- api/newItem.php | 4 +-- api/updateTable.php | 6 ++-- index.html | 13 ++++---- records.html | 4 +-- setTable.html | 68 +++++++++++++++++++++++++++++++++++++++--- 11 files changed, 127 insertions(+), 49 deletions(-) diff --git a/api/checkout.php b/api/checkout.php index b413c14..7d5ebaf 100644 --- a/api/checkout.php +++ b/api/checkout.php @@ -2,16 +2,41 @@ include './functions.php'; -$hash = $_REQUEST['hash']; -$tableId = $_REQUEST['tableId']; +$hash = $_GET['hash']; +$tableId = $_GET['tableId']; if(!isset($hash) || !isset($tableId)) die(); + +/* special php program */ +set_time_limit(0); +ob_end_clean(); +header("Connection: close"); +ob_start(); + + $cnn = db__connect(); $data = getFinalData($cnn, $tableId); +echo ''; + + + +/* close connection */ +ob_end_flush(); +flush(); +if (function_exists("fastcgi_finish_request")) { + fastcgi_finish_request(); +} +sleep(2); +ignore_user_abort(true); +set_time_limit(0); + + + + if($data['average'] > $data['virtualTotals'][$hash]){ foreach($data['users'] as $user){ $to = $user; @@ -37,4 +62,3 @@ db__pushData($cnn, "user", array( "table" => $tableId )); -echo ''; diff --git a/api/confirmBalance.php b/api/confirmBalance.php index ad22f0c..e7ba81f 100644 --- a/api/confirmBalance.php +++ b/api/confirmBalance.php @@ -1,8 +1,8 @@ CP-ACC网站进行确认。您可以通过CP-ACC网站查看具体账目细节。如有任何疑问,请联系站长呓喵酱(i@iotcat.me)。 - -确认链接: https://cp-acc.yimian.xyz/api/confirmBalance.php?first=".$itemIdFirst."&last=".$itemIdLast." - -感谢您使用本站服务,祝您生活愉悦! -呓喵酱(@iotcat)", "CP-ACC"); + sendMail($lastData['email'], "CP-ACC消息: 您将从".$firstData['nickname']."收到".$threshold."磅", "亲爱的".$lastData['nickname'].": +

+根据系统的计算,您将从".$firstData['nickname']."(".$firstData['email'].")"."收取".$threshold."磅,以保持大家的公共支出相对公平。请在收到对方转账后点击下方确认链接登入CP-ACC网站进行确认。您可以通过CP-ACC网站查看具体账目细节。如有任何疑问,请联系站长呓喵酱(i@iotcat.me)。 +

+确认链接: https://cp-acc.yimian.xyz/api/confirmBalance.php?first=".$itemIdFirst."&last=".$itemIdLast." +

+感谢您使用本站服务,祝您生活愉悦!
+呓喵酱(@iotcat)", "CP-ACC"); Sleep(10); -sendMail($firstData['email'], 'CP-ACC消息: 您需要给'.$lastData['nickname'].$threshold."磅/元", "亲爱的".$firstData['nickname'].": - -根据系统的计算,您需要给".$lastData['nickname']."(".$lastData['email'].")".$threshold."磅/元,以保持大家的公共支出相对公平。请在转账后提醒对方从网站或邮件中确认您的支出。您可以通过CP-ACC网站查看具体账目细节。如有任何疑问,请联系站长呓喵酱(i@iotcat.me)。 - -感谢您使用本站服务,祝您生活愉悦! -呓喵酱(@iotcat)", "CP-ACC"); +sendMail($firstData['email'], 'CP-ACC消息: 您需要给'.$lastData['nickname'].$threshold."磅", "亲爱的".$firstData['nickname'].": +

+根据系统的计算,您需要给".$lastData['nickname']."(".$lastData['email'].")".$threshold."磅,以保持大家的公共支出相对公平。请在转账后提醒对方从网站或邮件中确认您的支出。您可以通过CP-ACC网站查看具体账目细节。如有任何疑问,请联系站长呓喵酱(i@iotcat.me)。 +

+感谢您使用本站服务,祝您生活愉悦!
+呓喵酱(@iotcat)", "CP-ACC"); } diff --git a/api/getData.php b/api/getData.php index 5c74b82..fd8fb19 100644 --- a/api/getData.php +++ b/api/getData.php @@ -2,7 +2,7 @@ include './functions.php'; header("Content-type:application/json"); -$hash = $_REQUEST['hash']; +$hash = $_GET['hash']; if(!isset($hash)) die(); diff --git a/api/joinTable.php b/api/joinTable.php index 0676a3e..44ff00e 100644 --- a/api/joinTable.php +++ b/api/joinTable.php @@ -12,7 +12,7 @@ if(!isset($hash) || !isset($tableId) || strlen($hash)<60 || strlen($tableId)<60) $cnn = db__connect(); $data = getFinalData($cnn, $tableId); -if(!db__rowNum($cnn, "user", "user", $hash, "table", $tableId)){ +if(!db__rowNum($cnn, "user", "user", $hash, "table", $tableId, "state", "1")){ $itemId = hash('sha256', time().$hash.$tableId.rand(222,999)); db__pushData($cnn, "account", array( @@ -24,13 +24,7 @@ if(!db__rowNum($cnn, "user", "user", $hash, "table", $tableId)){ "value" => $data['average'], "created_at" => date("Y-m-d H:i:s", time()) )); - db__pushData($cnn, "user", array( - "user" => $hash, - "table" => $tableId, - "state" => '1', - "created_at" => date("Y-m-d H:i:s", time()) - )); -}else{ +} db__pushData($cnn, "user", array( "user" => $hash, "table" => $tableId, @@ -41,7 +35,6 @@ if(!db__rowNum($cnn, "user", "user", $hash, "table", $tableId)){ "table" => $tableId )); -} setcookie("tableId", $tableId, time()+3600*12*60*365, "/"); diff --git a/api/newItem.php b/api/newItem.php index 1c65fd1..736fa09 100644 --- a/api/newItem.php +++ b/api/newItem.php @@ -3,8 +3,8 @@ include './functions.php'; -$url = $_REQUEST['url']; -$passby = $_REQUEST['passby']; +$url = $_GET['url']; +$passby = $_GET['passby']; if(!isset($url) || !isset($passby)) die(); diff --git a/api/updateTable.php b/api/updateTable.php index 96f9fe4..debe6a0 100644 --- a/api/updateTable.php +++ b/api/updateTable.php @@ -1,9 +1,9 @@
  • -
  • -
  • +
  • +
  • © 2018- Made with by iotcat

    @@ -240,7 +240,6 @@ - @@ -268,7 +267,7 @@ Made with by iotcat

    diff --git a/setTable.html b/setTable.html index 22373e9..0cc949a 100644 --- a/setTable.html +++ b/setTable.html @@ -62,7 +62,7 @@

    @@ -101,11 +101,10 @@ try{ if(page.params.hasOwnProperty('tableId')){ if(cookie.get('cache')){ - data = JSON.parse(atob(cookie.get('cache'))); + data = JSON.parse(decodeURIComponent(escape(atob(cookie.get('cache'))))); $('#name').val(data.name); $('#threshold').val(data.threshold); - } } }catch(e){} @@ -168,13 +167,74 @@ session.onload(function(){ qrcode.makeCode('https://cp-acc.yimian.xyz/?tableId='+res.tableId); $('#url').val('https://cp-acc.yimian.xyz/?tableId='+res.tableId); cookie.set('tableId', res.tableId); + delete window.localStorage[session.get('hash')]; }); }); } }); - +window.Clipboard = (function(window, document, navigator) { + var textArea, + copy; + + // 判断是不是ios端 + function isOS() { + return navigator.userAgent.match(/ipad|iphone/i); + } + //创建文本元素 + function createTextArea(text) { + textArea = document.createElement('textArea'); + textArea.value = text; + document.body.appendChild(textArea); + } + //选择内容 + function selectText() { + var range, + selection; + + if (isOS()) { + range = document.createRange(); + range.selectNodeContents(textArea); + selection = window.getSelection(); + selection.removeAllRanges(); + selection.addRange(range); + textArea.setSelectionRange(0, 999999); + } else { + textArea.select(); + } + } + +//复制到剪贴板 + function copyToClipboard() { + try{ + if(document.execCommand("Copy")){ + alert("链接复制成功!"); + }else{ + alert("复制失败!请手动复制!"); + } + }catch(err){ + alert("复制错误!请手动复制!") + } + document.body.removeChild(textArea); + } + + copy = function(text) { + createTextArea(text); + selectText(); + copyToClipboard(); + }; + + return { + copy: copy + }; +})(window, document, navigator); + + +$('#copy').click(function(){ + Clipboard.copy($('#url').val()); +}); +