From da592b5c8dadf7f827cfc00752a82016b106d9a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BC=97=E4=BA=A7-=E7=8E=8B=E5=9D=A4?= Date: Tue, 29 Jul 2025 14:28:01 +0800 Subject: [PATCH] fromhf --- .gitignore | 7 + fork/fork_apinotify.php | 185 ++++++++++++++++++ fork/fork_order.php | 206 ++++++++++++++++++++ web/admin/ap/art_post.php | 15 +- web/admin/ap/art_section.php | 2 + web/admin/ap/art_vent.php | 1 + web/admin/ap/banner.php | 2 + web/admin/ap/cash_ie.php | 1 + web/admin/ap/cash_in.php | 1 + web/admin/ap/cash_out_1.php | 2 + web/admin/ap/cash_out_2.php | 1 + web/admin/ap/demo.php | 40 ++-- web/admin/ap/paper.go | 4 +- web/admin/ap/paper.php | 10 +- web/admin/ap/pnt_bundle.php | 11 +- web/admin/ap/pnt_buy.php | 1 + web/admin/ap/pnt_record.php | 1 + web/admin/ap/pnt_track.php | 2 + web/admin/ap/user.php | 6 +- web/admin/ap/user_service.php | 2 + web/admin/ap/usr_buy_bundle.php | 11 +- web/admin/ap/usr_buy_user.php | 1 + web/admin/ap/usr_capcode.php | 1 + web/admin/ap/usr_invoicetitle.php | 2 + web/admin/ap/usr_invoicing.php | 2 + web/admin/ap/usr_problem.php | 1 + web/admin/ap/usr_real_apply.php | 2 + web/admin/ap/usr_shipaddr.php | 2 + web/admin/ap/usr_suggest.php | 2 + web/admin/autotask/at_base.php | 104 ++++------ web/admin/autotask/task.php | 9 +- web/admin/cemap/bill.php | 2 + web/admin/cemap/ceeditor.php | 40 ++-- web/admin/cemap/glb.php | 6 +- web/admin/cemap/pathbill.php | 4 + web/admin/cemap/pathglb.php | 4 + web/admin/common.js | 2 +- web/admin/common.php | 8 +- web/admin/demo/demo_ajax.html | 1 + web/admin/demo/demo_button.html | 164 ++++++++++++++++ web/admin/demo/demo_ecc_ukey_ad.html | 280 +++++++++++++++++++++++++++ web/admin/demo/demo_ecc_ukey_ad.php | 26 +++ web/admin/demo/demo_rsa.html | 181 +++++++++++++++++ web/admin/demo/demo_rsa.php | 56 ++++++ web/admin/demo/demo_web3.html | 120 ++++++++++++ web/admin/demo/demo_web3.php | 42 ++++ web/admin/demo/form_checkbox.html | 10 + web/admin/demo/index.html | 24 +++ web/admin/demo/tool_alipaycb.html | 113 +++++++++++ web/admin/demo/tool_realip.html | 64 ++++++ web/admin/demo/tool_realip.php | 79 ++++++++ web/admin/develop/code_create.html | 26 ++- web/admin/develop/code_create.php | 46 +++-- web/admin/develop/code_list.html | 151 ++++----------- web/admin/develop/code_list.php | 10 +- web/admin/develop/code_mb_vue3.php | 2 +- web/admin/develop/code_pc_html.php | 96 ++++++--- web/admin/develop/code_pc_php.php | 139 +++++++++---- web/admin/develop/code_saas.html | 143 ++++++++++++++ web/admin/develop/code_saas.php | 150 ++++++++++++++ web/admin/develop/note.php | 1 + web/admin/index.go | 7 +- web/admin/index.html | 34 ++-- web/admin/index.php | 4 + web/admin/login.html | 5 +- web/admin/login.php | 10 +- web/admin/rigger/admin.php | 32 ++- web/admin/rigger/autotask.php | 7 +- web/admin/rigger/autotskrun.php | 1 + web/admin/rigger/cata.html | 2 +- web/admin/rigger/cata.php | 11 +- web/admin/rigger/cataindex.php | 11 +- web/admin/rigger/chgpass.html | 20 +- web/admin/rigger/chgpass.php | 18 +- web/admin/rigger/config.php | 6 +- web/admin/rigger/debug_user.php | 6 +- web/admin/rigger/depart.php | 4 + web/admin/rigger/funcslow.php | 1 + web/admin/rigger/logdb.php | 2 + web/admin/rigger/menu.php | 8 +- web/admin/rigger/mock.php | 6 +- web/admin/rigger/online.php | 1 + web/admin/rigger/power.php | 6 +- web/admin/rigger/role.php | 1 + web/admin/rigger/role_u.php | 1 + web/admin/rigger/statsdb.php | 4 +- web/admin/rigger/statsfunc.php | 1 + web/admin/welcome.html | 8 +- web/admin/welcome.php | 62 ++---- web/ambap/aiapi.php | 2 +- web/ambap/common.php | 6 +- web/ambap/demo/demo.php | 42 ++-- web/ambap/login.php | 2 +- web/ambap/me.php | 10 +- web/ambap/wxpay.php | 24 ++- web/api/craw.php | 24 ++- web/api/v1.php | 145 ++++++++++++++ web/api/v1_test.php | 93 +++++++++ web/docs/manage.php | 5 + web/jscss/ciy.js | 143 +++++++++++--- web/jscss/ciycmp.js | 7 +- web/jscss/ciytable.js | 6 +- web/jscss/style.css | 83 +++++++- web/projectcomm.php | 1 + web/z/index.php | 1 + zciyphp/comm.php | 177 ++++++++++------- zciyphp/db.php | 4 +- zciyphp/http.php | 50 ++++- zciyphp/openai.php | 4 +- zciyphp/pdo.php | 2 +- zciyphp/post.php | 12 +- zciyphp/sql.php | 10 +- zciyphp/upload.php | 2 +- zciyphp/wxfunc.php | 28 +-- 114 files changed, 3136 insertions(+), 653 deletions(-) create mode 100644 fork/fork_apinotify.php create mode 100644 fork/fork_order.php create mode 100644 web/admin/demo/demo_button.html create mode 100644 web/admin/demo/demo_ecc_ukey_ad.html create mode 100644 web/admin/demo/demo_ecc_ukey_ad.php create mode 100644 web/admin/demo/demo_rsa.html create mode 100644 web/admin/demo/demo_rsa.php create mode 100644 web/admin/demo/demo_web3.html create mode 100644 web/admin/demo/demo_web3.php create mode 100644 web/admin/demo/tool_alipaycb.html create mode 100644 web/admin/demo/tool_realip.html create mode 100644 web/admin/demo/tool_realip.php create mode 100644 web/admin/develop/code_saas.html create mode 100644 web/admin/develop/code_saas.php create mode 100644 web/api/v1.php create mode 100644 web/api/v1_test.php create mode 100644 web/projectcomm.php diff --git a/.gitignore b/.gitignore index 89e6cac..c8bbe8b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,12 @@ *.pem *.log *.glb +*.zip +*.rar +*.pdf +*.docx +*.xls +*.doc *.gltf *.mp3 *.mp4 @@ -20,5 +26,6 @@ web/ud/2026/* web/ud/2027/* web/ud/2028/* **/unpackage/ +**/tmp/ web.ini diff --git a/fork/fork_apinotify.php b/fork/fork_apinotify.php new file mode 100644 index 0000000..475b20c --- /dev/null +++ b/fork/fork_apinotify.php @@ -0,0 +1,185 @@ + 0) { + //echo "pcntl_wexitstatus: $status\n"; + //$exitCode = pcntl_wexitstatus($status); + //echo "子进程退出,状态码: $exitCode\n"; + $currentProcesses--; + if ($currentProcesses < 0) + $currentProcesses = 0; + } +}); +function outlog($msg) { + savelogfile('fork_apinotify', $msg); +} +function mainProcess() { + global $shouldStop, $currentProcesses, $logpath; + $db = new \ciy\db(); + $maxProcesses = 30; //1GB=15-20个进程 + $batchSize = 20; // 每次批量获取的记录数 + $spawnInterval = 100; // 子进程启动间隔(毫秒) + // 安装SIGCHLD信号处理器,避免僵尸进程 + + outlog('主进程启动,PID: ' . getmypid()); + $isbusy = false; + while (true) { + pcntl_signal_dispatch(); + if ($shouldStop) { + $time = time(); + while ($currentProcesses > 0 && $time > time() - 60) { + pcntl_signal_dispatch(); + sleep(1); + } + outlog('已关闭:' . $currentProcesses); + exit(0); + } + + if ($currentProcesses >= $maxProcesses) { + //echo "达到最大子进程数限制 ($maxProcesses),等待子进程退出...\n"; + sleep(1); + continue; + } + file_put_contents($logpath . 'fork_apinotify.tak', 'curr=' . $currentProcesses . ',max=' . $maxProcesses . ',batch=' . $batchSize . ',spawn=' . $spawnInterval . ',time=' . time()); + + $csql = new \ciy\sql('ap_transfer'); + //默认nexttimes=9999999999999,有90/100通知后,nexttimes=0,等待推送。 + //推成功,nexttimes=9999999999998 + //没成功,首次retimes=now,nexttimes=now+retimesspan+10s,直至24小时后=9999999999997 + //retimes>0判断是否有二次推送,判断商户api质量 + //nexttimes=9999999999997,判断是否始终推送失败,判断商户api接入能力 + //nexttimes=9999999999996,fork执行脚本非法跳出bug,或强制关闭导致 + $csql->where('nexttimes<', time()); + $csql->limit(1, $batchSize); + $orderrows = $db->get($csql); + if ($orderrows === false || count($orderrows) == 0) { + //echo "没有待处理任务,等待3秒...\n"; + sleep(3); + continue; + } + //outlog('发现待处理任务: ' . count($notifyrows) . '个'); + foreach ($orderrows as $orderrow) { + if (empty($orderrow['notifyurl'])) + continue; + if ($currentProcesses >= $maxProcesses) { + if (!$isbusy) + outlog('任务拥堵:' . $currentProcesses . '/' . $maxProcesses); + $isbusy = true; + sleep(3); + break; + } + if ($currentProcesses < $maxProcesses / 2) { + if ($isbusy) + outlog('拥堵暂缓:' . $currentProcesses . '/' . $maxProcesses); + $isbusy = false; + } + $pid = pcntl_fork(); + if ($pid == -1) { + outlog('创建子进程失败:' . pcntl_strerror(posix_get_last_error())); + } elseif ($pid) { + //echo "创建子进程成功,PID: $pid, 处理任务 ID: $id\n"; + $currentProcesses++; + usleep($spawnInterval * 1000); + } else { + //echo "子进程开始执行任务,PID: " . getmypid() . ", 任务 ID: $id\n"; + fork_apinotify($orderrow); + exit; + } + } + usleep(500 * 1000); + } +} +if (!extension_loaded('pcntl')) { + die("PCNTL扩展未加载,无法使用多进程功能\n"); +} +mainProcess(); + +function fork_apinotify($orderrow, $debug = false) { + $db = new \ciy\db(); + $id = $orderrow['id']; + $updata = array(); + $updata['nexttimes'] = 9999999999996; + $csql = new \ciy\sql('ap_transfer'); + $csql->where('id', $id); + $db->update($csql, $updata); + //orderrow就是数据集,再加上时间戳、sign、pairsign + $retapi = $orderrow; + unset($retapi['signature']); + $signstr = ''; + ksort($retapi); + foreach ($retapi as $key => $value) { + $signstr .= $key . '=' . $value . '&'; + } + $signstr = substr($signstr, 0, -1); + $sign = sha256($signstr); + $retapi['hash'] = $sign; + + $http = new \ciy\http(); + $http->set_timeout(10); + $http->request($orderrow['notifyurl'], json_encode($retapi)); + $result = $http->get_data(); + if (strpos($result, 'success') !== false) { + $updata = array(); + $updata['nexttimes'] = 9999999999998; + $csql = new \ciy\sql('ap_transfer'); + $csql->where('id', $id); + if ($db->update($csql, $updata) === false) { + if ($debug) clog('操作notify失败succ:' . $db->error); + savelogfile('err_db', '操作notify失败succ:' . $db->error); + } + } else { + $updata = array(); + $retimes = $orderrow['retimes']; + $time = time(); + if ($retimes == 0) { + $updata['retimes'] = $time; + $updata['nexttimes'] = $time + 10; + } else { + $time = $time + ($time - $retimes) + 10; + if ($time - $retimes < 136400) + $updata['nexttimes'] = $time + ($time - $retimes) + 10; + else + $updata['nexttimes'] = 9999999999997; + } + $csql = new \ciy\sql('ap_transfer'); + $csql->where('id', $id); + if ($db->update($csql, $updata) === false) { + if ($debug) clog('操作notify失败fail:' . $db->error); + savelogfile('err_db', '操作notify失败fail:' . $db->error); + } + } + exit(1); +} \ No newline at end of file diff --git a/fork/fork_order.php b/fork/fork_order.php new file mode 100644 index 0000000..cc037d1 --- /dev/null +++ b/fork/fork_order.php @@ -0,0 +1,206 @@ + 0) { + //echo "pcntl_wexitstatus: $status\n"; + //$exitCode = pcntl_wexitstatus($status); + //echo "子进程退出,状态码: $exitCode\n"; + $currentProcesses--; + if ($currentProcesses < 0) + $currentProcesses = 0; + } +}); +function outlog($msg) { + savelogfile('fork_order', $msg); +} +function mainProcess() { + global $shouldStop, $currentProcesses, $logpath; + $db = new \ciy\db(); + $maxProcesses = 30; //1GB=15-20个进程 + $batchSize = 20; // 每次批量获取的记录数 + $spawnInterval = 100; // 子进程启动间隔(毫秒) + // 安装SIGCHLD信号处理器,避免僵尸进程 + + outlog('主进程启动,PID: ' . getmypid()); + $isbusy = false; + while (true) { + pcntl_signal_dispatch(); + if ($shouldStop) { + $time = time(); + while ($currentProcesses > 0 && $time > time() - 60) { + pcntl_signal_dispatch(); + sleep(1); + } + outlog('已关闭:' . $currentProcesses); + exit(0); + } + + if ($currentProcesses >= $maxProcesses) { + //echo "达到最大子进程数限制 ($maxProcesses),等待子进程退出...\n"; + sleep(1); + continue; + } + file_put_contents($logpath . 'fork_order.tak', 'curr=' . $currentProcesses . ',max=' . $maxProcesses . ',batch=' . $batchSize . ',spawn=' . $spawnInterval . ',time=' . time()); + + $csql = new \ciy\sql('ap_transfer'); + $csql->where('orderstatus=20'); + $csql->limit(1, $batchSize); + $orderrows = $db->get($csql); + if ($orderrows === false || count($orderrows) == 0) { + //echo "没有待处理任务,等待3秒...\n"; + sleep(3); + continue; + } + //outlog('发现待处理任务: ' . count($orderrows) . '个'); + foreach ($orderrows as $orderrow) { + if ($currentProcesses >= $maxProcesses) { + if (!$isbusy) + outlog('任务拥堵:' . $currentProcesses . '/' . $maxProcesses); + $isbusy = true; + sleep(3); + break; + } + if ($currentProcesses < $maxProcesses / 2) { + if ($isbusy) + outlog('拥堵暂缓:' . $currentProcesses . '/' . $maxProcesses); + $isbusy = false; + } + $pid = pcntl_fork(); + if ($pid == -1) { + outlog('创建子进程失败:' . pcntl_strerror(posix_get_last_error())); + } elseif ($pid) { + //echo "创建子进程成功,PID: $pid, 处理任务 ID: $id\n"; + $currentProcesses++; + usleep($spawnInterval * 1000); + } else { + //echo "子进程开始执行任务,PID: " . getmypid() . ", 任务 ID: $id\n"; + fork_order($orderrow); + exit; + } + } + usleep(500 * 1000); + } +} +if (!extension_loaded('pcntl')) { + die("PCNTL扩展未加载,无法使用多进程功能\n"); +} +mainProcess(); + +function fork_order($orderrow, $debug = false) { + $db = new \ciy\db(); + $id = $orderrow['id']; + $updata = array(); + $updata['orderstatus'] = 30; + $csql = new \ciy\sql('ap_transfer'); + $csql->where('id', $id); + if ($db->update($csql, $updata) === false) { + if ($debug) clog('操作status=30:' . $db->error); + savelogfile('err_db', '操作status=30:' . $db->error); + exit(1); + } + //验签一次,验签失败,则90错误 + $fail = null; + if (!empty($orderrow['signature'])) { + $csql = new \ciy\sql('ap_api'); + $csql->where('id', $orderrow['apiid']); + $apirow = $db->getone($csql); + if (!is_array($apirow)) + $fail = array('errmsg' => 'API未找到', 'status' => 90); + else { + if (empty($apirow['pubkey'])) { + $fail = array('errmsg' => '数字证书无公钥', 'status' => 90); + } else { + $waitsignstr = 'amount=' . $orderrow['amount'] . ',addtimes=' . $orderrow['addtimes']; + $retsign = verifysign_api($apirow['pubkey'], $orderrow['signature'], $waitsignstr); + if (is_string($retsign)) + $fail = array('errmsg' => $retsign, 'status' => 90); + } + } + } + //$fail = array('errmsg' => $ret, 'status' => 90); //处理具体业务,失败赋值 + + if ($fail) { + try { + $db->begin(); + $updata = array(); + $updata['uptimes'] = tostamp(); + $updata['orderstatus'] = $fail['status']; + if ($fail['status'] == 90) + $updata['nexttimes'] = 0; + $csql = new \ciy\sql('ap_transfer'); + $csql->where('id', $id); + if ($db->update($csql, $updata) === false) + throw new \Exception('操作order fail失败:' . $db->error); + $db->commit(); + } catch (\Exception $ex) { + $db->rollback(); + savelogfile('err_db', $ex->getMessage()); + } + exit(4); + }else{ + try { + $db->begin(); + $updata = array(); + $updata['uptimes'] = tostamp(); + $updata['orderstatus'] = 100; + $updata['nexttimes'] = 0; + $csql = new \ciy\sql('ap_transfer'); + $csql->where('id', $id); + if ($db->update($csql, $updata) === false) + throw new \Exception('操作order succ失败:' . $db->error); + $db->commit(); + } catch (\Exception $ex) { + $db->rollback(); + savelogfile('err_db', $ex->getMessage()); + } + exit(0); + } +} + +function verifysign_api($signKey, $signature, $waitsignstr) { + if (strpos($signKey, '-----BEGIN RSA PUBLIC KEY-----') === false && strpos($signKey, '-----BEGIN PUBLIC KEY-----') === false) + $signKey = "-----BEGIN PUBLIC KEY-----\n" . wordwrap($signKey, 64, "\n") . "\n-----END PUBLIC KEY-----"; + $signbin = hex2bin($signature); + if ($signbin === false) + return errjson('签名格式错误'); + $hashbin = hex2bin(hash('sha256', $waitsignstr)); + $result = openssl_verify($hashbin, $signbin, $signKey, OPENSSL_ALGO_SHA256); + if ($result === 0) + return '数字证书验签失败'; + else if ($result !== 1) + return '数字证书验签错误:' . openssl_error_string(); + return true; +} diff --git a/web/admin/ap/art_post.php b/web/admin/ap/art_post.php index 0b07eb8..78523d5 100644 --- a/web/admin/ap/art_post.php +++ b/web/admin/ap/art_post.php @@ -106,7 +106,7 @@ class art_post { return errjson('请填写排序位'); if (empty($name)) return errjson('请填写文章标题'); - if (empty($content)) + if ($content == '[MD]') return errjson('请填写内容'); $datarow = null; if ($id > 0) { @@ -161,6 +161,7 @@ class art_post { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -214,6 +215,7 @@ class art_post { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; @@ -375,7 +377,7 @@ class art_post { else { $csqlchk = new \ciy\sql('ap_art_post'); $csqlchk->where('id', $id)->column('id'); - $chkid = (int)$db->get1($csqlchk); + $chkid = toint($db->get1($csqlchk)); if ($chkid != $id) $errmsg = $name . '在数据库中不存在'; $value = $id; @@ -389,7 +391,7 @@ class art_post { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)$showdat; + $value = toint($showdat); } } else if ($name == '文章状态') { if (empty($showdat)) { @@ -430,7 +432,7 @@ class art_post { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)$showdat; + $value = toint($showdat); } } else if ($name == '阅读数') { if (empty($showdat)) { @@ -440,7 +442,7 @@ class art_post { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)$showdat; + $value = toint($showdat); } } else if ($name == '摘要') { if (empty($showdat)) { @@ -483,7 +485,7 @@ class art_post { else { $uniques[] = $unq; $csql->column('id'); - $chkid = (int)$db->get1($csql); + $chkid = toint($db->get1($csql)); if ($chkid > 0 && (($id > 0 && $chkid != $id) || $id == 0)) $firsthtml = '
重复
'; } @@ -533,6 +535,7 @@ class art_post { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } return succjson(); diff --git a/web/admin/ap/art_section.php b/web/admin/ap/art_section.php index 3106beb..0a7d20a 100644 --- a/web/admin/ap/art_section.php +++ b/web/admin/ap/art_section.php @@ -93,6 +93,7 @@ class art_section { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -125,6 +126,7 @@ class art_section { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/art_vent.php b/web/admin/ap/art_vent.php index aa99c77..e1fdeb9 100644 --- a/web/admin/ap/art_vent.php +++ b/web/admin/ap/art_vent.php @@ -111,6 +111,7 @@ class art_vent { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/banner.php b/web/admin/ap/banner.php index a185a72..c12574f 100644 --- a/web/admin/ap/banner.php +++ b/web/admin/ap/banner.php @@ -87,6 +87,7 @@ class banner { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -119,6 +120,7 @@ class banner { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/cash_ie.php b/web/admin/ap/cash_ie.php index ee9ea16..e8c8163 100644 --- a/web/admin/ap/cash_ie.php +++ b/web/admin/ap/cash_ie.php @@ -121,6 +121,7 @@ class cash_ie { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/cash_in.php b/web/admin/ap/cash_in.php index 8779b86..59735f4 100644 --- a/web/admin/ap/cash_in.php +++ b/web/admin/ap/cash_in.php @@ -123,6 +123,7 @@ class cash_in { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/cash_out_1.php b/web/admin/ap/cash_out_1.php index 040d7ff..68258e6 100644 --- a/web/admin/ap/cash_out_1.php +++ b/web/admin/ap/cash_out_1.php @@ -111,6 +111,7 @@ class cash_out_1 { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -146,6 +147,7 @@ class cash_out_1 { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/cash_out_2.php b/web/admin/ap/cash_out_2.php index 609ce59..8507fe7 100644 --- a/web/admin/ap/cash_out_2.php +++ b/web/admin/ap/cash_out_2.php @@ -97,6 +97,7 @@ class cash_out_2 { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; diff --git a/web/admin/ap/demo.php b/web/admin/ap/demo.php index 7692086..51ebafc 100644 --- a/web/admin/ap/demo.php +++ b/web/admin/ap/demo.php @@ -240,6 +240,7 @@ class demo { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -273,6 +274,7 @@ class demo { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; @@ -317,6 +319,7 @@ class demo { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -595,7 +598,7 @@ class demo { else { $csqlchk = new \ciy\sql('ap_demo'); $csqlchk->where('id', $id)->column('id'); - $chkid = (int)$db->get1($csqlchk); + $chkid = toint($db->get1($csqlchk)); if ($chkid != $id) $errmsg = $name . '在数据库中不存在'; $value = $id; @@ -622,7 +625,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 1024); + $value = toint((float)$showdat * 1024); $showdat .= 'KB'; } } else if ($name == '长度') { @@ -633,7 +636,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 1000); + $value = toint((float)$showdat * 1000); $showdat .= '米'; } } else if ($name == '贷款金额') { @@ -644,7 +647,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 1000000); + $value = toint((float)$showdat * 1000000); $showdat .= '万元'; } } else if ($name == '设置日期') { @@ -805,7 +808,7 @@ class demo { $value = 0; } else { $last = substr($showdat, -3); - $dd = (int)substr($showdat, 0, -3); + $dd = toint(substr($showdat, 0, -3)); if ($dd == 0) { $errmsg = $name . '周期数字错误'; } else if ($last == '天') { @@ -826,7 +829,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)$showdat; + $value = toint($showdat); $showdat .= '秒'; } } else if ($name == '活动期数') { @@ -837,7 +840,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)$showdat; + $value = toint($showdat); } } else if ($name == '吨位') { if (empty($showdat)) { @@ -847,7 +850,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 1000000); + $value = toint((float)$showdat * 1000000); $showdat .= '吨'; } } else if ($name == '单价') { @@ -858,7 +861,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 100); + $value = toint((float)$showdat * 100); } } else if ($name == '位置') { if (empty($showdat)) { @@ -888,7 +891,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 100); + $value = toint((float)$showdat * 100); $showdat .= '%'; } } else if ($name == '链接') { @@ -904,7 +907,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 1000); + $value = toint((float)$showdat * 1000); $showdat .= 'KG'; } } else if ($name == '耳温') { @@ -915,7 +918,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 1000); + $value = toint((float)$showdat * 1000); $showdat .= '℃'; } } else if ($name == '中式钱') { @@ -926,7 +929,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 100); + $value = toint((float)$showdat * 100); $showdat .= '元'; } } else if ($name == '美式钱') { @@ -937,7 +940,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 100); + $value = toint((float)$showdat * 100); $showdat .= '¤'; } } else if ($name == '重量') { @@ -948,7 +951,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 1000); + $value = toint((float)$showdat * 1000); $showdat .= 'KG'; } } else if ($name == '长度') { @@ -959,7 +962,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 1000); + $value = toint((float)$showdat * 1000); $showdat .= '米'; } } else if ($name == '科学数') { @@ -970,7 +973,7 @@ class demo { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 1000); + $value = toint((float)$showdat * 1000); $showdat .= 'SKT'; } } else if ($name == '身份证号') { @@ -1000,7 +1003,7 @@ class demo { else { $uniques[] = $unq; $csql->column('id'); - $chkid = (int)$db->get1($csql); + $chkid = toint($db->get1($csql)); if ($chkid > 0 && (($id > 0 && $chkid != $id) || $id == 0)) $firsthtml = '
重复
'; } @@ -1076,6 +1079,7 @@ class demo { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } return succjson(); diff --git a/web/admin/ap/paper.go b/web/admin/ap/paper.go index a18955e..6d280e8 100644 --- a/web/admin/ap/paper.go +++ b/web/admin/ap/paper.go @@ -96,8 +96,8 @@ func Paper_update(w http.ResponseWriter, r *http.Request) bool { if name == "" { return c.ErrJSON(w, "请填写文档标题") } - content := post.Get("content", c.CIYPOST_ALLOW_HTML) - if content == "" { + content := post.Get("content") + if content == "[MD]" { return c.ErrJSON(w, "请填写内容") } var err error diff --git a/web/admin/ap/paper.php b/web/admin/ap/paper.php index d59ea6a..236bd9f 100644 --- a/web/admin/ap/paper.php +++ b/web/admin/ap/paper.php @@ -85,8 +85,8 @@ class paper { $title = $post->get('title'); if (empty($name)) return errjson('请填写文档标题'); - $content = $post->get('content', '', 'html'); - if (empty($content)) + $content = $post->get('content'); + if ($content == '[MD]') return errjson('请填写内容'); $datarow = null; if ($id > 0) { @@ -102,9 +102,9 @@ class paper { $csql = new \ciy\sql('ap_paper'); $csql->where('name', $name); $csql->column('id'); - $chkid = (int)$db->get1($csql); + $chkid = toint($db->get1($csql)); if ($chkid > 0 && (($id > 0 && $chkid != $id) || $id == 0)) - throw new \Exception('数据已存在'); + throw new \Exception('CIYIGN数据已存在'); $updata = array(); $updata['name'] = $name; @@ -127,6 +127,7 @@ class paper { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -174,6 +175,7 @@ class paper { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/pnt_bundle.php b/web/admin/ap/pnt_bundle.php index 1ec01fc..2425c8c 100644 --- a/web/admin/ap/pnt_bundle.php +++ b/web/admin/ap/pnt_bundle.php @@ -88,6 +88,7 @@ class pnt_bundle { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -120,6 +121,7 @@ class pnt_bundle { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; @@ -242,7 +244,7 @@ class pnt_bundle { else { $csqlchk = new \ciy\sql('ap_pnt_bundle'); $csqlchk->where('id', $id)->column('id'); - $chkid = (int)$db->get1($csqlchk); + $chkid = toint($db->get1($csqlchk)); if ($chkid != $id) $errmsg = $name . '在数据库中不存在'; $value = $id; @@ -256,7 +258,7 @@ class pnt_bundle { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)$showdat; + $value = toint($showdat); } } else if ($name == '金额') { if (empty($showdat)) { @@ -266,7 +268,7 @@ class pnt_bundle { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 100); + $value = toint((float)$showdat * 100); } } if (!empty($showdat)) @@ -285,7 +287,7 @@ class pnt_bundle { else { $uniques[] = $unq; $csql->column('id'); - $chkid = (int)$db->get1($csql); + $chkid = toint($db->get1($csql)); if ($chkid > 0 && (($id > 0 && $chkid != $id) || $id == 0)) $firsthtml = '
重复
'; } @@ -326,6 +328,7 @@ class pnt_bundle { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } return succjson(); diff --git a/web/admin/ap/pnt_buy.php b/web/admin/ap/pnt_buy.php index c569d90..d83b824 100644 --- a/web/admin/ap/pnt_buy.php +++ b/web/admin/ap/pnt_buy.php @@ -123,6 +123,7 @@ class pnt_buy { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/pnt_record.php b/web/admin/ap/pnt_record.php index 3870399..045e552 100644 --- a/web/admin/ap/pnt_record.php +++ b/web/admin/ap/pnt_record.php @@ -94,6 +94,7 @@ class pnt_record { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/pnt_track.php b/web/admin/ap/pnt_track.php index c104ba4..9aced1d 100644 --- a/web/admin/ap/pnt_track.php +++ b/web/admin/ap/pnt_track.php @@ -91,6 +91,7 @@ class pnt_track { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -123,6 +124,7 @@ class pnt_track { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/user.php b/web/admin/ap/user.php index e6e1ea6..fb901b9 100644 --- a/web/admin/ap/user.php +++ b/web/admin/ap/user.php @@ -101,7 +101,7 @@ class user { public static function json_update() { global $db; - global $tokensalt; + global $_token; $rsuser = verifyfast(); //if (nopower($db, $rsuser['id'], 'p u')) // return errjson('您未被授权操作'); @@ -128,7 +128,7 @@ class user { $updata['mobile'] = $mobile; $updata['stpstatus'] = $stpstatus; if(!empty($repass)) - $updata['password'] = md5($repass . $tokensalt); + $updata['password'] = md5($repass . $_token['salt']); $updata['addtimes'] = tostamp(); $updata['memo'] = $memo; $csql = new \ciy\sql('ap_user'); @@ -140,6 +140,7 @@ class user { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } if ($post->get('_pf') == 'PC') @@ -189,6 +190,7 @@ class user { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } return succjson(); diff --git a/web/admin/ap/user_service.php b/web/admin/ap/user_service.php index fc89cac..4c4c72d 100644 --- a/web/admin/ap/user_service.php +++ b/web/admin/ap/user_service.php @@ -136,6 +136,7 @@ class user_service { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } if ($post->get('_pf') == 'PC') @@ -185,6 +186,7 @@ class user_service { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } return succjson(); diff --git a/web/admin/ap/usr_buy_bundle.php b/web/admin/ap/usr_buy_bundle.php index 9ab7b3a..453bb89 100644 --- a/web/admin/ap/usr_buy_bundle.php +++ b/web/admin/ap/usr_buy_bundle.php @@ -100,6 +100,7 @@ class usr_buy_bundle { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -132,6 +133,7 @@ class usr_buy_bundle { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; @@ -262,7 +264,7 @@ class usr_buy_bundle { else { $csqlchk = new \ciy\sql('ap_usr_buy_bundle'); $csqlchk->where('id', $id)->column('id'); - $chkid = (int)$db->get1($csqlchk); + $chkid = toint($db->get1($csqlchk)); if ($chkid != $id) $errmsg = $name . '在数据库中不存在'; $value = $id; @@ -289,7 +291,7 @@ class usr_buy_bundle { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)$showdat; + $value = toint($showdat); } } else if ($name == '金额') { if (empty($showdat)) { @@ -299,7 +301,7 @@ class usr_buy_bundle { if (!is_numeric($showdat)) $errmsg = $name . '不是数字'; else - $value = (int)((float)$showdat * 100); + $value = toint((float)$showdat * 100); } } if (!empty($showdat)) @@ -318,7 +320,7 @@ class usr_buy_bundle { else { $uniques[] = $unq; $csql->column('id'); - $chkid = (int)$db->get1($csql); + $chkid = toint($db->get1($csql)); if ($chkid > 0 && (($id > 0 && $chkid != $id) || $id == 0)) $firsthtml = '
重复
'; } @@ -361,6 +363,7 @@ class usr_buy_bundle { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } return succjson(); diff --git a/web/admin/ap/usr_buy_user.php b/web/admin/ap/usr_buy_user.php index 1a82841..b5ee557 100644 --- a/web/admin/ap/usr_buy_user.php +++ b/web/admin/ap/usr_buy_user.php @@ -144,6 +144,7 @@ class usr_buy_user { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/usr_capcode.php b/web/admin/ap/usr_capcode.php index d64a46e..f7b25a2 100644 --- a/web/admin/ap/usr_capcode.php +++ b/web/admin/ap/usr_capcode.php @@ -116,6 +116,7 @@ class usr_capcode { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/usr_invoicetitle.php b/web/admin/ap/usr_invoicetitle.php index 4f4130a..41d468e 100644 --- a/web/admin/ap/usr_invoicetitle.php +++ b/web/admin/ap/usr_invoicetitle.php @@ -104,6 +104,7 @@ class usr_invoicetitle { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -137,6 +138,7 @@ class usr_invoicetitle { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/usr_invoicing.php b/web/admin/ap/usr_invoicing.php index bbe3299..a2d1a97 100644 --- a/web/admin/ap/usr_invoicing.php +++ b/web/admin/ap/usr_invoicing.php @@ -117,6 +117,7 @@ class usr_invoicing { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -151,6 +152,7 @@ class usr_invoicing { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/usr_problem.php b/web/admin/ap/usr_problem.php index 1ba0b38..f77fdd1 100644 --- a/web/admin/ap/usr_problem.php +++ b/web/admin/ap/usr_problem.php @@ -164,6 +164,7 @@ class usr_problem { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/usr_real_apply.php b/web/admin/ap/usr_real_apply.php index 9e4b691..cd0cc66 100644 --- a/web/admin/ap/usr_real_apply.php +++ b/web/admin/ap/usr_real_apply.php @@ -111,6 +111,7 @@ class usr_real_apply { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; @@ -155,6 +156,7 @@ class usr_real_apply { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; diff --git a/web/admin/ap/usr_shipaddr.php b/web/admin/ap/usr_shipaddr.php index a7e69bc..a1b1855 100644 --- a/web/admin/ap/usr_shipaddr.php +++ b/web/admin/ap/usr_shipaddr.php @@ -98,6 +98,7 @@ class usr_shipaddr { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -131,6 +132,7 @@ class usr_shipaddr { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/ap/usr_suggest.php b/web/admin/ap/usr_suggest.php index b7339fd..43aa1e3 100644 --- a/web/admin/ap/usr_suggest.php +++ b/web/admin/ap/usr_suggest.php @@ -98,6 +98,7 @@ class usr_suggest { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -131,6 +132,7 @@ class usr_suggest { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/autotask/at_base.php b/web/admin/autotask/at_base.php index 6b56442..d59688a 100644 --- a/web/admin/autotask/at_base.php +++ b/web/admin/autotask/at_base.php @@ -2,41 +2,45 @@ function base_dayclean($systemrow) { global $db; $msg = ''; + $msg .= _base_deldb($db, (new \ciy\sql('zc_autotsk_run'))->where('addtimes<', time() - 86400 * 90)); + $msg .= _base_deldb($db, (new \ciy\sql('zc_autotsk_log'))->where('addtimes<', time() - 86400 * 90)); + $msg .= _base_deldb($db, (new \ciy\sql('zc_funcslow'))->where('addtimes<', time() - 86400 * 60)); + $msg .= _base_deldb($db, (new \ciy\sql('zc_stats'))->where('addtimes<', time() - 86400 * 60)); + $msg .= _base_deldb($db, (new \ciy\sql('zc_log'))->where('addtimes<', time() - 86400 * 100)); + $msg .= _base_deldb($db, (new \ciy\sql('zc_online'))->where('exptimes<', time() - 86400 * 7)); - $execute = $db->execute('delete from zc_autotsk_run where addtimes<' . (time() - 86400 * 30)); + $cnt = 0;$msg .= _base_delfile(PATH_WEB . 'ud/tmp', 86400 * 3, $cnt); + $cnt = 0;$msg .= _base_delfile(PATH_WEB . 'ud/rep', 86400 * 1, $cnt); + return $msg; +} +function _base_deldb($db, $csql) { + $execute = $db->delete($csql); if ($execute === false) - $msg .= 'clean zc_autotsk_run: ' . $db->error . '
'; + return 'clean ' . $csql->table . ': ' . $db->error . '
'; else if ($execute > 0) - $msg .= 'clean zc_autotsk_run: ' . $execute . '
'; - $execute = $db->execute('delete from zc_autotsk_run where msg=\'\' and addtimes<' . (time() - 86400 * 3)); - if ($execute === false) - $msg .= 'clean zc_autotsk_run B: ' . $db->error . '
'; - $execute = $db->execute('delete from ap_usr_capcode where exptimes<' . time()); - if ($execute === false) - $msg .= 'clean ap_usr_capcode: ' . $db->error . '
'; - else if ($execute > 0) - $msg .= 'clean ap_usr_capcode: ' . $execute . '
'; - $cnt = 0; - $errcnt = 0; - $files = scandir(PATH_WEB . 'ud/tmp/'); - foreach ($files as $file) { - if ($file[0] == '.') - continue; - $mtime = filemtime(PATH_WEB . 'ud/tmp/' . $file); - if ($mtime === false) - continue; - if (tostamp() - $mtime > 86400 * 3) { - $ret = _base_delall(PATH_WEB . 'ud/tmp/' . $file); - $cnt++; - if ($ret !== true) { - $errcnt++; - savelog($db, 0, 'CRON', '清理tmp文件失败【' . PATH_WEB . 'ud/tmp/' . $file . '】' . $ret); + return 'clean ' . $csql->table . ': ' . $execute . '
'; + return ''; +} +function _base_delfile($pathfile, $timespan, &$cnt, $deep = 0) { + if (!is_dir($pathfile)) { + $mtime = filemtime($pathfile); + if ($mtime !== false) { + if (tostamp() - $mtime > $timespan) { + $cnt++; + filedel($pathfile); } } + return; } - if ($cnt > 0 || $errcnt > 0) - $msg .= 'clean file: ' . $cnt . ($errcnt > 0 ? ', err: ' . $errcnt : '') . '
'; - return $msg; + $files = scandir($pathfile); + foreach ($files as $file) { + if ($file == '.' || $file == '..') + continue; + _base_delfile($pathfile . '/' . $file, $timespan, $cnt, 1); + } + if ($deep == 0 && $cnt > 0) + return 'clean file: ' . $cnt . ' ' . substr($pathfile, strlen(PATH_WEB)) . '
'; + return ''; } function base_srvstats($systemrow) { global $db; @@ -49,15 +53,15 @@ function base_srvstats($systemrow) { $memrows = $db->get($csql); foreach ($memrows as $memrow) { if ($memrow['types'] == 'func_succ') - $func_succ = (int)$memrow['params']; + $func_succ = toint($memrow['params']); else if ($memrow['types'] == 'func_fail') - $func_fail = (int)$memrow['params']; + $func_fail = toint($memrow['params']); else if ($memrow['types'] == 'func_commit') - $func_commit = (int)$memrow['params']; + $func_commit = toint($memrow['params']); else if ($memrow['types'] == 'func_rollback') - $func_rollback = (int)$memrow['params']; + $func_rollback = toint($memrow['params']); else if ($memrow['types'] == 'func_runms') { - $func_runms = (int)$memrow['params']; + $func_runms = toint($memrow['params']); } else continue; $updata = array(); @@ -146,7 +150,7 @@ function base_srvstats($systemrow) { $ls = explode(" ", $line); if ($ls[0] == 'LISTEN') continue; - $net_tcp += (int)$ls[1]; + $net_tcp += toint($ls[1]); } $starttime = timems(); @@ -162,9 +166,9 @@ function base_srvstats($systemrow) { $val = $dbrows[$i]['Value']; $dbstat[$name] = $val; } - $db_keyhit = (int)$dbstat['Handler_read_key'] / ((int)$dbstat['Com_select'] + 1) * 100; - $db_dbhit = (int)$dbstat['Innodb_buffer_pool_reads'] / ((int)$dbstat['Innodb_buffer_pool_read_requests'] + 1) * 100; - $db_tmptable = (int)$dbstat['Created_tmp_disk_tables'] / ((int)$dbstat['Created_tmp_tables'] + 1) * 100; + $db_keyhit = toint($dbstat['Handler_read_key']) / (toint($dbstat['Com_select']) + 1) * 100; + $db_dbhit = toint($dbstat['Innodb_buffer_pool_reads']) / (toint($dbstat['Innodb_buffer_pool_read_requests']) + 1) * 100; + $db_tmptable = toint($dbstat['Created_tmp_disk_tables']) / (toint($dbstat['Created_tmp_tables']) + 1) * 100; $updata = array(); $updata['func_succ'] = $func_succ; @@ -199,30 +203,6 @@ function base_srvstats($systemrow) { return ''; return 'succ: ' . $func_succ . ($func_rollback > 0 ? ', rollback: ' . $func_rollback : ''); } - -function _base_delall($path) { - try { - if (is_dir($path)) { - $p = scandir($path); - foreach ($p as $val) { - if ($val[0] == '.') - continue; - if (is_dir($path . '/' . $val)) { - _base_delall($path . '/' . $val); - } else { - unlink($path . '/' . $val); - } - } - rmdir($path); - } else { - unlink($path); - } - } catch (\Exception $ex) { - return $ex->getMessage(); - } - return true; -} - function _base_nextspace(&$line) { $ind = strpos($line, " "); if ($ind === false) { diff --git a/web/admin/autotask/task.php b/web/admin/autotask/task.php index fc78b68..b116dbf 100644 --- a/web/admin/autotask/task.php +++ b/web/admin/autotask/task.php @@ -61,6 +61,8 @@ class task { $csql = new \ciy\sql('zc_autotsk_run'); $csql->where('id', $runtaskid); $tskrunrow = $db->getone($csql); + if(!is_array($tskrunrow)) + return clog('任务运行记录不存在:' . $runtaskid); $csql = new \ciy\sql('zc_autotsk_log'); $csql->where('runtaskid', $runtaskid); $csql->column('addtimes,msg'); @@ -93,7 +95,7 @@ class task { return; $sysid = $taskrow['id']; $nexttimes = $taskrow['nexttimes']; - $runcycle = (int)$taskrow['runcycle']; + $runcycle = toint($taskrow['runcycle']); while (true) { if ($nexttimes > tostamp()) break; @@ -126,14 +128,14 @@ class task { $updata['msg'] = $runningmsg; $csql = new \ciy\sql('zc_autotsk_run'); $db->insert($csql, $updata); - return; + return $db->insert_id(); } $runlogstart = tostamp(); $updata = array(); $updata['autotaskid'] = $sysid; $updata['addtimes'] = $runlogstart; $csql = new \ciy\sql('zc_autotsk_run'); - $execute = $db->insert($csql, $updata); + $db->insert($csql, $updata); $runtaskid = $db->insert_id(); $taskrow['runtaskid'] = $runtaskid; $taskrow['runtimes'] = tostamp(); @@ -186,7 +188,6 @@ class task { $csql = new \ciy\sql('zc_autotsk_run'); $csql->where('id', $runtaskid); $db->update($csql, $updata); - return $runtaskid; } } diff --git a/web/admin/cemap/bill.php b/web/admin/cemap/bill.php index f3584a8..64b380e 100644 --- a/web/admin/cemap/bill.php +++ b/web/admin/cemap/bill.php @@ -109,6 +109,7 @@ class bill { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -141,6 +142,7 @@ class bill { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/cemap/ceeditor.php b/web/admin/cemap/ceeditor.php index bf36c6a..845330c 100644 --- a/web/admin/cemap/ceeditor.php +++ b/web/admin/cemap/ceeditor.php @@ -44,23 +44,31 @@ class ceeditor { $post = new \ciy\post(); $set = $post->get('set'); - $updata = array(); - $updata['tabname'] = $tabname; - $updata['tabid'] = $id; - $updata['mapjson'] = json_encode($set, JSON_PARTIAL_OUTPUT_ON_ERROR); - $updata['uptimes'] = tostamp(); - $csql = new \ciy\sql('zc_cemap_data'); - $csql->where('tabname', $tabname); - $csql->where('tabid', $id); - $datarow = $db->getone($csql); - if (is_array($datarow)){ + try { + $db->begin(); + $updata = array(); + $updata['tabname'] = $tabname; + $updata['tabid'] = $id; + $updata['mapjson'] = json_encode($set, JSON_PARTIAL_OUTPUT_ON_ERROR); + $updata['uptimes'] = tostamp(); $csql = new \ciy\sql('zc_cemap_data'); - $csql->where('id', $datarow['id']); - if ($db->update($csql, $updata) === false) - throw new \Exception('更新失败:' . $db->error); - } else { - if ($db->insert($csql, $updata) === false) - throw new \Exception('新增失败:' . $db->error); + $csql->where('tabname', $tabname); + $csql->where('tabid', $id); + $datarow = $db->getone($csql); + if (is_array($datarow)) { + $csql = new \ciy\sql('zc_cemap_data'); + $csql->where('id', $datarow['id']); + if ($db->update($csql, $updata) === false) + throw new \Exception('更新失败:' . $db->error); + } else { + if ($db->insert($csql, $updata) === false) + throw new \Exception('新增失败:' . $db->error); + } + $db->commit(); + } catch (\Exception $ex) { + $db->rollback(); + savelogfile('err_db', $ex->getMessage()); + return errjson($ex->getMessage()); } return succjson(); } diff --git a/web/admin/cemap/glb.php b/web/admin/cemap/glb.php index f80b44e..58c7ed2 100644 --- a/web/admin/cemap/glb.php +++ b/web/admin/cemap/glb.php @@ -86,9 +86,9 @@ class glb { $csql = new \ciy\sql('zc_cemap_glb'); $csql->where('name', $name); $csql->column('id'); - $chkid = (int)$db->get1($csql); + $chkid = toint($db->get1($csql)); if ($chkid > 0 && (($id > 0 && $chkid != $id) || $id == 0)) - throw new \Exception('数据已存在'); + throw new \Exception('CIYIGN数据已存在'); $updata = array(); $updata['cpath'] = $cpath; $updata['name'] = $name; @@ -108,6 +108,7 @@ class glb { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['data'] = $updata; @@ -140,6 +141,7 @@ class glb { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; diff --git a/web/admin/cemap/pathbill.php b/web/admin/cemap/pathbill.php index 405ae6f..9027d8c 100644 --- a/web/admin/cemap/pathbill.php +++ b/web/admin/cemap/pathbill.php @@ -60,6 +60,7 @@ class pathbill { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } return succjson(); @@ -86,6 +87,7 @@ class pathbill { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; @@ -113,6 +115,7 @@ class pathbill { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } return succjson(); @@ -143,6 +146,7 @@ class pathbill { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } if ($cnt == 0) diff --git a/web/admin/cemap/pathglb.php b/web/admin/cemap/pathglb.php index 5f9bcd2..6211e03 100644 --- a/web/admin/cemap/pathglb.php +++ b/web/admin/cemap/pathglb.php @@ -60,6 +60,7 @@ class pathglb { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } return succjson(); @@ -86,6 +87,7 @@ class pathglb { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } $ret['ids'] = $vids; @@ -113,6 +115,7 @@ class pathglb { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } return succjson(); @@ -143,6 +146,7 @@ class pathglb { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } if ($cnt == 0) diff --git a/web/admin/common.js b/web/admin/common.js index fd29a38..a3d41eb 100644 --- a/web/admin/common.js +++ b/web/admin/common.js @@ -1,6 +1,6 @@ var ciy_vars = { "tokenfield": "ciyadm" - , "tokensalt": "ast34h$2" + , "tokensalt": "ast34h$3" , "uploadurl": "admin/upload" , "loginurl": "admin/login.html" , "dupsec": 60 diff --git a/web/admin/common.php b/web/admin/common.php index 9de209c..d5e388e 100644 --- a/web/admin/common.php +++ b/web/admin/common.php @@ -96,7 +96,7 @@ function nopower($db, $userid, $chkpower) { return true; if (strlen($chkpower) < 3) return true; - if ($userid == 10) + if ($mepower == '.*.') //超级管理员 return false; $pows = explode('.', $mepower); foreach ($pows as $p) { @@ -155,13 +155,13 @@ function setconfig($db, $types, $value) { } function getcatas($db, $cbid, $table = 'zc_cata') { if (is_numeric($cbid)) { - $cbid = (int)$cbid; + $cbid = toint($cbid); } else { $csql = new \ciy\sql($table); $csql->where('codeid', $cbid); $csql->where('cbid=0'); $csql->column('id'); - $cbid = (int)$db->get1($csql); + $cbid = toint($db->get1($csql)); if ($cbid == 0) return array(); } @@ -215,7 +215,7 @@ function setmemvar($db, $types, $value) { if ($ind === false) { $updata['params'] = 1; } else { - $updata['params'] = (int)substr($value[0], $ind + 1); + $updata['params'] = toint(substr($value[0], $ind + 1)); } } if ($db->insert($csql, $updata) === false) diff --git a/web/admin/demo/demo_ajax.html b/web/admin/demo/demo_ajax.html index 84206fe..78dafd4 100644 --- a/web/admin/demo/demo_ajax.html +++ b/web/admin/demo/demo_ajax.html @@ -66,6 +66,7 @@ first: 顶部添加...first limit: a~b 只包含[a,b]。a,b,c 包含a,b,c filter: field=value 只包含field=value的数据。 + rename: 10=新名称 将id=10的name改为新名称。 ciyfn.ccode 字典id转name ciyfn.multicode 多级字典id转数组 diff --git a/web/admin/demo/demo_button.html b/web/admin/demo/demo_button.html new file mode 100644 index 0000000..29caffe --- /dev/null +++ b/web/admin/demo/demo_button.html @@ -0,0 +1,164 @@ + + + + + + + + + + + + + +
+ +
按钮样式
+
+ + + + + + + +
+ +
自定尺寸按钮
+
+ + + + + + + +
+ +
图标按钮
+
+ +
+ +
span标签
+
+ 普通文字 + def + dag + imp + warn + man + 普通文字 +
+ +



+



+



+



+



+



+
下拉按钮
+ + +



+



+



+



+



+



+



+



+



+



+



+



+
+ + + + + + + \ No newline at end of file diff --git a/web/admin/demo/demo_ecc_ukey_ad.html b/web/admin/demo/demo_ecc_ukey_ad.html new file mode 100644 index 0000000..c72db9a --- /dev/null +++ b/web/admin/demo/demo_ecc_ukey_ad.html @@ -0,0 +1,280 @@ + + + + + + + + + + + + + +
+
识别号
+
+ 用于标识UKey设备唯一编号
+ +
+
+
登录用户
+
+ 无感自动登录时设置的默认用户名
+ + +
+
+ +
ECC签名
+
+ 现将不限制长度的明文数据用hash256等算法计算固定长度hash摘要,再用私钥签名
+ +
+
hash: +
+
签名: +
+
+ +
ECC验签
+
+ 将导出的公钥公开(服务端),服务端将用hash值、sign签名、公钥,做签名验证。
+ 服务端保存好原始明文数据、sign签名、公钥,可作为司法证据,防抵赖。
+ 最佳实践,用户收到Ukey后,应自行生成新密钥对,再与平台方关联。
+ +
+
+
+
+
+ +
PIN码
+
+ + +
+ +
+ +
重置PIN码
+
+
+ + +
+
+ +
读写标记
+
+
+ +
+
+ +
初始化
+
+ 执行时间较长 +
+
+
+ + + + + + \ No newline at end of file diff --git a/web/admin/demo/demo_ecc_ukey_ad.php b/web/admin/demo/demo_ecc_ukey_ad.php new file mode 100644 index 0000000..bb53260 --- /dev/null +++ b/web/admin/demo/demo_ecc_ukey_ad.php @@ -0,0 +1,26 @@ +get('pubkey'); + if (empty($pubkey)) + return errjson('请填写公钥'); + $sign = $post->get('sign'); + if (empty($sign)) + return errjson('请填写签名'); + $hash = $post->get('hash'); + if (empty($hash)) + return errjson('请填写hash'); + require_once PATH_ROOT . '../libs/sm/autoload.php'; + $der = base64_decode($pubkey); + $pubkeyBytes = substr($der, 27); + $publicKey = '04' . bin2hex($pubkeyBytes); + $sm2Object = new \Rtgm\sm\RtSm2('base64', true); + $verifyResult = $sm2Object->verifySign($hash, $sign, $publicKey); + $ret['msg'] = $verifyResult ? "php验签结果: 验签成功" : "php验签结果: 验签失败"; + return succjson($ret); + } +} diff --git a/web/admin/demo/demo_rsa.html b/web/admin/demo/demo_rsa.html new file mode 100644 index 0000000..bcd6531 --- /dev/null +++ b/web/admin/demo/demo_rsa.html @@ -0,0 +1,181 @@ + + + + + + + + + + + + + +
+ +
生成RSA密钥对
+
+ 需在https协议下使用,原理是调用现代浏览器的Web Crypto API。 +
+
-----BEGIN PRIVATE KEY----- +
+ -----END PRIVATE KEY----- +
+
-----BEGIN PUBLIC KEY----- +
+ -----END PUBLIC KEY----- +
+ +
RSA签名
+
+ +
+
hash: +
+ +
签名: +
+
+ +
RSA验签
+
+
+ +
+
+
+ + + + + + + \ No newline at end of file diff --git a/web/admin/demo/demo_rsa.php b/web/admin/demo/demo_rsa.php new file mode 100644 index 0000000..a827ac0 --- /dev/null +++ b/web/admin/demo/demo_rsa.php @@ -0,0 +1,56 @@ +get('pubkey'); + if (empty($pubkey)) + return errjson('请填写公钥'); + $sign = $post->get('sign'); + if (empty($sign)) + return errjson('请填写签名'); + $hash = $post->get('hash'); + if (empty($hash)) + return errjson('请填写hash'); + $signbin = hex2bin($sign); + if ($signbin === false) + return errjson('签名格式错误'); + $hashbin = hex2bin($hash); + if ($hashbin === false) + return errjson('hash格式错误'); + $signKey = $pubkey; + if (strpos($signKey, '-----BEGIN RSA PUBLIC KEY-----') === false && strpos($signKey, '-----BEGIN PUBLIC KEY-----') === false) + $signKey = "-----BEGIN PUBLIC KEY-----\n" . wordwrap($signKey, 64, "\n") . "\n-----END PUBLIC KEY-----"; + $result = openssl_verify($hashbin, $signbin, $signKey, OPENSSL_ALGO_SHA256); + if ($result === 0) + $ret['msg'] = '验签失败'; + else if ($result === 1) + $ret['msg'] = '验签成功'; + else + return errjson('验签错误:' . openssl_error_string()); + return succjson($ret); + } + public static function json_signrsa() { + $post = new \ciy\post(); + $prikey = $post->get('prikey'); + if (empty($prikey)) + return errjson('请填写私钥'); + $hash = $post->get('hash'); + if (empty($hash)) + return errjson('请填写hash'); + $hashbin = hex2bin($hash); + if ($hashbin === false) + return errjson('hash格式错误'); + $privateKey = $prikey; + if (strpos($privateKey, '-----BEGIN RSA PRIVATE KEY-----') === false && strpos($privateKey, '-----BEGIN PRIVATE KEY-----') === false) + $privateKey = "-----BEGIN PRIVATE KEY-----\n" . wordwrap($privateKey, 64, "\n", true) . "\n-----END PRIVATE KEY-----"; + $result = openssl_sign($hashbin, $signbin, $privateKey, OPENSSL_ALGO_SHA256); + if ($result !== true) + return errjson('签名错误:' . openssl_error_string()); + $ret['sign'] = bin2hex($signbin); + $ret['from'] = 'php'; + return succjson($ret); + } +} diff --git a/web/admin/demo/demo_web3.html b/web/admin/demo/demo_web3.html new file mode 100644 index 0000000..5a757a9 --- /dev/null +++ b/web/admin/demo/demo_web3.html @@ -0,0 +1,120 @@ + + + + + + + + + + + + + +
+ +
钱包登录
+
+
+
+
+ +
钱包签名
+
+ +
+
hash: +
+
签名: +
+
+ +
钱包验签
+
+
+
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/web/admin/demo/demo_web3.php b/web/admin/demo/demo_web3.php new file mode 100644 index 0000000..8ef6b82 --- /dev/null +++ b/web/admin/demo/demo_web3.php @@ -0,0 +1,42 @@ +get('addr'); + if (empty($addr)) + return errjson('请填写钱包地址'); + $signature = $post->get('sign'); + if (empty($signature)) + return errjson('请填写签名'); + $message = $post->get('hash'); + if (empty($message)) + return errjson('请填写hash'); + //composer require simplito/elliptic-php kornrunner/keccak + require_once PATH_ROOT . '../libs/ethereum/autoload.php'; + $prefix = "\x19Ethereum Signed Message:\n" . strlen($message); + $hash = \kornrunner\Keccak::hash($prefix . $message, 256); + $signature = substr($signature, 2); + if (strlen($signature) !== 130) + return '签名数据长度错误'; + $r = substr($signature, 0, 64); + $s = substr($signature, 64, 64); + $v = substr($signature, 128, 2); + $v = hexdec($v); + if ($v == 27 || $v == 28) + $v -= 27; + $ec = new \Elliptic\EC('secp256k1'); + $publicKey = $ec->recoverPubKey($hash, [ + 'r' => $r, + 's' => $s + ], $v); + $publicKeyHex = $publicKey->encode('hex'); + $publicKeyBytes = substr(hex2bin($publicKeyHex), 1); + $addressFromKey = '0x' . substr(\kornrunner\Keccak::hash($publicKeyBytes, 256), 24); + $addressFromKey = strtolower($addressFromKey); + $ret['msg'] = strtolower($addr) === $addressFromKey ? "签名验证成功" : "签名验证失败"; + return succjson($ret); + } +} diff --git a/web/admin/demo/form_checkbox.html b/web/admin/demo/form_checkbox.html index c5ea7ef..2b31723 100644 --- a/web/admin/demo/form_checkbox.html +++ b/web/admin/demo/form_checkbox.html @@ -30,6 +30,14 @@
+
+ +
+
+
+ +
+
改变值 @@ -55,6 +63,8 @@ ciycmp({ dom: '[com=b]', range: rg }); ciycmp({ dom: '[com=c]', range: rg, value: '1,3' }); ciycmp({ dom: '[com=d]', range: [{ id: 'aa', name: 'AAA' }, { id: 'bb', name: 'BBB' }], value: 'bb' }); + ciycmp({ dom: '[com=e]' }); + ciycmp({ dom: '[com=f]' }); }); function formsubmit(event) { event.preventDefault(); diff --git a/web/admin/demo/index.html b/web/admin/demo/index.html index f21ff42..4a53fbc 100644 --- a/web/admin/demo/index.html +++ b/web/admin/demo/index.html @@ -110,6 +110,10 @@ tabcard 选项卡。 +
+ button + 按钮。 +
 
@@ -159,6 +163,18 @@ proxy prop Proxy响应式示例。 +
+ rsa sign + RSA私钥签名 +
+
+ ecc sign + ECC UKey签名(VN) +
+
+ web3 + web3登录、签名、验签 +
mail Mail收发邮件。 @@ -171,6 +187,14 @@ tesseract 文字OCR识别。
+
+ alipaycb + 阿里API,回调数据分析 +
+
+ realip + 复杂网络环境下获取真实ip +
diff --git a/web/admin/demo/tool_alipaycb.html b/web/admin/demo/tool_alipaycb.html new file mode 100644 index 0000000..6d3ca27 --- /dev/null +++ b/web/admin/demo/tool_alipaycb.html @@ -0,0 +1,113 @@ + + + + + + + + + + + + + +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ + + + + + + + + + \ No newline at end of file diff --git a/web/admin/demo/tool_realip.html b/web/admin/demo/tool_realip.html new file mode 100644 index 0000000..9cb0860 --- /dev/null +++ b/web/admin/demo/tool_realip.html @@ -0,0 +1,64 @@ + + + + + + + + + + + + + +
+
+ +
+
+
+
+ +
+ + +
+
+
+
+ + + + + + + + + + \ No newline at end of file diff --git a/web/admin/demo/tool_realip.php b/web/admin/demo/tool_realip.php new file mode 100644 index 0000000..b08cdcf --- /dev/null +++ b/web/admin/demo/tool_realip.php @@ -0,0 +1,79 @@ +get('header')); + $server = array(); + foreach ($headers as $header) { + $ind = strpos($header, '='); + if ($ind === false) + continue; + $server[strtoupper(substr($header, 0, $ind))] = substr($header, $ind + 1); + } + $ret['ip'] = self::simip($server); + return succjson($ret); + } + public static function json_getip() { + $ret['ip'] = getip(); + return succjson($ret); + } + static function simip($server) { + $headers = [ + 'HTTP_CF_CONNECTING_IP', // Cloudflare + 'HTTP_TRUE_CLIENT_IP', // Akamai/Cloudflare + 'HTTP_X_FORWARDED_FOR', // 最常用的代理头 + 'HTTP_FORWARDED', // RFC 7239 标准 + 'HTTP_X_REAL_IP', // Nginx + 'HTTP_FORWARDED_FOR', // 变体 + 'HTTP_X_FORWARDED', // 旧格式 + ]; + $ips = array(); + foreach ($headers as $header) { + if (!empty($server[$header])) //$_SERVER + $ips[] = strtolower($server[$header]); + } + foreach ($ips as $ip) { + $ind = strpos($ip, ','); + if ($ind !== false) + $ip = substr($ip, 0, $ind); + $ind = strpos($ip, 'for='); + if ($ind !== false) { + //for=192.0.2.43:47011,for="[2001:db8:cafe::17]:47011",for=unknown + //for=_hidden, for=_SEVKISEK + $ip = substr($ip, $ind + 4); + if ($ip[0] == '"') { + $ip = substr($ip, 1, strpos($ip, '"', 1) - 1); + $ind = strpos($ip, ']'); + if ($ind !== false) + $ip = substr($ip, 1, $ind - 1); + } else if ($ip[0] == '[') { + $ip = substr($ip, 1, strpos($ip, ']') - 1); + } else { + $ind = strpos($ip, ';'); + if ($ind !== false) + $ip = substr($ip, 0, $ind); + + if (strpos($ip, '.') !== false) { + $ind = strpos($ip, ':'); + if ($ind !== false) + $ip = substr($ip, 0, $ind); + } + } + } else { + if (strpos($ip, '.') !== false) { + $ind = strpos($ip, ':'); + if ($ind !== false) + $ip = substr($ip, 0, $ind); + } + } + if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) + return $ip; + } + if (isset($_SERVER['REMOTE_ADDR'])) + return $_SERVER['REMOTE_ADDR']; + return '0.0.0.0'; + } +} diff --git a/web/admin/develop/code_create.html b/web/admin/develop/code_create.html index c7cf3b6..0e870a6 100644 --- a/web/admin/develop/code_create.html +++ b/web/admin/develop/code_create.html @@ -34,9 +34,6 @@
-
- -
@@ -44,6 +41,9 @@
+
+ +
@@ -206,8 +206,6 @@ cc.bcod.proglang = ciyfn.getstorage('_ccode_proglang', 'php'); if (!cc.bcod.saascode) cc.bcod.saascode = ciyfn.getstorage('_ccode_saascode', ''); - if (!cc.bcod.savepc) - cc.bcod.savepc = ciyfn.getstorage('_ccode_savepc', 'web\\*\\') + cc.bcod.tabname.substring(cc.bcod.tabname.indexOf('_') + 1); $5('[name=_bcod_verifyfunc]').val(cc.bcod.verifyfunc); $5('[name=_bcod_titname]').val(cc.bcod.titname); @@ -221,7 +219,6 @@ $5('[name=_bcod_tabdict]').val(cc.bcod.tabdict); $5('[name=_bcod_saascode]').val(cc.bcod.saascode); - ciycmp({ dom: '[com=owpc]' }); // ciycmp({ // dom: '[com=_bcod_chk]', value: cc.bcod.bcod_chk, range: [ // //如果有固定的几个字段,则开启审核 @@ -451,7 +448,7 @@ chkvalue = chkvalue.replace(',bmin', '').replace(',bout', ''); } if (colcomment.cate == 'BR' || colcomment.cate == 'MD') { - if(!colcomment.show) + if (!colcomment.show) spset.nocmn = 'no'; } if (data.COLUMN_NAME == 'auditstatus' @@ -465,7 +462,8 @@ || data.COLUMN_NAME == 'ip') { spset.noup = 'no'; } - if (data.COLUMN_NAME.substring(0, 4) == 'saas' && data.COLUMN_NAME.substring(5) == 'id') { + var saascode = ciyfn.getstorage('_ccode_saascode', '').split('='); + if (data.COLUMN_NAME == saascode[0]) { spset.noup = 'saas'; } if (data.COLUMN_NAME == 'lat') { @@ -499,7 +497,7 @@ html += '
'; html += '
'; html += ''; - html += ''; + html += ''; html += ''; html += ''; html += ''; @@ -675,10 +673,16 @@ ciyfn.setstorage('_ccode_tabdict', postparam._bcod_tabdict); ciyfn.setstorage('_ccode_htmllang', postparam._bcod_htmllang); ciyfn.setstorage('_ccode_proglang', postparam._bcod_proglang); + ciyfn.setstorage('_ccode_saascode', postparam._bcod_saascode); ciyfn.setstorage('_ccode_savepc', postparam._bcod_savepc.substring(0, postparam._bcod_savepc.lastIndexOf('\\') + 1)); //记忆一部分,默认一部分+表名 ciyfn.toast('保存成功'); }); } + function del(dom) { + ciyfn.callfunc('del', {}, function (json) { + window.close(); + }); + } function createhtml(dom) { var postparam = checkformdata(dom); if (typeof (postparam) == 'string') @@ -741,9 +745,11 @@ function checkformdata(dom) { var postparam = ciyfn.getform(dom); postparam.total = table.json.list.length; + postparam.schema = table.json.dbsaas.schem; + postparam.table = table.json.table; + postparam.subpath = table.json.dbsaas.subpath; if (!postparam._bcod_proglang) return '请选择后端语言'; - console.log(postparam); for (var i = 0; i < postparam.total; i++) { if (postparam['none_' + i] === 'true') continue; diff --git a/web/admin/develop/code_create.php b/web/admin/develop/code_create.php index e5582cb..9df0777 100644 --- a/web/admin/develop/code_create.php +++ b/web/admin/develop/code_create.php @@ -8,8 +8,14 @@ class code_create { $rsuser = verifyfast(); $post = new \ciy\post(); $query = $post->get('query'); - $schema = objstr($query, 'schema'); + $dbcid = objint($query, 'dbcid'); $tabname = objstr($query, 'table'); + $csql = new \ciy\sql('zc_dev_dbsaas'); + $csql->where('id', $dbcid); + $dbsaasrow = $db->getone($csql); + if (!is_array($dbsaasrow)) + return errjson('dbsaas不存在'); + $schema = $dbsaasrow['schem']; $csql = new \ciy\sql('INFORMATION_SCHEMA.COLUMNS'); $csql->where('TABLE_SCHEMA', $schema); $csql->where('TABLE_NAME', $tabname); @@ -17,6 +23,8 @@ class code_create { for ($i = 0; $i < count($rows); $i++) $rows[$i]['id'] = $i; $ret = array('list' => $rows); + $ret['dbsaas'] = $dbsaasrow; + $ret['table'] = $tabname; $field = array(); $field['_btn'] = array('c' => '操作'); $field['TABLE_COMMENT'] = array('c' => '表名'); @@ -26,7 +34,7 @@ class code_create { $ret['field'] = $field; $csql = new \ciy\sql('zc_dev_dbcode'); - $csql->where('schem', $schema); + $csql->where('dbcid', $dbcid); $csql->where('tabl', $tabname); $csql->column('pcjson'); $jnstr = $db->get1($csql); @@ -43,7 +51,9 @@ class code_create { $ret['code_create'] = array('bcod' => array(), 'col' => array()); $ret['code_create']['bcod']['tabname'] = $tabname; $ret['code_create']['bcod']['titname'] = str_replace('表', '', $tabrow['TABLE_COMMENT']); - $ret['code_create']['bcod']['uploadpat'] = substr($tabname, strpos($tabname, '_') + 1); + $maintab = substr($tabname, strpos($tabname, '_') + 1); + $ret['code_create']['bcod']['uploadpat'] = $maintab; + $ret['code_create']['bcod']['savepc'] = 'web\\' . $dbsaasrow['subpath'] . '\\' . $maintab; if ($chk_audit) { $ret['code_create']['bcod']['newline'] = '导出'; $ret['code_create']['bcod']['multibtn'] = '批量删除,审核通过,驳回'; @@ -67,7 +77,7 @@ class code_create { } public static function save($post) { global $db; - $schema = get('schema'); + $dbcid = getint('dbcid'); $tabname = get('table'); $json = array(); $json['bcod'] = array(); @@ -76,8 +86,9 @@ class code_create { $json['bcod']['titname'] = $post->get('_bcod_titname', '', 'all'); //$json['bcod']['logtype'] = $post->get('_bcod_logtype', '', 'all'); $json['bcod']['uploadpat'] = $post->get('_bcod_uploadpat', '', 'all'); - $json['bcod']['liiddict'] = $post->get('_bcod_liiddict', '', 'all'); - $json['bcod']['uptabcard'] = $post->get('_bcod_uptabcard', '', 'all'); + $json['bcod']['liiddict'] = str_replace(',', ',', $post->get('_bcod_liiddict', '', 'all')); + $json['bcod']['uptabcard'] = str_replace(',', ',', $post->get('_bcod_uptabcard', '', 'all')); + $json['bcod']['viewtabcard'] = str_replace(',', ',', $post->get('_bcod_viewtabcard', '', 'all')); $json['bcod']['tabdict'] = $post->get('_bcod_tabdict', '', 'all'); $json['bcod']['saascode'] = $post->get('_bcod_saascode', '', 'all'); //$json['bcod']['uniquedata'] = $post->get('_bcod_uniquedata', '', 'all'); @@ -105,11 +116,11 @@ class code_create { try { $db->begin(); $updata = array(); - $updata['schem'] = $schema; + $updata['dbcid'] = $dbcid; $updata['tabl'] = $tabname; $updata['pcjson'] = json_encode($json, JSON_PARTIAL_OUTPUT_ON_ERROR); $csql = new \ciy\sql('zc_dev_dbcode'); - $csql->where('schem', $schema); + $csql->where('dbcid', $dbcid); $csql->where('tabl', $tabname); $row = $db->getone($csql); $csql = new \ciy\sql('zc_dev_dbcode'); @@ -126,10 +137,22 @@ class code_create { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } return succjson(); } + public static function json_del() { + global $db; + $dbcid = getint('dbcid'); + $tabname = get('table'); + $csql = new \ciy\sql('zc_dev_dbcode'); + $csql->where('dbcid', $dbcid); + $csql->where('tabl', $tabname); + if ($db->delete($csql) === false) + return errjson('删除失败:' . $db->error); + return succjson(); + } public static function json_createhtml() { $post = new \ciy\post(); require_once 'code_common.php'; @@ -167,13 +190,6 @@ class code_create { $tpath = dirname($savepc); if (!is_dir($tpath)) return errjson('目录不存在' . $tpath); - $ow = $post->getbool('owpc'); - if (!$ow) { - if (file_exists($savepc . '.html')) - return errjson($savepc . '.html文件已存在'); - if (file_exists($savepc . '.php')) - return errjson($savepc . '.php文件已存在'); - } $ret = self::save($post); if (is_string($ret)) return errjson($ret); diff --git a/web/admin/develop/code_list.html b/web/admin/develop/code_list.html index 8fd630b..aae49ab 100644 --- a/web/admin/develop/code_list.html +++ b/web/admin/develop/code_list.html @@ -17,7 +17,7 @@
- 选库 +
@@ -25,16 +25,6 @@
- @@ -44,42 +34,41 @@ var table; var Glob = {}; ciyfn.pageload(function () { - var urlp = ciyfn.urlparam(); - if (urlp.schema) - return gettab({ schema: urlp.schema }); - var schema = ciyfn.getstorage('schema'); - if (schema) - return gettab({ schema: schema }); - getschema(); - }); - function getschema() { - ciyfn.callfunc("getschema", {}, function (json) { - for (var i = 0; i < json.schema.length; i++) { - json.schema[i].id = json.schema[i].name; + table = new ciyclass.table({ + dom: '.table' + , url: 'init' + , pagecount: 10 + , fn_beforedata: function (json) { + ciyfn.fillsearch({ + searchdom: '.search' + , data: json + }); + Glob.tabls = {}; + for (var i in json.once.dbcode) + Glob.tabls[json.once.dbcode[i].tabl] = 1; + document.title = '🔆' + json.once.dbsaas.name + ' - ' + json.once.dbsaas.subpath; + $5('#id_dbc').html('' + json.once.dbsaas.name + '' + json.once.dbsaas.schem + '' + json.once.dbsaas.subpath + ''); + return json; + } + , fn_tdcontent: function (key, datashow, field, data) { + if (key == 'TABLE_COMMENT') {//内部编辑,立即更新 + return ''; + } + if (key == '_btn') { + var html = ''; + if (Glob.tabls[data.TABLE_NAME]) + html += '生成'; + else + html += '生成'; + return html; + } } - ciyfn.alert({ - contentstyle: 'width:27em;', - content: '
', - nomaskclose: true, - noparent: true, - fn_showed: function (doc, dom) { - ciycmp({ dom: $5('[com=schema]', dom), range: json.schema }); - }, - cb: function (opn) { - if (opn.btn == "取消") - return opn.close(); - if (!opn.inputs.schema) - return opn.close(); - ciyfn.setstorage('schema', opn.inputs.schema); - gettab({ schema: opn.inputs.schema }); - opn.close(); - }, - btns: ["提交", "*取消"] - }); }); - } + table.callpage(1); + }); function search(dom) { Glob.key = ciyfn.getform(dom); + delete Glob.key.memo; $5('[data-id]').each(function (rdom) { var bshow = true; for (var k in Glob.key) { @@ -94,78 +83,20 @@ rdom.style.display = bshow ? '' : 'none'; }); } - function gettab(post) { - if (table) - table.dom.attr('_field', 0); - table = new ciyclass.table({ - dom: '.table' - , url: 'init' - , query: post - , pagecount: 10 - , fn_beforedata: function (json) { - ciyfn.fillsearch({ - searchdom: '.search' - , data: json - }); - return json; - } - , fn_tdcontent: function (key, datashow, field, data) { - if (key == 'TABLE_COMMENT') {//内部编辑,立即更新 - return ''; - } - if (key == '_btn') { - var html = ''; - html += '生成'; - //html += '更名'; - return html; - } - } + function upcomment(dom, id) { + var val = $5(dom).val(); + if (val == table.data[id].TABLE_COMMENT) + return; + ciyfn.callfunc('update', { id: id, tabname: table.data[id].TABLE_NAME, name: val }, function (json) { + table.data[id].TABLE_COMMENT = val; + $5(dom).css({ border: '1px solid var(--succ5)' }); + setTimeout(function () { $5(dom).css({ border: '' }); }, 1000); }); - table.callpage(1); } - function upcomment(dom, id) { - var val = $5(dom).val(); - if (val == table.data[id].TABLE_COMMENT) - return; - ciyfn.callfunc('update', { id: id, tabname: table.data[id].TABLE_NAME, name: val }, function (json) { - table.data[id].TABLE_COMMENT = val; - $5(dom).css({ border: '1px solid var(--succ5)' }); - setTimeout(function () { $5(dom).css({ border: '' }); }, 1000); - }); - } function menubtn(dom, btn) { var id = $5(dom).parent('tr').attr('data-id'); if (btn == 'create') { - window.open('code_create.html?schema=' + table.data[id].TABLE_SCHEMA + '&table=' + table.data[id].TABLE_NAME); - return; - ciyfn.sendsignal(window.top, 'manage_ifropen', { - url: 'develop/code_create.html?schema=' + table.data[id].TABLE_SCHEMA + '&table=' + table.data[id].TABLE_NAME - , name: '代码生成' + table.data[id].TABLE_COMMENT + '' - }); - } - if (btn == 'edit') { - ciyfn.alert({ - title: '更名' - , content: document.getElementById("alert_edit").innerHTML - //, noparent:true - , fn_showed: function (doc, dom) { - var dat = table.data[id]; - $5('[name=name]', dom).val(dat.TABLE_COMMENT); - } - , cb: function (opn) { - if (opn.btn == "关闭") - return opn.close(); - opn.inputs.id = id; - opn.inputs.tabname = table.data[id].TABLE_NAME; - if (ciyfn.throttle(opn.dombtn)) return; - ciyfn.callfunc('update', opn.inputs, function (json) { - table.updateline(json); - opn.close(); - ciyfn.toast('更新成功'); - }); - }, - btns: ["提交", "*关闭"] - }); + window.open('code_create.html?dbcid=' + table.once.dbsaas.id + '&table=' + table.data[id].TABLE_NAME); } } diff --git a/web/admin/develop/code_list.php b/web/admin/develop/code_list.php index 0361c4a..47d5457 100644 --- a/web/admin/develop/code_list.php +++ b/web/admin/develop/code_list.php @@ -6,14 +6,17 @@ class code_list { static function setwhere($db, $post) { $query = $post->get('query'); $csql = new \ciy\sql('INFORMATION_SCHEMA.TABLES'); - $csql->where('TABLE_SCHEMA', objstr($query, 'schema')); return [$query, $csql]; } public static function json_init() { global $db; $rsuser = verifyfast(); $post = new \ciy\post(); + $csql = new \ciy\sql('zc_dev_dbsaas'); + $csql->where('id', getint('dbcid')); + $dbsaasrow = $db->getone($csql); list($where, $csql) = self::setwhere($db, $post); + $csql->where('TABLE_SCHEMA', $dbsaasrow['schem']); $rows = $db->get($csql); for ($i = 0; $i < count($rows); $i++) $rows[$i]['id'] = $i + 1; @@ -31,6 +34,11 @@ class code_list { if ($post->getbool('once')) { $ret['once'] = array(); + $ret['once']['dbsaas'] = $dbsaasrow; + $csql = new \ciy\sql('zc_dev_dbcode'); + $csql->where('dbcid', getint('dbcid')); + $csql->column('tabl'); + $ret['once']['dbcode'] = $db->get($csql); $input = array(); $input[] = array( 'type' => 'input', diff --git a/web/admin/develop/code_mb_vue3.php b/web/admin/develop/code_mb_vue3.php index 4580e20..32ef4a3 100644 --- a/web/admin/develop/code_mb_vue3.php +++ b/web/admin/develop/code_mb_vue3.php @@ -8,7 +8,7 @@ function code_mbvue3($post) { $titname = $post->get('_bcod_titname', '', 'all'); $logtype = $post->get('_bcod_logtype', '', 'all'); $uploadpat = $post->get('_bcod_uploadpat', '', 'all'); - $liiddict = $post->get('_bcod_liiddict', '', 'all'); + $liiddict = str_replace(',',',', $post->get('_bcod_liiddict', '', 'all')); $tabdict = $post->get('_bcod_tabdict', '', 'all'); $uniquedata = $post->get('_bcod_uniquedata', '', 'all'); $chk_in = $post->get('_bcod_chk_in') == 'yes'; diff --git a/web/admin/develop/code_pc_html.php b/web/admin/develop/code_pc_html.php index 0fafef0..78dac58 100644 --- a/web/admin/develop/code_pc_html.php +++ b/web/admin/develop/code_pc_html.php @@ -1,19 +1,25 @@ get('schema', '', 'all'); + $tabname = $post->get('table', '', 'all'); + $subpath = $post->get('subpath', '', 'all'); $maindb = $post->get('_bcod_maindb', '', 'all'); $verifyfunc = $post->get('_bcod_verifyfunc', '', 'all'); $titname = $post->get('_bcod_titname', '', 'all'); $saascode = $post->get('_bcod_saascode', '', 'all'); + if ($saascode) { + $saascode = explode('=', $saascode); + if (count($saascode) == 1) + $saascode[1] = $saascode[0]; + } $uploadpat = $post->get('_bcod_uploadpat', '', 'all'); - $liiddict = $post->get('_bcod_liiddict', '', 'all'); - $uptabcard = $post->get('_bcod_uptabcard', '', 'all'); + $liiddict = str_replace(',',',', $post->get('_bcod_liiddict', '', 'all')); + $uptabcard = str_replace(',',',', $post->get('_bcod_uptabcard', '', 'all')); $uptabcards = array(); if (!empty($uptabcard)) $uptabcards = explode(',', $uptabcard); - $viewtabcard = $post->get('_bcod_viewtabcard', '', 'all'); + $viewtabcard = str_replace(',',',', $post->get('_bcod_viewtabcard', '', 'all')); $viewtabcards = array(); if (!empty($viewtabcard)) $viewtabcards = explode(',', $viewtabcard); @@ -107,7 +113,9 @@ function code_pc_html($post) { $topbtns[] = '' . $str . ''; } else { $subs = explode('|', $str); //操作|成果|方法|-修改|删除 - $btnhtml = "{$subs[0]}\n"; + $btnhtml .= " "; $topbtns[] = $btnhtml; } } @@ -144,7 +153,7 @@ function code_pc_html($post) { data; - if (($querycount < 5 && count($topbtns) < 4) || count($topbtns) < 2) { + if (($querycount < 5 && count($topbtns) < 4) || count($topbtns) < 3) { foreach ($topbtns as $topbtn) { $codex .= ' ' . $topbtn . "\n"; } @@ -156,7 +165,7 @@ data; data; - if (!(($querycount < 5 && count($topbtns) < 4) || count($topbtns) < 2)) { + if (!(($querycount < 5 && count($topbtns) < 4) || count($topbtns) < 3)) { $codex .= "
\n"; foreach ($topbtns as $topbtn) { $codex .= ' ' . $topbtn . "\n"; @@ -272,11 +281,11 @@ if($hasedit){ } else if ($cate == 'METRE') { $codex .= "\n{$pspec} "; } else if ($cate == 'DATE') { - if (strpos('H', $fld['data']) !== false) + if (strpos($fld['data'], 'H') !== false) $ext = ' type="datetime"'; $codex .= "\n{$pspec} "; } else if ($cate == 'TIME') { - if (strpos(':s', $fld['data']) !== false) + if (strpos($fld['data'], ':s') !== false) $ext = ' type="second"'; $codex .= "\n{$pspec} "; } else if ($cate == 'WCNY') { @@ -459,10 +468,10 @@ if($hasedit){ $savepc = str_replace('\\', '/', $savepc); $savepc = substr($savepc, strpos($savepc, 'web/') + 4); $count = substr_count($savepc, '/'); - $subpath = './'; + $subpathn = './'; if($count > 0) - $subpath = str_repeat('../', $count - 1); - $codex .= "\n "; + $subpathn = str_repeat('../', $count - 1); + $codex .= "\n "; $liid = ''; if (!empty($liiddict)) { @@ -491,7 +500,9 @@ if($hasedit){ $editbtn = ''; $menubtn = ''; + $bmenubtn = false; $strs = explode(',', $btnlist_line); //添加,导入,导出,其他,操作|成果|方法|-修改|删除 + $subgomenus = array(); foreach ($strs as $str) { $ind = strpos($str, '|'); if ($ind === false) { @@ -526,16 +537,25 @@ if($hasedit){ $menubtn .= "\n }"; } else { + $btnstrs = explode('.', $str); + $str = $btnstrs[0]; $extcls = ''; $extkey = ''; - $menubtn .= "\n if (btn == '') {"; + if(count($btnstrs) > 1){ + $subgomenus[] = $btnstrs; + $extkey = $btnstrs[1]; + } + $menubtn .= "\n if (btn == '{$extkey}') {"; $menubtn .= "\n ciyfn.callfastfunc(dom, '是否{$str}?', 'status', { ids: id }, function (json) { table.updateline(json) });"; $menubtn .= "\n }"; } $editbtn .= "\n html += `{$str}`;"; } else { + $bmenubtn = true; $subs = explode('|', $str); //操作|成果|方法|-修改|删除 - $editbtn .= "\n html += `{$subs[0]}`;"; } } $pcaddtit = ''; @@ -578,18 +603,37 @@ if($hasedit){ $codex .= "\n // table.mergecol('auditstatus');"; $codex .= "\n // table.mergefix('总计', 'center', 6, 0, 8, 1);"; $codex .= "\n // table.footertotal();"; + if($bmenubtn) + $codex .= "\n ciyfn.dropmenu('.btn-menu');"; $codex .= "\n }"; $codex .= "\n });"; $codex .= "\n table.callpage(1);"; $codex .= "\n });"; $codex .= "\n function menubtn(dom, btn) {"; $codex .= "\n var id = $5(dom).parent('tr').attr('data-id');{$menubtn}"; - $codex .= "\n if (btn == 'sub') {"; - $codex .= "\n ciyfn.sendsignal(window.top, 'manage_ifropen', {"; - $codex .= "\n url: 'xxx.html?_xxxid=' + id"; - $codex .= "\n , name: '{$titname}' + table.data[id].name + ''"; - $codex .= "\n });"; - $codex .= "\n }"; + $subpathn = ''; + $ind = strpos($subpath, '\\'); + if($ind > 0) + $subpathn = str_replace('\\','/', substr($subpath, $ind+1)) . '/'; + foreach ($subgomenus as $subgomenu) { + $xid = 'xxxid'; + if(isset($subgomenu[2])) + $xid = $subgomenu[2]; + $codex .= "\n if (btn == '{$subgomenu[1]}') {"; + $codex .= "\n ciyfn.sendsignal(window.top, 'manage_ifropen', {"; + $codex .= "\n url: '{$subpathn}{$subgomenu[1]}.html?_{$xid}=' + id"; + $codex .= "\n , name: '{$subgomenu[0]}' + table.data[id].name + ''"; + $codex .= "\n });"; + $codex .= "\n }"; + } + if (count($subgomenus) == 0) { + $codex .= "\n if (btn == 'sub') {"; + $codex .= "\n ciyfn.sendsignal(window.top, 'manage_ifropen', {"; + $codex .= "\n url: 'xxx.html?_xxxid=' + id"; + $codex .= "\n , name: '{$titname}' + table.data[id].name + ''"; + $codex .= "\n });"; + $codex .= "\n }"; + } $codex .= "\n }"; $codex .= "\n"; $codex .= "\n function getdata(id, act, cb) {"; @@ -753,6 +797,8 @@ if($hasedit){ continue; if ($col == 'auditstatus' || $col == 'audittimes' || $col == 'audituser' || $col == 'auditmsg') continue; + if ($saascode && $saascode[0] == $fld['col']) + continue; $sgcol = (isset($fld['set']['colview']) ? $fld['set']['colview'] : '24'); $codex .= "\n html += '
';"; $codex .= "\n html += '
';"; diff --git a/web/admin/develop/code_pc_php.php b/web/admin/develop/code_pc_php.php index d414c96..298472a 100644 --- a/web/admin/develop/code_pc_php.php +++ b/web/admin/develop/code_pc_php.php @@ -1,7 +1,8 @@ get('schema', '', 'all'); + $tabname = $post->get('table', '', 'all'); + $subpath = $post->get('subpath', '', 'all'); $maindb = $post->get('_bcod_maindb', '', 'all'); $verifyfunc = $post->get('_bcod_verifyfunc', '', 'all'); $titname = $post->get('_bcod_titname', '', 'all'); @@ -9,10 +10,10 @@ function code_pc_php($post) { if ($saascode) { $saascode = explode('=', $saascode); if (count($saascode) == 1) - $saascode[1] = $saascode[0]; + $saascode[1] = ''; } $uploadpat = $post->get('_bcod_uploadpat', '', 'all'); - $liiddict = $post->get('_bcod_liiddict', '', 'all'); + $liiddict = str_replace(',',',', $post->get('_bcod_liiddict', '', 'all')); $tabdict = $post->get('_bcod_tabdict', '', 'all'); $selectorder = $post->get('_bcod_select_order', '', 'all'); $btntop_newline = $post->get('_bcod_btntop_newline', '', 'all'); @@ -75,7 +76,7 @@ function code_pc_php($post) { $codex .= "\nnamespace {$namespace};"; $codex .= "\n"; $codex .= "\nclass {$classname} {"; - $codex .= "\n static function setwhere(\$db, \$post) {"; + $codex .= "\n static function setwhere(\$db, \$post, \$rsuser) {"; $codex .= "\n \$query = \$post->get('query');"; $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; if (!empty($liiddict)) { @@ -187,9 +188,11 @@ function code_pc_php($post) { if ($verifyfunc) $codex .= "\n \$rsuser = {$verifyfunc}();"; $codex .= "\n \$post = new \ciy\post();"; - $codex .= "\n list(\$where, \$csql) = self::setwhere(\$db, \$post);"; - if ($saascode) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + $codex .= "\n list(\$where, \$csql) = self::setwhere(\$db, \$post, \$rsuser);"; + if ($saascode){ + if(!empty($saascode[1])) + $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + } if (count($nocolumn) > 0) { $codex .= "\n \$csql->column('!" . implode(',', $nocolumn) . "', \$db->getraw('show full fields from {$tabname}'));"; } @@ -207,6 +210,10 @@ function code_pc_php($post) { $codex .= "\n foreach (\$field as \$fr => \$v) {"; $codex .= "\n if (get('_' . \$fr))"; $codex .= "\n \$field[\$fr]['c'] = ',' . \$field[\$fr]['c'];"; + if ($saascode) { + $codex .= "\n if (\$fr == '{$saascode[0]}')"; + $codex .= "\n \$field[\$fr]['c'] = ',' . \$field[\$fr]['c'];"; + } $codex .= "\n }"; if ($btnlist_line) $codex .= "\n \$fshow = fieldadd(\$fshow, \$field, 0, '_btn', '操作');"; @@ -230,7 +237,7 @@ function code_pc_php($post) { $dbquery = isset($fld['set']['dbquery']) ? $fld['set']['dbquery'] : ''; $pspec = ''; if ($fld['breq']) { - $codex .= "\n if(!get('_' . '{$col}'))"; + $codex .= "\n if(!get('_{$col}'))"; $pspec = ' '; } if ($dbquery == 'window') { @@ -309,6 +316,8 @@ function code_pc_php($post) { foreach ($flds as $fld) { if (!$fld['show']) continue; + if ($saascode && $saascode[0] == $fld['col']) + continue; $cate = $fld['cate']; if ($cate == 'DB' || $cate == 'CATU' || $cate == 'CATS' || $cate == 'CATM') { if (isset($fld['set']['listload']) && $fld['set']['listload'] == 'rel') { @@ -333,8 +342,10 @@ function code_pc_php($post) { $codex .= "\n \$act = \$post->get('act');"; $codex .= "\n if (\$id > 0) {"; $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saascode){ + if(!empty($saascode[1])) + $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + } $codex .= "\n \$csql->where('id', \$id);"; $codex .= "\n \$row = \$db->getone(\$csql);"; $codex .= "\n if (!is_array(\$row))"; @@ -410,10 +421,13 @@ function code_pc_php($post) { if (!empty($fld['set']['noup'])) continue; $col = $fld['col']; + $cate = $fld['cate']; $name = $fld['name']; $type = $fld['type']; if ($type == 'bigint' || $type == 'int' || $type == 'double' || $type == 'float') $codex .= "\n if (\${$col} == 0)"; + else if ($cate == 'MD') + $codex .= "\n if (\${$col} == '[MD]')"; else $codex .= "\n if (empty(\${$col}))"; $codex .= "\n return errjson('请填写{$name}');"; @@ -422,8 +436,10 @@ function code_pc_php($post) { $codex .= "\n \$datarow = null;"; $codex .= "\n if (\$id > 0) {"; $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saascode) { + if(!empty($saascode[1])) + $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + } $codex .= "\n \$csql->where('id', \$id);"; $codex .= "\n \$datarow = \$db->getone(\$csql);"; $codex .= "\n if (!is_array(\$datarow))"; @@ -431,8 +447,10 @@ function code_pc_php($post) { $codex .= "\n }"; } else { $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser[{$saascode[1]}']);"; + if ($saascode) { + if(!empty($saascode[1])) + $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + } $codex .= "\n \$csql->where('id', \$id);"; $codex .= "\n \$datarow = \$db->getone(\$csql);"; $codex .= "\n if (!is_array(\$datarow))"; @@ -448,21 +466,23 @@ function code_pc_php($post) { } if (count($dups) > 0) { $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saascode){ + if(!empty($saascode[1])) + $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + } foreach ($dups as $dup) { $codex .= "\n \$csql->where('{$dup}', \${$dup});"; } $codex .= "\n \$csql->column('id');"; - $codex .= "\n \$chkid = (int)\$db->get1(\$csql);"; + $codex .= "\n \$chkid = toint(\$db->get1(\$csql));"; $codex .= "\n if (\$chkid > 0 && ((\$id > 0 && \$chkid != \$id) || \$id == 0))"; - $codex .= "\n throw new \Exception('数据已存在');"; + $codex .= "\n throw new \Exception('CIYIGN数据已存在');"; } $codex .= "\n \$updata = array();"; foreach ($flds as $fld) { $col = $fld['col']; - // if($col == 'id' || $col == $saascode || $col == 'addtimes') - // continue; + if($col == 'id' || $col == 'addtimes') + continue; // if($col == 'auditstatus' || $col == 'audittimes' || $col == 'audituser' || $col == 'auditmsg') // continue; // if($col == 'matterstatus' || $col == 'matternextuser' || $col == 'mattertimes') @@ -492,14 +512,17 @@ function code_pc_php($post) { $codex .= "\n } else {"; foreach ($flds as $fld) { $col = $fld['col']; - if ($fld['set']['noup'] == 'no') { + if ($col == 'id'){ + }else if ($fld['set']['noup'] == 'no') { if($fld['type'] == 'int' || $fld['type'] == 'bigint') $codex .= "\n \$updata['{$col}'] = 0;"; else $codex .= "\n \$updata['{$col}'] = '';"; - } else if ($saascode && $col == $saascode[0]) - $codex .= "\n \$updata['{$col}'] = \$rsuser['{$saascode[1]}'];"; + } else if ($saascode && $col == $saascode[0]){ + if(!empty($saascode[1])) + $codex .= "\n \$updata['{$col}'] = \$rsuser['{$saascode[1]}'];"; + } else if ($col == 'addtimes') $codex .= "\n \$updata['{$col}'] = tostamp();"; else if ($col == 'auditstatus') @@ -522,10 +545,13 @@ function code_pc_php($post) { $codex .= "\n \$db->commit();"; $codex .= "\n } catch (\Exception \$ex) {"; $codex .= "\n \$db->rollback();"; + $codex .= "\n savelogfile('err_db', \$ex->getMessage());"; $codex .= "\n return errjson(\$ex->getMessage());"; $codex .= "\n }"; $codex .= "\n \$ret['data'] = \$updata;"; foreach ($flds as $fld) { + if ($saascode && $saascode[0] == $fld['col']) + continue; $cate = $fld['cate']; if ($cate == 'DB' || $cate == 'CATU' || $cate == 'CATS' || $cate == 'CATM') { if (isset($fld['set']['listload']) && $fld['set']['listload'] == 'rel') { @@ -558,8 +584,10 @@ function code_pc_php($post) { $codex .= "\n if (empty(\$ids))"; $codex .= "\n return errjson('请选择至少一条');"; $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saascode){ + if(!empty($saascode[1])) + $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + } $codex .= "\n \$csql->where('id in', \$ids);"; $codex .= "\n \$rows = \$db->get(\$csql);"; $codex .= "\n \$vids = array();"; @@ -581,6 +609,7 @@ function code_pc_php($post) { $codex .= "\n \$db->commit();"; $codex .= "\n } catch (\Exception \$ex) {"; $codex .= "\n \$db->rollback();"; + $codex .= "\n savelogfile('err_db', \$ex->getMessage());"; $codex .= "\n return errjson(\$ex->getMessage());"; $codex .= "\n }"; $codex .= "\n \$ret['ids'] = \$vids;"; @@ -610,8 +639,10 @@ function code_pc_php($post) { } } $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saascode){ + if(!empty($saascode[1])) + $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + } $codex .= "\n \$csql->where('id in', \$ids);"; $codex .= "\n \$rows = \$db->get(\$csql);"; $codex .= "\n \$ids = array();"; @@ -643,6 +674,7 @@ function code_pc_php($post) { $codex .= "\n \$db->commit();"; $codex .= "\n } catch (\Exception \$ex) {"; $codex .= "\n \$db->rollback();"; + $codex .= "\n savelogfile('err_db', \$ex->getMessage());"; $codex .= "\n return errjson(\$ex->getMessage());"; $codex .= "\n }"; $codex .= "\n \$ret['data'] = \$updata;"; @@ -666,8 +698,10 @@ function code_pc_php($post) { $codex .= "\n if (empty(\$ids))"; $codex .= "\n return errjson('请选择至少一条');"; $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saascode){ + if(!empty($saascode[1])) + $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + } $codex .= "\n \$csql->where('id in', \$ids);"; $codex .= "\n \$rows = \$db->get(\$csql);"; $codex .= "\n \$ids = array();"; @@ -687,6 +721,7 @@ function code_pc_php($post) { $codex .= "\n \$db->commit();"; $codex .= "\n } catch (\Exception \$ex) {"; $codex .= "\n \$db->rollback();"; + $codex .= "\n savelogfile('err_db', \$ex->getMessage());"; $codex .= "\n return errjson(\$ex->getMessage());"; $codex .= "\n }"; $codex .= "\n \$ret['data'] = \$updata;"; @@ -704,7 +739,7 @@ function code_pc_php($post) { $codex .= "\n // return errjson('您未被授权操作');"; $codex .= "\n \$post = new \\ciy\\post();"; - $codex .= "\n list(\$where, \$csql) = self::setwhere(\$db, \$post);"; + $codex .= "\n list(\$where, \$csql) = self::setwhere(\$db, \$post, \$rsuser);"; $codex .= "\n \$rows = \$db->get(\$csql);"; $codex .= "\n if (count(\$rows) > 10000)"; $codex .= "\n return errjson('将导出' . count(\$rows) . '条,不建议超过1万条,请筛选缩小范围');"; @@ -712,6 +747,8 @@ function code_pc_php($post) { foreach ($flds as $fld) { if (!$fld['bout']) continue; + if ($saascode && $saascode[0] == $fld['col']) + continue; $col = $fld['col']; $name = $fld['name']; $cate = $fld['cate']; @@ -730,6 +767,8 @@ function code_pc_php($post) { foreach ($flds as $fld) { if (!$fld['bout']) continue; + if ($saascode && $saascode[0] == $fld['col']) + continue; $col = $fld['col']; $cate = $fld['cate']; if ($cate == 'BOOL') { @@ -763,6 +802,8 @@ function code_pc_php($post) { foreach ($flds as $fld) { if ($fld['col'] != 'id' && !$fld['bout']) continue; + if ($saascode && $saascode[0] == $fld['col']) + continue; $col = $fld['col']; $cate = $fld['cate']; $ext = ''; @@ -952,6 +993,15 @@ function code_pc_php($post) { $codex .= "\n \$uniques = array();"; $codex .= "\n \$id = 0;"; $codex .= "\n for (\$rowidx = \$xlsidx; \$rowidx < \$datacnt; \$rowidx++) {"; + $codex .= "\n \$bfull = false;"; + $codex .= "\n foreach (\$datas[\$rowidx] as \$dat) {"; + $codex .= "\n if (empty(\$dat))"; + $codex .= "\n continue;"; + $codex .= "\n \$bfull = true;"; + $codex .= "\n break;"; + $codex .= "\n }"; + $codex .= "\n if (!\$bfull)"; + $codex .= "\n continue;"; $codex .= "\n \$lineidx = \$rowidx - \$xlsidx + 1;"; $codex .= "\n \$hrhtml = '';"; $codex .= "\n \$firsthtml = '
' . \$lineidx . '
';"; @@ -979,7 +1029,7 @@ function code_pc_php($post) { $codex .= "\n else {"; $codex .= "\n \$csqlchk = new \ciy\sql('{$tabname}');"; $codex .= "\n \$csqlchk->where('id', \$id)->column('id');"; - $codex .= "\n \$chkid = (int)\$db->get1(\$csqlchk);"; + $codex .= "\n \$chkid = toint(\$db->get1(\$csqlchk));"; $codex .= "\n if (\$chkid != \$id)"; $codex .= "\n \$errmsg = \$name . '在数据库中不存在';"; $codex .= "\n \$value = \$id;"; @@ -1096,7 +1146,7 @@ function code_pc_php($post) { $codex .= "\n \$errmsg = \$name . '文字与系统数据不匹配';"; } else if ($cate == 'CYC') { $codex .= "\n \$last = substr(\$showdat, -3);"; - $codex .= "\n \$dd = (int)substr(\$showdat, 0, -3);"; + $codex .= "\n \$dd = toint(substr(\$showdat, 0, -3));"; $codex .= "\n if (\$dd == 0) {"; $codex .= "\n \$errmsg = \$name . '周期数字错误';"; $codex .= "\n } else if (\$last == '天') {"; @@ -1160,11 +1210,11 @@ function code_pc_php($post) { $codex .= "\n \$errmsg = \$name . '不是数字';"; $codex .= "\n else"; if ($bet > 1) - $codex .= "\n \$value = (int)((float)\$showdat * {$bet});"; + $codex .= "\n \$value = toint((float)\$showdat * {$bet});"; else if ($type == 'double' || $type == 'float') $codex .= "\n \$value = (float)\$showdat;"; else - $codex .= "\n \$value = (int)\$showdat;"; + $codex .= "\n \$value = toint(\$showdat);"; if (!empty($unit)) $codex .= "\n \$showdat .= '{$unit}';"; } @@ -1190,7 +1240,7 @@ function code_pc_php($post) { $codex .= "\n else {"; $codex .= "\n \$uniques[] = \$unq;"; $codex .= "\n \$csql->column('id');"; - $codex .= "\n \$chkid = (int)\$db->get1(\$csql);"; + $codex .= "\n \$chkid = toint(\$db->get1(\$csql));"; $codex .= "\n if (\$chkid > 0 && ((\$id > 0 && \$chkid != \$id) || \$id == 0))"; $codex .= "\n \$firsthtml = '
重复
';"; $codex .= "\n }"; @@ -1226,15 +1276,17 @@ function code_pc_php($post) { } if (count($dups) > 0) { $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saascode){ + if(!empty($saascode[1])) + $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + } foreach ($dups as $dup) { $codex .= "\n \$csql->where('{$dup}', \${$dup});"; } $codex .= "\n \$csql->column('id');"; - $codex .= "\n \$chkid = (int)\$db->get1(\$csql);"; + $codex .= "\n \$chkid = toint(\$db->get1(\$csql));"; $codex .= "\n if (\$chkid > 0 && ((\$id > 0 && \$chkid != \$id) || \$id == 0))"; - $codex .= "\n throw new \Exception('发现数据有重复');"; + $codex .= "\n throw new \Exception('CIYIGN发现数据有重复');"; } $codex .= "\n \$updata = array();"; foreach ($flds as $fld) { @@ -1249,8 +1301,10 @@ function code_pc_php($post) { $codex .= "\n if (\$id == 0) {"; foreach ($flds as $fld) { $col = $fld['col']; - if ($saascode && $col == $saascode[0]) - $codex .= "\n \$updata['{$col}'] = \$rsuser['{$saascode[1]}'];"; + if ($saascode && $col == $saascode[0]){ + if(!empty($saascode[1])) + $codex .= "\n \$updata['{$col}'] = \$rsuser['{$saascode[1]}'];"; + } if ($col == 'addtimes') $codex .= "\n \$updata['{$col}'] = tostamp();"; if ($col == 'auditstatus') @@ -1269,6 +1323,7 @@ function code_pc_php($post) { $codex .= "\n \$db->commit();"; $codex .= "\n } catch (\Exception \$ex) {"; $codex .= "\n \$db->rollback();"; + $codex .= "\n savelogfile('err_db', \$ex->getMessage());"; $codex .= "\n return errjson(\$ex->getMessage());"; $codex .= "\n }"; $codex .= "\n return succjson();"; diff --git a/web/admin/develop/code_saas.html b/web/admin/develop/code_saas.html new file mode 100644 index 0000000..164faaa --- /dev/null +++ b/web/admin/develop/code_saas.html @@ -0,0 +1,143 @@ + + + + + + + + + + + + +
+ +
+
Loading...
+
+
+
+ 全选 + 反选 + | + 批量删除 +
+
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/web/admin/develop/code_saas.php b/web/admin/develop/code_saas.php new file mode 100644 index 0000000..f44b497 --- /dev/null +++ b/web/admin/develop/code_saas.php @@ -0,0 +1,150 @@ +get('query'); + $csql = new \ciy\sql('zc_dev_dbsaas'); + $order = objstr($query, 'order', 'id desc'); + $csql->order($order); + $query['order'] = $order; + return [$query, $csql]; + } + + public static function json_list() { + global $db; + $rsuser = verifyfast(); + $post = new \ciy\post(); + list($where, $csql) = self::setwhere($db, $post); + $pageno = $post->getint('pageno', 1); + $pagecount = $post->getint('pagecount', 10); + $csql->limit($pageno, $pagecount); + $mainrowcount = $post->getint('count'); + $rows = $db->get($csql, $mainrowcount); + if($rows === false) + return errjson($db->error); + $ret = array('where' => $where, 'pageno' => $pageno, 'pagecount' => $pagecount, 'count' => $mainrowcount, 'list' => $rows); + if ($post->getbool('field')) { + $field = array(); + $fshow = $db->getfield($field, 'zc_dev_dbsaas'); + foreach ($field as $fr => $v) { + if (get('_' . $fr)) + $field[$fr]['c'] = ',' . $field[$fr]['c']; + } + $fshow = fieldadd($fshow, $field, 0, '_btn', '操作'); + $ret['field'] = $field; + $ret['fshow'] = $fshow; + } + if ($post->getbool('once')) { + $ret['once'] = array(); + } + return succjson($ret); + } + + public static function json_getdata() { + global $db; + $rsuser = verifyfast(); + $post = new \ciy\post(); + $id = $post->getint('id'); + $act = $post->get('act'); + if ($id > 0) { + $csql = new \ciy\sql('zc_dev_dbsaas'); + $csql->where('id', $id); + $row = $db->getone($csql); + if (!is_array($row)) + return errjson('数据不存在'); + } else { + $row = array(); + } + $ret['data'] = $row; + if ($act == 'edit') { + $csql = new \ciy\sql('INFORMATION_SCHEMA.SCHEMATA'); + $csql->column('SCHEMA_NAME as id,SCHEMA_NAME as name'); + $sehrows = $db->get($csql); + $ret['schema'] = $sehrows; + } + return succjson($ret); + } + + public static function json_update() { + global $db; + $rsuser = verifyfast(); + //if (nopower($db, $rsuser['id'], 'p u')) + // return errjson('您未被授权操作'); + $post = new \ciy\post(); + $id = $post->getint('id'); + $name = $post->get('name'); + $schem = $post->get('schem'); + $subpath = $post->get('subpath'); + $datarow = null; + if ($id > 0) { + $csql = new \ciy\sql('zc_dev_dbsaas'); + $csql->where('id', $id); + $datarow = $db->getone($csql); + if (!is_array($datarow)) + return errjson('数据不存在'); + } + try { + $db->begin(); + $updata = array(); + $updata['name'] = $name; + $updata['schem'] = $schem; + $updata['subpath'] = $subpath; + $csql = new \ciy\sql('zc_dev_dbsaas'); + if ($id > 0) { + $csql->where('id', $id); + if ($db->update($csql, $updata) === false) + throw new \Exception('更新失败:' . $db->error); + } else { + $updata['id'] = 0; + if ($db->insert($csql, $updata) === false) + throw new \Exception('新增失败:' . $db->error); + $id = $db->insert_id(); + } + $updata['id'] = $id; + //savelogdb($db, $rsuser['id'], 'zc_dev_dbsaas', $datarow, $updata); + $db->commit(); + } catch (\Exception $ex) { + $db->rollback(); + savelogfile('err_db', $ex->getMessage()); + return errjson($ex->getMessage()); + } + $ret['data'] = $updata; + $ret['hf_providerbase'] = getrelation($db, [$updata], 'hf_providerbase', 'providerid'); + return succjson($ret); + } + + public static function json_del() { + global $db; + $rsuser = verifyfast(); + //if (nopower($db, $rsuser['id'], 'p d')) + // return errjson('您未被授权操作'); + $post = new \ciy\post(); + $ids = $post->get('ids'); + if (empty($ids)) + return errjson('请选择至少一条'); + $csql = new \ciy\sql('zc_dev_dbsaas'); + $csql->where('id in', $ids); + $rows = $db->get($csql); + $vids = array(); + try { + $db->begin(); + foreach ($rows as $row) { + $delid = $row['id']; + //delcheck($db, $delid, 'tablexx', 'xxid', '管理员'); + //delall($db, $delid, 'tablexx', 'xxid', '运动员'); //deltimeall + delme($db, $delid, 'zc_dev_dbsaas'); + savelogdb($db, $rsuser['id'], 'zc_dev_dbsaas', $row, null); + $vids[] = $delid; + } + $db->commit(); + } catch (\Exception $ex) { + $db->rollback(); + savelogfile('err_db', $ex->getMessage()); + return errjson($ex->getMessage()); + } + $ret['ids'] = $vids; + return succjson($ret); + } +} diff --git a/web/admin/develop/note.php b/web/admin/develop/note.php index 62fe3a1..34eae12 100644 --- a/web/admin/develop/note.php +++ b/web/admin/develop/note.php @@ -67,6 +67,7 @@ class note { $db->commit(); } catch (\Exception $ex) { $db->rollback(); + savelogfile('err_db', $ex->getMessage()); return errjson($ex->getMessage()); } if ($id > 0) diff --git a/web/admin/index.go b/web/admin/index.go index f59557e..f515ca8 100644 --- a/web/admin/index.go +++ b/web/admin/index.go @@ -37,7 +37,7 @@ func Index_init(w http.ResponseWriter, r *http.Request) bool { menurows = append(menurows, menu) } csql = c.NewCiySQL("zc_mnufav") - csql.Where("user", userid).Column("menuid") + csql.Where("favtarget", 10).Where("user", userid).Column("menuid") mnufavrows, _, err := c.CiyDB.Get(csql) if err != nil { return c.ErrJSON(w, "遇到mnufav读取错误", err) @@ -62,13 +62,14 @@ func Index_favadd(w http.ResponseWriter, r *http.Request) bool { } menuid := post.Getint("id") csql := c.NewCiySQL("zc_mnufav") - csql.Where("user", userid).Where("menuid", menuid) + csql.Where("favtarget", 10).Where("user", userid).Where("menuid", menuid) favrow, err := c.CiyDB.Getone(csql) if err != nil { return c.ErrJSON(w, "遇到fav读取错误", err) } if favrow == nil { updata := map[string]any{} + updata["favtarget"] = 10 updata["user"] = userid updata["menuid"] = menuid updata["addtimes"] = c.Tostamp() @@ -88,7 +89,7 @@ func Index_favdel(w http.ResponseWriter, r *http.Request) bool { } menuid := post.Getint("id") csql := c.NewCiySQL("zc_mnufav") - csql.Where("user", userid).Where("menuid", menuid) + csql.Where("favtarget", 10).Where("user", userid).Where("menuid", menuid) _, err := c.CiyDB.Delete(csql) if err != nil { return c.ErrJSON(w, "删除fav失败", err) diff --git a/web/admin/index.html b/web/admin/index.html index 4fc1559..60a09b1 100644 --- a/web/admin/index.html +++ b/web/admin/index.html @@ -652,16 +652,6 @@ else return 'data-href="' + url + '"'; } - function ciy_ifrclose(domtab) { - var txt = domtab.attr('data-tit'); - var domifm = $5("#id_ifms>iframe[data-tit='" + txt + "']"); - domifm[0].src = 'about:blank'; - domifm[0].contentWindow.close(); - setTimeout(function () { - domifm.remove(); - }, 100); - domtab.remove(); - } $5('#nav_menu').html(html); var lmenuact = opn.act; var tabsdom = $5('#id_headertabs'); @@ -696,7 +686,7 @@ thos.page_refresh(); }); tabsuldom.on('click', "i", function (e) { - ciy_ifrclose($5(e.currentTarget).parent('li')); + thos.page_ifrclose($5(e.currentTarget).parent('li')); }); ciyclass.dragdom({ dom: tabsuldom @@ -904,6 +894,16 @@ if (domifm.length == 1) domifm[0].contentWindow.location.reload(); //domifm.attr('src', domifm.attr('src')); } + this.page_ifrclose = function (domtab) { + var txt = domtab.attr('data-tit'); + var domifm = $5("#id_ifms>iframe[data-tit='" + txt + "']"); + domifm[0].src = 'about:blank'; + domifm[0].contentWindow.close(); + setTimeout(function () { + domifm.remove(); + }, 100); + domtab.remove(); + } this.headertabscroll = function (act) { var width = tabsdom.width() * 2 / 3; var sl = tabsdom[0].scrollLeft; @@ -963,6 +963,18 @@ if (event.data.func == 'manage_ifropen') { Glob.manage.page_ifropen(event.data.url, event.data.name, event.data.ableclose, event.source); } + if (event.data.func == 'manage_ifrclose') { + var domli; + if (event.data.name) + domli = $5('#id_headertabs_ul>li[data-tit="' + event.data.name + '"]'); + else + domli = $5("#id_headertabs_ul>li.active"); + if (domli.length == 0) + return; + Glob.manage.page_ifrclose(domli); + var domltab = $5('#id_headertabs_ul').children(-1); + Glob.manage.page_ifropen('', domltab.attr('data-tit')); + } if (event.data.func == 'manage_fulldiv') { if (event.data.full) { $5('.ciy-body-main').css({ zIndex: null }); diff --git a/web/admin/index.php b/web/admin/index.php index 3885af5..31451b7 100644 --- a/web/admin/index.php +++ b/web/admin/index.php @@ -19,6 +19,7 @@ class index { $ret['menu'][] = array('id' => 2, 'upid' => 0, 'name' => '您无任何菜单权限', 'url' => '', 'pow' => '', 'csort' => 0); $csql = new \ciy\sql('zc_mnufav'); + $csql->where('favtarget', 10); $csql->where('user', $rsuser['id']); $csql->column('menuid'); $ret['mnufav'] = $db->get($csql); @@ -32,11 +33,13 @@ class index { $post = new \ciy\post(); $menuid = $post->getint('id'); $csql = new \ciy\sql('zc_mnufav'); + $csql->where('favtarget', 10); $csql->where('user', $rsuser['id']); $csql->where('menuid', $menuid); $favrow = $db->getone($csql); if (!is_array($favrow)) { $updata = array(); + $updata['favtarget'] = 10; $updata['user'] = $rsuser['id']; $updata['menuid'] = $menuid; $updata['addtimes'] = tostamp(); @@ -51,6 +54,7 @@ class index { $post = new \ciy\post(); $menuid = $post->getint('id'); $csql = new \ciy\sql('zc_mnufav'); + $csql->where('favtarget', 10); $csql->where('user', $rsuser['id']); $csql->where('menuid', $menuid); $db->delete($csql); diff --git a/web/admin/login.html b/web/admin/login.html index 2a05f0c..5743fc0 100644 --- a/web/admin/login.html +++ b/web/admin/login.html @@ -145,7 +145,6 @@
© 2024 众产®
-