diff --git a/route_adm.go b/route_adm.go index 3a5d625..4d3a042 100644 --- a/route_adm.go +++ b/route_adm.go @@ -51,6 +51,10 @@ func setWebRoute_adm(web *c.CiyWebServer) { "del": rigger.Logdb_del, "multiread": rigger.Logdb_multiread, }, + "luser": { + "init": rigger.Luser_init, + "del": rigger.Luser_del, + }, "funcslow": { "init": rigger.Funcslow_init, "del": rigger.Funcslow_del, diff --git a/web/admin/ap/art_post.html b/web/admin/ap/art_post.html index ea4c744..27cca82 100644 --- a/web/admin/ap/art_post.html +++ b/web/admin/ap/art_post.html @@ -94,7 +94,7 @@
- +
diff --git a/web/admin/ap/banner.html b/web/admin/ap/banner.html index 09e6230..32989a7 100644 --- a/web/admin/ap/banner.html +++ b/web/admin/ap/banner.html @@ -40,7 +40,7 @@
- +
diff --git a/web/admin/ap/logdb.html b/web/admin/ap/logdb.html new file mode 100644 index 0000000..6a061df --- /dev/null +++ b/web/admin/ap/logdb.html @@ -0,0 +1,113 @@ + + + + + + + + + + + + +
+ +
+
Loading...
+
+
+ +
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/web/admin/ap/logdb.php b/web/admin/ap/logdb.php new file mode 100644 index 0000000..b905f63 --- /dev/null +++ b/web/admin/ap/logdb.php @@ -0,0 +1,163 @@ +get('query'); + $csql = new \ciy\sql('ap_log'); + $liid = objint($query, 'liid'); + if ($liid == 1) + $csql->where('readuser=0'); + if ($liid == 2) + $csql->where('readuser>0'); + $val = objstr($query, 'loguser'); + if (!empty($val)) { + $csqlt = new \ciy\sql('ap_user'); + $csqlt->where('name like', $val); + $trow = $db->getone($csqlt); + if (is_array($trow)) { + $csql->where('loguser', $trow['id']); + $query['loguser'] = $trow['name']; + } else { + $csql->where('loguser=0'); + } + } + $csql->where('readuser', objstr($query, 'readuser')); + $csql->where('types', objstr($query, 'types')); + $csql->wheredaterange('addtimes', objstr($query, 'addtimes')); + $csql->where('logs like', objstr($query, 'logs')); + $order = objstr($query, 'order', 'id desc'); + $csql->order($order); + $query['order'] = $order; + return [$query, $csql]; + } + public static function json_init() { + 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); + $ret = array('where' => $where, 'pageno' => $pageno, 'pagecount' => $pagecount, 'count' => $mainrowcount, 'list' => $rows); + if ($post->getbool('field')) { + $field = array(); + $fshow = $db->getfield($field, 'ap_log'); + $ret['field'] = $field; + $ret['fshow'] = $fshow; + } + + if ($post->getbool('once')) { + $ret['once'] = array(); + $input = array(); + $input[] = array( + 'type' => 'input', + 'form' => 'loguser', + 'name' => '操作人', + 'prop' => ' style="width:6em;"', + ); + $input[] = array( + 'type' => 'select', + 'form' => 'readuser', + 'name' => '审阅人', + 'prop' => ' style="min-width:6em;"', + 'select' => 'adminuser', + 'all' => '全部' + ); + $input[] = array( + 'type' => 'input', + 'form' => 'types', + 'name' => 'LOG分类', + 'prop' => ' style="width:8em;"' + ); + $input[] = array( + 'type' => 'daterange', + 'form' => 'addtimes', + 'name' => '发生日期' + ); + $input[] = array( + 'type' => 'input', + 'form' => 'logs', + 'name' => '详情', + 'prop' => ' style="width:8em;"' + ); + $ret['once']['input'] = $input; + } + $ret['ap_user'] = getrelation($db, $rows, 'ap_user', 'loguser'); + return succjson($ret); + } + public static function json_del() { + global $db; + $rsuser = verifyfast(); + + if (nopower($db, $rsuser['id'], 'p10260d')) + return errjson('您未被授权操作'); + + $post = new \ciy\post(); + $ids = $post->get('ids'); + if (empty($ids)) + return errjson('请选择至少一条'); + $csql = new \ciy\sql('ap_log'); + + $csql->where('id in', $ids); + $rows = $db->get($csql); + $vids = array(); + try { + $db->begin(); + foreach ($rows as $row) { + $delid = $row['id']; + delme($db, $delid, 'ap_log'); + $vids[] = $delid; + } + $db->commit(); + } catch (\Exception $ex) { + $db->rollback(); + savelogfile('err_db', $ex->getMessage()); + return errjson($ex->getMessage()); + } + $ret['ids'] = $vids; + return succjson($ret); + } + + public static function json_multiread() { + global $db; + $rsuser = verifyfast(); + + if (nopower($db, $rsuser['id'], 'p10260s')) + return errjson('您未被授权操作'); + + $post = new \ciy\post(); + $ids = $post->get('ids'); + if (empty($ids)) + return errjson('请选择至少一条'); + $csql = new \ciy\sql('ap_log'); + + $csql->where('id in', $ids); + $rows = $db->get($csql); + $vids = array(); + try { + $db->begin(); + foreach ($rows as $row) { + $rowid = $row['id']; + $updata = array(); + $updata['readuser'] = $rsuser['id']; + $csql = new \ciy\sql('ap_log'); + $csql->where('id', $rowid); + if ($db->update($csql, $updata) === false) + throw new \Exception('更新失败:' . $db->error); + $vids[] = $rowid; + } + $db->commit(); + } catch (\Exception $ex) { + $db->rollback(); + savelogfile('err_db', $ex->getMessage()); + return errjson($ex->getMessage()); + } + $ret['ids'] = $vids; + $ret['data'] = $updata; + return succjson($ret); + } +} diff --git a/web/admin/ap/luser.html b/web/admin/ap/luser.html new file mode 100644 index 0000000..a12ae28 --- /dev/null +++ b/web/admin/ap/luser.html @@ -0,0 +1,71 @@ + + + + + + + + + + + + +
+ +
+
Loading...
+
+
+
+ 全选 + 反选 + | + 批量删除 +
+
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/web/admin/ap/luser.php b/web/admin/ap/luser.php new file mode 100644 index 0000000..f2920ab --- /dev/null +++ b/web/admin/ap/luser.php @@ -0,0 +1,105 @@ +get('query'); + $csql = new \ciy\sql('ap_luser'); + $liid = objint($query, 'liid'); + if ($liid > 0) + $csql->where('isinout', $liid); + $val = objstr($query, 'loguser'); + if (!empty($val)) { + $csqlt = new \ciy\sql('ap_user'); + $csqlt->where('name like', $val); + $trow = $db->getone($csqlt); + if (is_array($trow)) { + $csql->where('loguser', $trow['id']); + $query['loguser'] = $trow['name']; + } else { + $csql->where('loguser=0'); + } + } + $csql->where('model like', objstr($query, 'model')); + $csql->wheredaterange('addtimes', objstr($query, 'addtimes')); + $order = objstr($query, 'order', 'id desc'); + $csql->order($order); + $query['order'] = $order; + return [$query, $csql]; + } + public static function json_init() { + 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); + $ret = array('where' => $where, 'pageno' => $pageno, 'pagecount' => $pagecount, 'count' => $mainrowcount, 'list' => $rows); + if ($post->getbool('field')) { + $field = array(); + $fshow = $db->getfield($field, 'ap_luser'); + $ret['field'] = $field; + $ret['fshow'] = $fshow; + } + + if ($post->getbool('once')) { + $ret['once'] = array(); + $input = array(); + $input[] = array( + 'type' => 'input', + 'form' => 'loguser', + 'name' => '操作人', + 'prop' => ' style="width:6em;"', + ); + $input[] = array( + 'type' => 'daterange', + 'form' => 'addtimes', + 'name' => '发生日期' + ); + $input[] = array( + 'type' => 'input', + 'form' => 'model', + 'name' => '设备指纹', + ); + $ret['once']['input'] = $input; + } + $ret['ap_user'] = getrelation($db, $rows, 'ap_user', 'loguser'); + return succjson($ret); + } + public static function json_del() { + global $db; + $rsuser = verifyfast(); + + if (nopower($db, $rsuser['id'], 'p10261d')) + return errjson('您未被授权操作'); + + $post = new \ciy\post(); + $ids = $post->get('ids'); + if (empty($ids)) + return errjson('请选择至少一条'); + $csql = new \ciy\sql('ap_luser'); + + $csql->where('id in', $ids); + $rows = $db->get($csql); + $vids = array(); + try { + $db->begin(); + foreach ($rows as $row) { + $delid = $row['id']; + delme($db, $delid, 'ap_luser'); + $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/ap/user.html b/web/admin/ap/user.html index ab439b2..7c2aef7 100644 --- a/web/admin/ap/user.html +++ b/web/admin/ap/user.html @@ -40,7 +40,7 @@
- +
diff --git a/web/admin/ap/user.php b/web/admin/ap/user.php index fb901b9..27ee96b 100644 --- a/web/admin/ap/user.php +++ b/web/admin/ap/user.php @@ -212,7 +212,8 @@ class user { $fields[] = array('style' => 'l', 'width' => 150, 'field' => 'mobile', 'name' => '手机号'); $fields[] = array('style' => 'c', 'width' => 100, 'field' => 'stpstatus', 'name' => '账号状态'); $fields[] = array('style' => 'r', 'width' => 100, 'field' => 'myinvmoney', 'name' => '待开票金额'); - $fields[] = array('style' => 'r', 'width' => 100, 'field' => 'mycashmoney', 'name' => '可提现金额'); + $fields[] = array('style' => 'r', 'width' => 100, 'field' => 'mycashmoney', 'name' => '用户余额'); + $fields[] = array('style' => 'r', 'width' => 100, 'field' => 'mybondmoney', 'name' => '保证金'); $fields[] = array('style' => 'r', 'width' => 100, 'field' => 'mypnt', 'name' => '金币'); $fields[] = array('style' => 'l', 'width' => 150, 'field' => 'certs', 'name' => '认证范围'); $fields[] = array('style' => 'l', 'width' => 100, 'field' => 'logintimes', 'name' => '登录时间'); @@ -245,6 +246,8 @@ class user { $val = number_format($val / 100, 2); if ($field == 'mycashmoney') $val = number_format($val / 100, 2); + if ($field == 'mybondmoney') + $val = number_format($val / 100, 2); if ($field == 'certs') $val = implode(',', scode($code_certs, $val)); if ($field == 'logintimes') diff --git a/web/admin/ap/usr_invoicing.html b/web/admin/ap/usr_invoicing.html index 1d746c9..af2317e 100644 --- a/web/admin/ap/usr_invoicing.html +++ b/web/admin/ap/usr_invoicing.html @@ -77,7 +77,7 @@
- +
diff --git a/web/admin/autotask/at_base.php b/web/admin/autotask/at_base.php deleted file mode 100644 index d59688a..0000000 --- a/web/admin/autotask/at_base.php +++ /dev/null @@ -1,222 +0,0 @@ -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)); - - $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) - return 'clean ' . $csql->table . ': ' . $db->error . '
'; - else if ($execute > 0) - 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; - } - $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; - $func_succ = 0; - $func_fail = 0; - $func_commit = 0; - $func_rollback = 0; - $func_runms = 0; - $csql = new \ciy\sql('zc_zmem_var'); - $memrows = $db->get($csql); - foreach ($memrows as $memrow) { - if ($memrow['types'] == 'func_succ') - $func_succ = toint($memrow['params']); - else if ($memrow['types'] == 'func_fail') - $func_fail = toint($memrow['params']); - else if ($memrow['types'] == 'func_commit') - $func_commit = toint($memrow['params']); - else if ($memrow['types'] == 'func_rollback') - $func_rollback = toint($memrow['params']); - else if ($memrow['types'] == 'func_runms') { - $func_runms = toint($memrow['params']); - } else - continue; - $updata = array(); - $updata['params'] = 0; - $csql = new \ciy\sql('zc_zmem_var'); - $csql->where('id', $memrow['id']); - $db->update($csql, $updata); - } - $func_runms = 0; - if ($func_succ + $func_fail > 0) - $func_runms = $func_runms / ($func_succ + $func_fail); - - $disk_sysfree = disk_free_space("/"); - $disk_datafree = disk_free_space("/data"); - // $disk_sysfree = disk_free_space("D:/"); - // $disk_datafree = disk_free_space("E:/"); - $starttime = timems(); - $fcontent = str_repeat("0", 1024 * 1024); //写入1MB - $fpath = PATH_WEB . "/ud/_" . tostamp() . ".bin"; - file_put_contents($fpath, $fcontent); - $rcontent = file_get_contents($fpath); - unlink($fpath); - $disk_ioms = timems() - $starttime; - if ($rcontent !== $fcontent) { - savelog($db, 0, 'STAT', '写入临时文件校验失败'); - } - - $output = array(); - exec("ps aux -A", $output); - // $output = array(); - // $output[] = "USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND"; - // $output[] = "root 1 0.0 0.0 190928 3396 ? Ss Apr10 9:54 /usr/lib/systemd/systemd --switched-root --system --deserialize 22"; - // $output[] = "root 2 0.0 0.0 0 0 ? S Apr10 0:00 [kthreadd]"; - // $output[] = "root 1322 0.0 0.0 102900 2320 ? Ss Apr10 0:00 /sbin/dhclient -q -lf /var/lib/dhclient/dhclient--eth0.lease -pf /var/run/dhclient-eth0.pid -H VM_0_5_centos eth0"; - // $output[] = "mysql 2219 0.2 9.3 1654448 362344 ? Sl Apr10 76:53 /usr/libexec/mysqld --basedir=/usr --datadir=/data/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock"; - // $output[] = "root 2934 0.0 0.2 494920 10360 ? S Apr10 0:02 WorkerMan: worker process proxy tcp://0.0.0.0:6981"; - $cmddb = ['mysql', 'mysqld']; - $cmdweb = ['nginx', 'php', 'WorkerMan', 'mosquitto', 'gitea', '/zgo']; - $cpu = array('db' => 0, 'web' => 0, 'oth' => 0); - $mem = array('db' => 0, 'web' => 0, 'oth' => 0); - - foreach ($output as $line) { - if (strpos($line, "COMMAND") !== false) - continue; - _base_nextspace($line); - _base_nextspace($line); - $cpup = (float)_base_nextspace($line); - $memp = (float)_base_nextspace($line); - _base_nextspace($line); //虚拟内存 - _base_nextspace($line); //物理内存 包括共享内存 - _base_nextspace($line); - _base_nextspace($line); - _base_nextspace($line); - _base_nextspace($line); - if (_base_arrin($line, $cmddb)) { - $cpu['db'] += $cpup; - $mem['db'] += $memp; - } else if (_base_arrin($line, $cmdweb)) { - $cpu['web'] += $cpup; - $mem['web'] += $memp; - } else { - $cpu['oth'] += $cpup; - $mem['oth'] += $memp; - } - } - - $output = array(); - exec("free -m", $output); - // $output = array(); - // $output[] = " total used free shared buff/cache available"; - // $output[] = "Mem: 3789 860 201 18 2727 2629"; - - preg_match('/Mem:\s+(\d+)/', $output[1], $totalmem); - $mem_free = $totalmem[1] * (100 - $cpu['db'] - $cpu['web'] - $cpu['oth']) * 1024 * 1024 / 100; - - $output = array(); - exec("netstat -an | awk '/^tcp/ {++S[\$NF]} END {for(a in S) print a, S[a]}'", $output); - - // $output = array(); - // $output[] = "LISTEN 13"; - // $output[] = "SYN_RECV 3"; - // $output[] = "ESTABLISHED 15"; - // $output[] = "TIME_WAIT 36"; - $net_tcp = 0; - foreach ($output as $line) { - $ls = explode(" ", $line); - if ($ls[0] == 'LISTEN') - continue; - $net_tcp += toint($ls[1]); - } - - $starttime = timems(); - $http = new ciy\http(); - $http->request('https://www.baidu.com'); - $http->get_data(); - $net_ioms = timems() - $starttime; - - $dbrows = $db->getraw('show global status'); - $dbstat = array(); - for ($i = 0; $i < count($dbrows); $i++) { - $name = $dbrows[$i]['Variable_name']; - $val = $dbrows[$i]['Value']; - $dbstat[$name] = $val; - } - $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; - $updata['func_fail'] = $func_fail; - $updata['func_commit'] = $func_commit; - $updata['func_rollback'] = $func_rollback; - $updata['func_runms'] = $func_runms; - $updata['disk_sysfree'] = $disk_sysfree; - $updata['disk_datafree'] = $disk_datafree; - $updata['disk_ioms'] = $disk_ioms; - $updata['cpu_free'] = 100 - $cpu['db'] - $cpu['web'] - $cpu['oth']; - $updata['cpu_db'] = $cpu['db']; - $updata['cpu_web'] = $cpu['web']; - $updata['cpu_oth'] = $cpu['oth']; - $updata['mem_free'] = $mem_free; - $updata['mem_db'] = $mem['db']; - $updata['mem_web'] = $mem['web']; - $updata['mem_oth'] = $mem['oth']; - $updata['net_tcp'] = $net_tcp; - $updata['net_ioms'] = $net_ioms; - $updata['db_query'] = $dbstat['Questions']; - $updata['db_commit'] = $dbstat['Com_commit']; - $updata['db_rollback'] = $dbstat['Com_rollback']; - $updata['db_keyhit'] = $db_keyhit; - $updata['db_dbhit'] = $db_dbhit; - $updata['db_tmptable'] = $db_tmptable; - $updata['db_lock'] = $dbstat['Innodb_row_lock_current_waits']; - $updata['addtimes'] = tostamp(); - $csql = new \ciy\sql('zc_stats'); - $db->insert($csql, $updata); - if ($func_succ == 0 && $func_fail == 0 && $func_rollback == 0) - return ''; - return 'succ: ' . $func_succ . ($func_rollback > 0 ? ', rollback: ' . $func_rollback : ''); -} -function _base_nextspace(&$line) { - $ind = strpos($line, " "); - if ($ind === false) { - $line = ''; - return $line; - } - $va = substr($line, 0, $ind); - $line = ltrim(substr($line, $ind)); - return $va; -} -function _base_arrin($cmd, $arr) { - foreach ($arr as $v) { - if (strpos($cmd, $v) !== false) - return true; - } - return false; -} diff --git a/web/admin/autotask/at_base.go b/web/admin/autotask/base.go similarity index 98% rename from web/admin/autotask/at_base.go rename to web/admin/autotask/base.go index 1c27c4a..b8fadde 100644 --- a/web/admin/autotask/at_base.go +++ b/web/admin/autotask/base.go @@ -13,8 +13,8 @@ import ( func funcindex() map[string]func(map[string]any) string { return map[string]func(map[string]any) string{ - "dayclean": dayclean, - "srvstats": srvstats, + "web\\admin\\autotask\\base::dayclean": dayclean, + "web\\admin\\autotask\\base::srvstats": srvstats, } } func srvstats(systemrow map[string]any) string { diff --git a/web/admin/autotask/base.php b/web/admin/autotask/base.php new file mode 100644 index 0000000..35b4984 --- /dev/null +++ b/web/admin/autotask/base.php @@ -0,0 +1,231 @@ +where('addtimes<', time() - 86400 * 90)); + $msg .= self::_base_deldb($db, (new \ciy\sql('zc_autotsk_log'))->where('addtimes<', time() - 86400 * 90)); + $msg .= self::_base_deldb($db, (new \ciy\sql('zc_funcslow'))->where('addtimes<', time() - 86400 * 60)); + $msg .= self::_base_deldb($db, (new \ciy\sql('zc_stats'))->where('addtimes<', time() - 86400 * 60)); + $msg .= self::_base_deldb($db, (new \ciy\sql('zc_log'))->where('addtimes<', time() - 86400 * 100)); + $msg .= self::_base_deldb($db, (new \ciy\sql('zc_online'))->where('exptimes<', time() - 86400 * 7)); + + $cnt = 0; + $msg .= self::_base_delfile(PATH_WEB . 'ud/tmp', 86400 * 3, $cnt); + $cnt = 0; + $msg .= self::_base_delfile(PATH_WEB . 'ud/rep', 86400 * 1, $cnt); + return $msg; + } + static function _base_deldb($db, $csql) { + $execute = $db->delete($csql); + if ($execute === false) + return 'clean ' . $csql->table . ': ' . $db->error . '
'; + else if ($execute > 0) + return 'clean ' . $csql->table . ': ' . $execute . '
'; + return ''; + } + static function _base_delfile($pathfile, $timespan, &$cnt, $deep = 0) { + if (!is_dir($pathfile)) { + if (file_exists($pathfile)) { + $mtime = filemtime($pathfile); + if ($mtime !== false) { + if (tostamp() - $mtime > $timespan) { + $cnt++; + filedel($pathfile); + } + } + } + return; + } + $files = scandir($pathfile); + foreach ($files as $file) { + if ($file == '.' || $file == '..') + continue; + self::_base_delfile($pathfile . '/' . $file, $timespan, $cnt, 1); + } + if ($deep == 0 && $cnt > 0) + return 'clean file: ' . $cnt . ' ' . substr($pathfile, strlen(PATH_WEB)) . '
'; + return ''; + } + public static function srvstats($systemrow) { + global $db; + $func_succ = 0; + $func_fail = 0; + $func_commit = 0; + $func_rollback = 0; + $func_runms = 0; + $csql = new \ciy\sql('zc_zmem_var'); + $memrows = $db->get($csql); + foreach ($memrows as $memrow) { + if ($memrow['types'] == 'func_succ') + $func_succ = toint($memrow['params']); + else if ($memrow['types'] == 'func_fail') + $func_fail = toint($memrow['params']); + else if ($memrow['types'] == 'func_commit') + $func_commit = toint($memrow['params']); + else if ($memrow['types'] == 'func_rollback') + $func_rollback = toint($memrow['params']); + else if ($memrow['types'] == 'func_runms') { + $func_runms = toint($memrow['params']); + } else + continue; + $updata = array(); + $updata['params'] = 0; + $csql = new \ciy\sql('zc_zmem_var'); + $csql->where('id', $memrow['id']); + $db->update($csql, $updata); + } + $func_runms = 0; + if ($func_succ + $func_fail > 0) + $func_runms = $func_runms / ($func_succ + $func_fail); + + $disk_sysfree = disk_free_space("/"); + $disk_datafree = disk_free_space("/data"); + // $disk_sysfree = disk_free_space("D:/"); + // $disk_datafree = disk_free_space("E:/"); + $starttime = timems(); + $fcontent = str_repeat("0", 1024 * 1024); //写入1MB + $fpath = PATH_WEB . "/ud/_" . tostamp() . ".bin"; + file_put_contents($fpath, $fcontent); + $rcontent = file_get_contents($fpath); + unlink($fpath); + $disk_ioms = timems() - $starttime; + if ($rcontent !== $fcontent) { + savelog($db, 0, 'STAT', '写入临时文件校验失败'); + } + + $output = array(); + exec("ps aux -A", $output); + // $output = array(); + // $output[] = "USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND"; + // $output[] = "root 1 0.0 0.0 190928 3396 ? Ss Apr10 9:54 /usr/lib/systemd/systemd --switched-root --system --deserialize 22"; + // $output[] = "root 2 0.0 0.0 0 0 ? S Apr10 0:00 [kthreadd]"; + // $output[] = "root 1322 0.0 0.0 102900 2320 ? Ss Apr10 0:00 /sbin/dhclient -q -lf /var/lib/dhclient/dhclient--eth0.lease -pf /var/run/dhclient-eth0.pid -H VM_0_5_centos eth0"; + // $output[] = "mysql 2219 0.2 9.3 1654448 362344 ? Sl Apr10 76:53 /usr/libexec/mysqld --basedir=/usr --datadir=/data/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock"; + // $output[] = "root 2934 0.0 0.2 494920 10360 ? S Apr10 0:02 WorkerMan: worker process proxy tcp://0.0.0.0:6981"; + $cmddb = ['mysql', 'mysqld']; + $cmdweb = ['nginx', 'php', 'WorkerMan', 'mosquitto', 'gitea', '/zgo']; + $cpu = array('db' => 0, 'web' => 0, 'oth' => 0); + $mem = array('db' => 0, 'web' => 0, 'oth' => 0); + + foreach ($output as $line) { + if (strpos($line, "COMMAND") !== false) + continue; + self::_base_nextspace($line); + self::_base_nextspace($line); + $cpup = (float)self::_base_nextspace($line); + $memp = (float)self::_base_nextspace($line); + self::_base_nextspace($line); //虚拟内存 + self::_base_nextspace($line); //物理内存 包括共享内存 + self::_base_nextspace($line); + self::_base_nextspace($line); + self::_base_nextspace($line); + self::_base_nextspace($line); + if (self::_base_arrin($line, $cmddb)) { + $cpu['db'] += $cpup; + $mem['db'] += $memp; + } else if (self::_base_arrin($line, $cmdweb)) { + $cpu['web'] += $cpup; + $mem['web'] += $memp; + } else { + $cpu['oth'] += $cpup; + $mem['oth'] += $memp; + } + } + + $output = array(); + exec("free -m", $output); + // $output = array(); + // $output[] = " total used free shared buff/cache available"; + // $output[] = "Mem: 3789 860 201 18 2727 2629"; + + preg_match('/Mem:\s+(\d+)/', $output[1], $totalmem); + $mem_free = $totalmem[1] * (100 - $cpu['db'] - $cpu['web'] - $cpu['oth']) * 1024 * 1024 / 100; + + $output = array(); + exec("netstat -an | awk '/^tcp/ {++S[\$NF]} END {for(a in S) print a, S[a]}'", $output); + + // $output = array(); + // $output[] = "LISTEN 13"; + // $output[] = "SYN_RECV 3"; + // $output[] = "ESTABLISHED 15"; + // $output[] = "TIME_WAIT 36"; + $net_tcp = 0; + foreach ($output as $line) { + $ls = explode(" ", $line); + if ($ls[0] == 'LISTEN') + continue; + $net_tcp += toint($ls[1]); + } + + $starttime = timems(); + $http = new \ciy\http(); + $http->request('https://www.baidu.com'); + $http->get_data(); + $net_ioms = timems() - $starttime; + + $dbrows = $db->getraw('show global status'); + $dbstat = array(); + for ($i = 0; $i < count($dbrows); $i++) { + $name = $dbrows[$i]['Variable_name']; + $val = $dbrows[$i]['Value']; + $dbstat[$name] = $val; + } + $db_keyhit = toint($dbstat['Handler_read_key']) / (toint($dbstat['Com_select']) + 1) * 100; + $db_dbhit = 100 - 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; + $updata['func_fail'] = $func_fail; + $updata['func_commit'] = $func_commit; + $updata['func_rollback'] = $func_rollback; + $updata['func_runms'] = $func_runms; + $updata['disk_sysfree'] = $disk_sysfree; + $updata['disk_datafree'] = $disk_datafree; + $updata['disk_ioms'] = $disk_ioms; + $updata['cpu_free'] = 100 - $cpu['db'] - $cpu['web'] - $cpu['oth']; + $updata['cpu_db'] = $cpu['db']; + $updata['cpu_web'] = $cpu['web']; + $updata['cpu_oth'] = $cpu['oth']; + $updata['mem_free'] = $mem_free; + $updata['mem_db'] = $mem['db']; + $updata['mem_web'] = $mem['web']; + $updata['mem_oth'] = $mem['oth']; + $updata['net_tcp'] = $net_tcp; + $updata['net_ioms'] = $net_ioms; + $updata['db_query'] = $dbstat['Questions']; + $updata['db_commit'] = $dbstat['Com_commit']; + $updata['db_rollback'] = $dbstat['Com_rollback']; + $updata['db_keyhit'] = $db_keyhit; + $updata['db_dbhit'] = $db_dbhit; + $updata['db_tmptable'] = $db_tmptable; + $updata['db_lock'] = $dbstat['Innodb_row_lock_current_waits']; + $updata['addtimes'] = tostamp(); + $csql = new \ciy\sql('zc_stats'); + $db->insert($csql, $updata); + if ($func_succ == 0 && $func_fail == 0 && $func_rollback == 0) + return ''; + return 'succ: ' . $func_succ . ($func_rollback > 0 ? ', rollback: ' . $func_rollback : ''); + } + static function _base_nextspace(&$line) { + $ind = strpos($line, " "); + if ($ind === false) { + $line = ''; + return $line; + } + $va = substr($line, 0, $ind); + $line = ltrim(substr($line, $ind)); + return $va; + } + static function _base_arrin($cmd, $arr) { + foreach ($arr as $v) { + if (strpos($cmd, $v) !== false) + return true; + } + return false; + } +} diff --git a/web/admin/autotask/task.go b/web/admin/autotask/task.go index 5d2a231..7ba69c4 100644 --- a/web/admin/autotask/task.go +++ b/web/admin/autotask/task.go @@ -1,7 +1,6 @@ package autotask import ( - "ciyon/web/admin" c "ciyon/zciyon" "fmt" "net/http" @@ -38,15 +37,15 @@ func Main() bool { } func Task_main(w http.ResponseWriter, r *http.Request) bool { post := c.NewCiyPost(w, r) - rsuser, err := admin.Verifyuser(r, c.CiyDB, post) - if err != nil { - w.Write([]byte("您未登录")) - return false - } - if admin.Nopower(c.CiyDB, c.Toint(rsuser["id"]), "p602r") { - w.Write([]byte("您未被授权操作")) - return false - } + // rsuser, err := admin.Verifyuser(r, c.CiyDB, post) + // if err != nil { + // w.Write([]byte("您未登录")) + // return false + // } + // if admin.Nopower(c.CiyDB, c.Toint(rsuser["id"]), "p602r") { + // w.Write([]byte("您未被授权操作")) + // return false + // } runid := post.Getint("runid") csql := c.NewCiySQL("zc_autotask") csql.Where("id", runid) diff --git a/web/admin/autotask/task.php b/web/admin/autotask/task.php index b116dbf..72bbab0 100644 --- a/web/admin/autotask/task.php +++ b/web/admin/autotask/task.php @@ -4,7 +4,7 @@ namespace web\admin\autotask; class task { //http://xx.local.ciy.cn/ajax/admin/autotask/task.run - //php D:/Dreams/ciy/ciyon/web/admin/autotask/index.php + //php D:/Dreams/ciy/c5_dao/web/admin/autotask/run.php public static function json_run() { self::main(); echo '全部执行完成'; @@ -12,10 +12,6 @@ class task { } public static function main() { global $db; - $files = glob(PATH_ROOT . 'web/admin/autotask/at_*.php'); - foreach ($files as $file) { - require $file; - } while (true) { $csql = new \ciy\sql('zc_autotask'); $csql->where('autotaskstatus<', 90)->where('nexttimes<=', tostamp()); @@ -27,13 +23,6 @@ class task { } public static function json_main() { global $db; - //获取本地文件夹内所有.php文件 - $files = glob(PATH_ROOT . 'web/admin/autotask/at_*.php'); - //遍历所有文件 - foreach ($files as $file) { - require $file; - clog('已加载: ' . $file); - } set_time_limit(0); if (isset($_SERVER['HTTP_HOST'])) ob_end_clean(); @@ -57,11 +46,12 @@ class task { $taskrow = $db->getone($csql); if (!is_array($taskrow)) return clog('任务ID不存在:' . $runid); + $taskrow['autotaskstatus'] = 20; $runtaskid = self::run($db, $taskrow); $csql = new \ciy\sql('zc_autotsk_run'); $csql->where('id', $runtaskid); $tskrunrow = $db->getone($csql); - if(!is_array($tskrunrow)) + if (!is_array($tskrunrow)) return clog('任务运行记录不存在:' . $runtaskid); $csql = new \ciy\sql('zc_autotsk_log'); $csql->where('runtaskid', $runtaskid); @@ -148,7 +138,7 @@ class task { $db->update($csql, array('runtimes' => $taskrow['runtimes'])); }; $taskrow['log'] = function ($msg) use ($db, &$taskrow) { - if(empty($msg)) + if (empty($msg)) return; $updata = array(); $updata['autotaskid'] = $taskrow['id']; @@ -161,14 +151,15 @@ class task { $msg = ''; try { clog($taskrow['name'] . ' 开始执行...'); - if (!function_exists($taskrow['runfunc'])) - $msg .= '缺少函数' . $taskrow['runfunc']; - else - $msg = call_user_func($taskrow['runfunc'], $taskrow); - + $funcs = explode('::', $taskrow['runfunc']); + if (!class_exists($funcs[0])) + throw new \Exception('无效类:' . $funcs[0]); + if (!method_exists($funcs[0], $funcs[1])) + throw new \Exception('无效函数:' . $funcs[0] . '::' . $funcs[1]); + $msg = call_user_func($taskrow['runfunc'], $taskrow); clog($taskrow['name'] . ' 执行完成。
' . $msg); } catch (\Exception $ex) { - $msg = 'try:' . print_r($ex, true); + $msg = $ex->getMessage(); } $runsec = tostamp() - $runlogstart; $updata = array(); diff --git a/web/admin/cemap/bill.html b/web/admin/cemap/bill.html index babf819..a44c98a 100644 --- a/web/admin/cemap/bill.html +++ b/web/admin/cemap/bill.html @@ -56,7 +56,7 @@
- +
diff --git a/web/admin/cemap/cemap.html b/web/admin/cemap/cemap.html index 1744227..90bc6ec 100644 --- a/web/admin/cemap/cemap.html +++ b/web/admin/cemap/cemap.html @@ -96,6 +96,8 @@ var Glob = {}; var ciy_vars = {}; var ce = new ciyearth(); + if(ciyfn.inmobile()) + $5('.cecontrolpanel').hide(); Glob.dom_controltip = $5('.cecontrolpanel .tip'); function fly_to(dom) { @@ -144,7 +146,6 @@ var mapset = ciyfn.tojson(json.cemap.mapjson); console.log('mapset', mapset); mapset.domid = 'ceContainer'; - mapset.personheight = 1.8; ce.init(mapset); if (!isarray(mapset.flys)) return; diff --git a/web/admin/datasse/expo.php b/web/admin/datasse/expo.php deleted file mode 100644 index 3760d9b..0000000 --- a/web/admin/datasse/expo.php +++ /dev/null @@ -1,150 +0,0 @@ -where('diqu like', '中国-'); - $csql->where('conferenceid=0'); - $cpavirows = $db->get($csql); - foreach ($cpavirows as $cpavirow) { - $csql = new \ciy\sql('c_fair_juzhan_expo'); - $csql->where('paviid', $cpavirow['rawid']); - $cnt = $db->get1($csql); - if ($cnt > 0) - $senddata('展馆中有展会,但展馆未收录: ' . $cpavirow['name'] . ',' . $cpavirow['rawid']); - } - } - if (true) { - $csql = new \ciy\sql('c_fair_juzhan_pavi'); - $csql->where('diqu like', '中国-'); - $csql->where('conferenceid>0'); - $cpavirows = $db->get($csql); - foreach ($cpavirows as $cpavirow) { - $csql = new \ciy\sql('c_fair_juzhan_expo'); - $csql->where('paviid', $cpavirow['rawid']); - $crows = $db->get($csql); - // $csql = new \ciy\sql('ep_exposition'); - // $csql->where('conferenceid', $cpavirow['conferenceid']); - // $csql->order('name'); - // $erows = $db->get($csql); - // if(count($crows) == count($erows)) - // continue; - //$senddata('C'.count($crows) .'=E'. count($erows).'|'.$cpavirow['name'] . ',' . $cpavirow['rawid']); - //检查C有,但E没有的展会有哪些 - foreach ($crows as $crow) { - if ($crow['expoid'] == 0) { - $csql = new \ciy\sql('ep_exposition'); - $csql->where('conferenceid', $cpavirow['conferenceid']); - $csql->where('name', $crow['name']); - $chkrow = $db->getone($csql); - if (is_array($chkrow)) { - if ($param != 'biaoji') { - $senddata('[biaoji] 展会存在,但juzhan未标记: ' . $cpavirow['conferenceid'] . ',' . $crow['name']); - continue; - } - - $updata = array(); - $updata['status'] = 10; - $updata['expoid'] = $chkrow['id']; - $csql = new \ciy\sql('c_fair_juzhan_expo'); - $csql->where('id', $crow['id']); - $execute = $db->data($updata)->set($csql, 'update'); - if ($execute === false) - $senddata('ERR ' . $cpavirow['conferenceid'] . ',' . $crow['name'] . $db->error); - else - $senddata('展会存在,已补juahznid: ' . $cpavirow['conferenceid'] . ',' . $crow['name']); - } else { - if ($param != 'newexpo') { - $senddata('[newexpo] 展会不存在需建立: ' . $cpavirow['conferenceid'] . ',' . $crow['name']); - continue; - } - $updata = array(); - $updata['conferenceid'] = $cpavirow['conferenceid']; - $updata['name'] = $crow['name']; - $updata['opentimes'] = $crow['opentimes']; - $updata['daycnt'] = \web\amb\expo::convday($crow); - $updata['content'] = '[MD]'; - $csql = new \ciy\sql('ep_exposition'); - $execute = $db->data($updata)->set($csql, 'insert'); - if ($execute !== false) { - $exponewid = $db->insert_id(); - $updata = array(); - $updata['status'] = 10; - $updata['expoid'] = $exponewid; - $csql = new \ciy\sql('c_fair_juzhan_expo'); - $csql->where('id', $crow['id']); - $execute = $db->data($updata)->set($csql, 'update'); - if ($execute === false) - $senddata('ERR ' . $cpavirow['conferenceid'] . ',' . $crow['name'] . $db->error); - else - $senddata('已新建展会: ' . $cpavirow['conferenceid'] . ',' . $crow['name']); - } else { - $senddata('ERR ' . $cpavirow['conferenceid'] . ',' . $crow['name'] . $db->error); - } - } - } - } - } - } - if (true) { - $csql = new \ciy\sql('ep_exposition'); - $csql->where('daycnt>30'); - $exporows = $db->get($csql); - $csql = new \ciy\sql('zc_ai_key'); - $csql->where('id', 1); - $aikeyrow = $db->getone($csql); - if(!is_array($aikeyrow)) - return errjson('AI Key不存在'); - foreach ($exporows as $exporow) { - if ($param != 'expoday') { - $senddata('[expoday] 展会持续: ' . $exporow['daycnt'] . '天,' . $exporow['name']); - continue; - } - $csql = new \ciy\sql('c_fair_juzhan_expo'); - $csql->where('expoid', $exporow['id']); - $crow = $db->getone($csql); - if (is_array($crow)) { - $n = \web\amb\expo::convday($crow); - if ($n != $exporow['daycnt']) - $senddata('展会天数调整到[' . $n . ']: ' . $exporow['daycnt'] . ',' . $exporow['name'] . $crow['lunchdate']); - } else { - $param = array(); - $param['id'] = 6; - $param['name'] = $exporow['name']; - $retai = \web\amb\ai::json_aidecision($param); - if (@$retai['code'] != 1){ - $senddata('AI识别失败: ' . $exporow['name'] . ',' . $retai['errmsg']); - continue; - } - - if (!isset($retai['ai']['day'])) { - $senddata('AI识别错误: ' . $exporow['name'] . ',day不存在'); - continue; - } - $updata = array(); - $updata['daycnt'] = $retai['ai']['day']; - $csql = new \ciy\sql('ep_exposition'); - $csql->where('id', $exporow['id']); - $execute = $db->data($updata)->set($csql, 'update'); - if ($execute === false) - $senddata('ERR ' . $retai['ai']['day'] . '==' . $exporow['daycnt'] . ',' . $exporow['name'] . $db->error); - else - $senddata('展会天数调整到[' . $retai['ai']['day'] . ']: ' . $exporow['daycnt'] . ',' . $exporow['name']); - } - } - } - $sendevent('ok'); - } -} diff --git a/web/admin/demo/bs/index.php b/web/admin/demo/bs/index.php index 3003514..18c4151 100644 --- a/web/admin/demo/bs/index.php +++ b/web/admin/demo/bs/index.php @@ -57,7 +57,7 @@ class index { public static function json_bank_r2() { $ret['videos'] = array(); for ($i = 1; $i < 50; $i++) { - $ret['videos'][] = array('id' => $i, 'name' => '监控视频' . $i, 'capture' => 'https://cf4.xinquanyou.cn/vcap/c' . rand(7816, 7846) . '.jpg'); + $ret['videos'][] = array('id' => $i, 'name' => '监控视频' . $i, 'capture' => 'https://cf4.nyyzsoft.cn/vcap/c' . rand(7816, 7846) . '.jpg'); } return succjson($ret); } @@ -118,7 +118,7 @@ class index { public static function json_farm_r3() { $ret['videos'] = array(); for ($i = 1; $i < 50; $i++) { - $ret['videos'][] = array('id' => $i, 'name' => '监控视频' . $i, 'capture' => 'https://cf4.xinquanyou.cn/vcap/c' . rand(7816, 7846) . '.jpg'); + $ret['videos'][] = array('id' => $i, 'name' => '监控视频' . $i, 'capture' => 'https://cf4.nyyzsoft.cn/vcap/c' . rand(7816, 7846) . '.jpg'); } return succjson($ret); } diff --git a/web/admin/demo/front/form_inputcyc.html b/web/admin/demo/front/form_inputcyc.html index 003fe29..41920f3 100644 --- a/web/admin/demo/front/form_inputcyc.html +++ b/web/admin/demo/front/form_inputcyc.html @@ -20,7 +20,7 @@
-
+
diff --git a/web/admin/demo/front/form_timepoint.html b/web/admin/demo/front/form_timepoint.html index 48e8c57..ba30d85 100644 --- a/web/admin/demo/front/form_timepoint.html +++ b/web/admin/demo/front/form_timepoint.html @@ -22,7 +22,7 @@
-
+
diff --git a/web/admin/develop/code_create.html b/web/admin/develop/code_create.html index 0e870a6..f62a9c7 100644 --- a/web/admin/develop/code_create.html +++ b/web/admin/develop/code_create.html @@ -51,75 +51,40 @@
-
- -
-
-
-
- -
-
-
-
- +
- +
- -
-
-
-
- -
-
-
-
- -
-
-
- - -
- +
- +
- -
+ +
- -
+ +
@@ -145,6 +110,12 @@
+
+ +
+ +
+
@@ -196,18 +167,11 @@ var cc = json.code_create || {}; cc.bcod = cc.bcod || {}; document.title = '☯' + cc.bcod.titname + ' 【低代码生成】'; - if (!cc.bcod.verifyfunc) - cc.bcod.verifyfunc = ciyfn.getstorage('_ccode_verifyfunc', 'verifyfast'); - if (!cc.bcod.tabdict) - cc.bcod.tabdict = ciyfn.getstorage('_ccode_tabdict', 'zc_cata'); if (!cc.bcod.htmllang) cc.bcod.htmllang = ciyfn.getstorage('_ccode_htmllang', 'js'); if (!cc.bcod.proglang) cc.bcod.proglang = ciyfn.getstorage('_ccode_proglang', 'php'); - if (!cc.bcod.saascode) - cc.bcod.saascode = ciyfn.getstorage('_ccode_saascode', ''); - $5('[name=_bcod_verifyfunc]').val(cc.bcod.verifyfunc); $5('[name=_bcod_titname]').val(cc.bcod.titname); $5('[name=_bcod_select_order]').val(cc.bcod.selectorder); $5('[name=_bcod_btntop_newline]').val(cc.bcod.newline); @@ -216,8 +180,6 @@ $5('[name=_bcod_liiddict]').val(cc.bcod.liiddict); $5('[name=_bcod_uptabcard]').val(cc.bcod.uptabcard); $5('[name=_bcod_viewtabcard]').val(cc.bcod.viewtabcard); - $5('[name=_bcod_tabdict]').val(cc.bcod.tabdict); - $5('[name=_bcod_saascode]').val(cc.bcod.saascode); // ciycmp({ // dom: '[com=_bcod_chk]', value: cc.bcod.bcod_chk, range: [ @@ -234,6 +196,7 @@ ciycmp({ dom: '[com=_bcod_htmllang]', value: cc.bcod.htmllang, range: [{ id: 'js', name: '原生JS' }, { id: 'vue3', name: 'Vue3' }, { id: 'react18', name: 'ReactV18' }] }); ciycmp({ dom: '[com=_bcod_proglang]', value: cc.bcod.proglang, range: [{ id: 'php', name: 'PHP' }, { id: 'golang', name: 'Golang' }, { id: 'python', name: 'Python' }] }); ciycmp({ dom: '[com=_bcod_pctemplate]', value: cc.bcod.pctemplate, range: [{ id: 'sigpage', name: '单页版' }, { id: 'threepage', name: '独立三页' }, { id: 'treepage', name: '多级树形' }, { id: 'editpage', name: '列表编辑' }] }); + ciycmp({ dom: '[com=_bcod_pcparam]', value: cc.bcod.pcparam, range: [{ id: 'listchk', name: '列表复选' }, { id: 'editsave', name: '编辑暂存' }, { id: 'topbtnnewline', name: '列表上按钮起新行' }] }); ciycmp({ dom: '[com=_bcod_mbtemplate]', value: cc.bcod.mbtemplate, range: [{ id: 'sigpage', name: '单页版' }, { id: 'threepage', name: '独立三页' }] }); //计算所有的set,给到subset @@ -323,6 +286,7 @@ colrange = []; colrange.push({ id: '', name: '下拉' }); colrange.push({ id: 'window', name: '窗选' }); + colrange.push({ id: 'text', name: '文本框' }); ciycmp({ dom: '[com=subset_dbedit_' + ss + ']', range: colrange, minwidth: '4em', onchange: function (e) { if (e.from == 'init') @@ -333,6 +297,7 @@ colrange = []; colrange.push({ id: '', name: '一次性' }); colrange.push({ id: 'rel', name: '增量' }); + colrange.push({ id: 'no', name: '不加载' }); ciycmp({ dom: '[com=subset_listload_' + ss + ']', range: colrange, minwidth: '4em', onchange: function (e) { if (e.from == 'init') @@ -403,7 +368,6 @@ if (!isview) $5('[name=bviw_' + ss + ']').attr('checked', 'true'); } - console.log(isview); } , fn_lihtml: function (data, i) { var html = ''; @@ -421,7 +385,7 @@ || data.COLUMN_NAME == 'lat') { chkvalue = ',bout'; } - else if (data.COLUMN_NAME.substring(0, 4) == 'saas' && data.COLUMN_NAME.substring(5) == 'id') { + else if (data.COLUMN_NAME == table.json.dbsaas.saasfield && data.COLUMN_NAME.substring(5) == 'id') { chkvalue = ''; } else if (data.COLUMN_NAME == 'ip' @@ -462,8 +426,8 @@ || data.COLUMN_NAME == 'ip') { spset.noup = 'no'; } - var saascode = ciyfn.getstorage('_ccode_saascode', '').split('='); - if (data.COLUMN_NAME == saascode[0]) { + + if (data.COLUMN_NAME == table.json.dbsaas.saasfield) { spset.noup = 'saas'; } if (data.COLUMN_NAME == 'lat') { @@ -479,13 +443,25 @@ spset.msk = '****##'; if (colcomment.cate == 'DOWN') - spset.ftype = 'jpg,png,pdf,zip,rar,docx,xlsx,pptx'; + spset.ftype = 'jpg,png,webp,pdf,zip,rar,docx,xlsx,pptx'; if (colcomment.cate == 'AV') spset.ftype = 'mp3,mp4,wav,ogg'; if (colcomment.cate == 'IMG' || colcomment.cate == 'IMG1') - spset.ftype = 'jpg,png'; - if (colcomment.cate == 'DOWN' || colcomment.cate == 'AV' || colcomment.cate == 'IMG') - spset.num = 3; + spset.ftype = 'jpg,png,webp'; + if (colcomment.cate == 'DOWN' || colcomment.cate == 'AV' || colcomment.cate == 'IMG') { + spset.num = toint(data.CHARACTER_MAXIMUM_LENGTH / 50); + } + if (colcomment.cate == 'MD' || colcomment.cate == 'DOWN' || colcomment.cate == 'AV' || colcomment.cate == 'IMG' || colcomment.cate == 'IMG1') { + spset.savepath = data.COLUMN_NAME; + if (spset.savepath.substring(spset.savepath.length - 4) == 'imgs') + spset.savepath = spset.savepath.substring(0, spset.savepath.length - 4); + if (spset.savepath.substring(spset.savepath.length - 5) == 'files') + spset.savepath = spset.savepath.substring(0, spset.savepath.length - 5); + if (spset.savepath.substring(spset.savepath.length - 3) == 'img') + spset.savepath = spset.savepath.substring(0, spset.savepath.length - 3); + if (spset.savepath.substring(spset.savepath.length - 4) == 'file') + spset.savepath = spset.savepath.substring(0, spset.savepath.length - 4); + } if (colcomment.dicttype == 'dictdb' && (colcomment.cate == 'DB' || colcomment.cate == 'CATU')) spset.listload = 'rel'; } @@ -545,8 +521,8 @@ html += '
图片宽
'; html += '
图片高
'; html += '
jpg压缩
'; - html += '
压缩范围
'; - //html += '
savepath
'; + html += '
压缩范围
'; + html += '
savepath
'; } if (colcomment.cate == 'BR' || colcomment.cate == 'MD') { html += '
列加载
'; @@ -669,11 +645,8 @@ if (typeof (postparam) == 'string') return ciyfn.alert(postparam); ciyfn.callfunc('save', postparam, function (json) { - ciyfn.setstorage('_ccode_verifyfunc', postparam._bcod_verifyfunc); - 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('保存成功'); }); @@ -748,6 +721,10 @@ postparam.schema = table.json.dbsaas.schem; postparam.table = table.json.table; postparam.subpath = table.json.dbsaas.subpath; + postparam.verifyfunc = table.json.dbsaas.verifyfunc; + postparam.codetable = table.json.dbsaas.codetable; + postparam.saasfield = table.json.dbsaas.saasfield; + postparam.saasusr = table.json.dbsaas.saasusr; if (!postparam._bcod_proglang) return '请选择后端语言'; for (var i = 0; i < postparam.total; i++) { diff --git a/web/admin/develop/code_create.php b/web/admin/develop/code_create.php index 9df0777..1946a23 100644 --- a/web/admin/develop/code_create.php +++ b/web/admin/develop/code_create.php @@ -52,14 +52,19 @@ class code_create { $ret['code_create']['bcod']['tabname'] = $tabname; $ret['code_create']['bcod']['titname'] = str_replace('表', '', $tabrow['TABLE_COMMENT']); $maintab = substr($tabname, strpos($tabname, '_') + 1); - $ret['code_create']['bcod']['uploadpat'] = $maintab; + $subend = substr($dbsaasrow['subpath'], strrpos($dbsaasrow['subpath'], '\\') + 1); + if (substr($maintab, 0, strlen($subend)) == $subend) + $maintab = substr($maintab, strlen($subend)); $ret['code_create']['bcod']['savepc'] = 'web\\' . $dbsaasrow['subpath'] . '\\' . $maintab; + $ret['code_create']['bcod']['pctemplate'] = 'sigpage'; + $ret['code_create']['bcod']['pcparam'] = ',listchk,'; + if ($chk_audit) { - $ret['code_create']['bcod']['newline'] = '导出'; + $ret['code_create']['bcod']['newline'] = '导出,帮助'; $ret['code_create']['bcod']['multibtn'] = '批量删除,审核通过,驳回'; $ret['code_create']['bcod']['btnlist_line'] = '审核'; } else { - $ret['code_create']['bcod']['newline'] = '添加,导入,导出'; + $ret['code_create']['bcod']['newline'] = '添加,导入,导出,帮助'; $ret['code_create']['bcod']['multibtn'] = '批量删除'; $ret['code_create']['bcod']['btnlist_line'] = '查看,修改'; } @@ -88,11 +93,6 @@ class code_create { $json['bcod']['uploadpat'] = $post->get('_bcod_uploadpat', '', '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'); - //$json['bcod']['bcod_chk'] = $post->get('bcod_chk'); $json['bcod']['selectorder'] = $post->get('_bcod_select_order', '', 'all'); $json['bcod']['newline'] = $post->get('_bcod_btntop_newline', '', 'all'); $json['bcod']['multibtn'] = $post->get('_bcod_btntop_multibtn', '', 'all'); @@ -101,6 +101,7 @@ class code_create { $json['bcod']['htmllang'] = $post->get('_bcod_htmllang', '', 'all'); $json['bcod']['proglang'] = $post->get('_bcod_proglang', '', 'all'); $json['bcod']['pctemplate'] = $post->get('_bcod_pctemplate', '', 'all'); + $json['bcod']['pcparam'] = $post->get('_bcod_pcparam', '', 'all'); $json['bcod']['mbtemplate'] = $post->get('_bcod_mbtemplate', '', 'all'); $total = $post->getint('total'); @@ -184,7 +185,6 @@ class code_create { $savepc = $post->get('_bcod_savepc', '', 'all'); if (empty($savepc)) return errjson('请填写PC保存路径'); - if (strpos($savepc, ':') === false) $savepc = PATH_ROOT . $savepc; $tpath = dirname($savepc); @@ -193,6 +193,12 @@ class code_create { $ret = self::save($post); if (is_string($ret)) return errjson($ret); + + $fname = substr($savepc, strrpos($savepc, '\\') + 1); + if (empty($fname)) + return errjson('必须指定文件名'); + if ($fname[0] == '_') + return errjson('文件名不能以_开头'); $codex = code_pc_html($post); $ret = file_put_contents($savepc . '.html', $codex); if ($ret === false) diff --git a/web/admin/develop/code_list.html b/web/admin/develop/code_list.html index aae49ab..8e2449d 100644 --- a/web/admin/develop/code_list.html +++ b/web/admin/develop/code_list.html @@ -57,9 +57,9 @@ if (key == '_btn') { var html = ''; if (Glob.tabls[data.TABLE_NAME]) - html += '生成'; + html += '生成'; else - html += '生成'; + html += '生成'; return html; } } diff --git a/web/admin/develop/code_pc_html.php b/web/admin/develop/code_pc_html.php index 359581e..57a0fd8 100644 --- a/web/admin/develop/code_pc_html.php +++ b/web/admin/develop/code_pc_html.php @@ -1,38 +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'); + $saasfield = $post->get('saasfield', '', 'all'); + $saasusr = $post->get('saasusr', '', '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 = str_replace(',',',', $post->get('_bcod_liiddict', '', 'all')); $uptabcard = str_replace(',',',', $post->get('_bcod_uptabcard', '', 'all')); $uptabcards = array(); if (!empty($uptabcard)) $uptabcards = explode(',', $uptabcard); - $viewtabcard = str_replace(',',',', $post->get('_bcod_viewtabcard', '', 'all')); - $viewtabcards = array(); - if (!empty($viewtabcard)) - $viewtabcards = explode(',', $viewtabcard); - $tabdict = $post->get('_bcod_tabdict', '', 'all'); $btntop_newline = $post->get('_bcod_btntop_newline', '', 'all'); $btnlist_line = $post->get('_bcod_btnlist_line', '', 'all'); $btntop_multibtn = $post->get('_bcod_btntop_multibtn', '', 'all'); $savepc = $post->get('_bcod_savepc', '', 'all'); + $pcparam = $post->get('_bcod_pcparam'); $hasview = strpos($btnlist_line, '查看') !== false; $flds = calfld($post); - $querycount = 0; $chk_audit = false; $chk_matter = false; $chk_getupdate = false; @@ -45,8 +32,6 @@ function code_pc_html($post) { $len = gb_strlen($fld['name']); if ($len > $maxnamelen) $maxnamelen = $len; - if ($fld['bqry']) - $querycount++; if ($fld['col'] == 'auditstatus') $chk_audit = true; //auditstatus/audituser/audittimes/auditmsg: 加审核按钮 if ($fld['col'] == 'matterstatus') @@ -89,6 +74,7 @@ function code_pc_html($post) { $hasaudit = false; $hasexcelin = false; $hasexcelout = false; + $hashelp = false; $topbtns = []; $strs = explode(',', $btntop_newline); //添加,导入,导出,其他,操作|成果|方法|-修改|删除 foreach ($strs as $str) { @@ -107,23 +93,22 @@ function code_pc_html($post) { $hasexcelout = true; $topbtns[] = '导出'; } else if ($str == '帮助') { - $hasexcelout = true; + $hashelp = true; $topbtns[] = '帮助'; } else $topbtns[] = '' . $str . ''; } else { - $subs = explode('|', $str); //操作|成果|方法|-修改|删除 + $subs = explode('|', $str); //操作|成果|方法|-|修改|删除 $btnhtml = "{$subs[0]}\n"; $btnhtml .= " \n"; $btnhtml .= "
    \n"; for ($j = 1; $j < count($subs); $j++) { - $ext = ''; $name = $subs[$j]; - if ($name[0] == '-') { - $name = substr($name, 1); - $ext = ' class="upline"'; + if ($name == '-') { + $btnhtml .= "
  • \n"; + } else { + $btnhtml .= "
  • {$name}
  • \n"; } - $btnhtml .= " {$name}\n"; } $btnhtml .= "
\n"; $btnhtml .= "
"; @@ -153,7 +138,7 @@ function code_pc_html($post) { data; - if (($querycount < 5 && count($topbtns) < 4) || count($topbtns) < 3) { + if (strpos($pcparam, ',topbtnnewline,') === false) { foreach ($topbtns as $topbtn) { $codex .= ' ' . $topbtn . "\n"; } @@ -165,14 +150,14 @@ data; data; - if (!(($querycount < 5 && count($topbtns) < 4) || count($topbtns) < 3)) { + if (strpos($pcparam, ',topbtnnewline,') !== false) { $codex .= "
\n"; foreach ($topbtns as $topbtn) { $codex .= ' ' . $topbtn . "\n"; } $codex .= "
\n"; } - $chk_multistatus = false; + $chk_multis = []; $multibtn = ''; if ($btntop_multibtn) { $btns = explode(',', $btntop_multibtn); @@ -191,12 +176,21 @@ data; } } $multibtn .= "\n {$btn}"; - } else if ($btn[0] == 'A') { - $btn = substr($btn, 1); - $multibtn .= "\n {$btn}"; } else { - $chk_multistatus = true; - $multibtn .= "\n {$btn}"; + $btnstrs = explode('.', $btn); + $str = $btnstrs[0]; + $extkey = ''; + if(count($btnstrs) > 1) + $extkey = $btnstrs[1]; + if($str[0] == '&'){ + $str = substr($str, 1); + if(empty($extkey)) + $extkey = $str; + $chk_multis[$extkey] = $str; + $multibtn .= "\n {$str}"; + }else{ + $multibtn .= "\n {$str}"; + } } } } @@ -216,6 +210,24 @@ data;
+data; + + if ($hashelp) + $codex .= <<
+ data; if ($hasexcelin) $codex .= <<"; + } else if ($cate == 'MCNY') { + $codex .= "\n{$pspec} "; } else if ($cate == 'WCNY') { $codex .= "\n{$pspec} "; } else if ($cate == 'MD' || $cate == 'DOWN' || $cate == 'AV' || $cate == 'IMG' || $cate == 'IMG1') { @@ -342,7 +356,9 @@ if($hasedit){ } else if ($cate == 'DB' || $cate == 'CATU') { if (isset($fld['set']['dbedit']) && $fld['set']['dbedit'] == 'window') //暂无实现窗选/组织 $codex .= "\n{$pspec} "; - else { + else if (isset($fld['set']['dbedit']) && $fld['set']['dbedit'] == 'text') { + $codex .= "\n{$pspec} "; + } else { if (!$fld['bimp']) $ext .= ' all="无"'; $codex .= "\n{$pspec} "; @@ -373,7 +389,7 @@ if($hasedit){ else $align = 'center'; } - $codex .= "\n{$pspec} {$strstart} {$strend}"; + $codex .= "\n{$pspec} {$strstart} {$strend}"; } else if ($cate == 'TON') { $codex .= "\n{$pspec} "; } else if ($cate == 'BET') { @@ -444,13 +460,19 @@ if($hasedit){ $codex .= "\n
"; } - if ($chk_multistatus) { - $codex .= "\n
"; + foreach($chk_multis as $key=>$name){ + $codex .= "\n
"; $codex .= "\n
"; $codex .= "\n
"; - $codex .= "\n "; + $codex .= "\n "; $codex .= "\n
"; - $codex .= "\n "; + $codex .= "\n "; + $codex .= "\n
"; + $codex .= "\n
"; + $codex .= "\n
"; + $codex .= "\n "; + $codex .= "\n
"; + $codex .= "\n "; $codex .= "\n
"; $codex .= "\n
"; $codex .= "\n
"; @@ -501,7 +523,11 @@ if($hasedit){ $editbtn = ''; $menubtn = ''; $bmenubtn = false; - $strs = explode(',', $btnlist_line); //添加,导入,导出,其他,操作|成果|方法|-修改|删除 + $subpathn = ''; + $ind = strpos($subpath, '\\'); + if($ind > 0) + $subpathn = str_replace('\\','/', substr($subpath, $ind+1)) . '/'; + $strs = explode(',', $btnlist_line); //添加,导入,导出,其他,操作|成果|方法|-修改|删除,&填报,$跳转选项卡 $subgomenus = array(); foreach ($strs as $str) { $ind = strpos($str, '|'); @@ -539,36 +565,84 @@ if($hasedit){ else { $btnstrs = explode('.', $str); $str = $btnstrs[0]; - $extcls = ''; $extkey = ''; - if(count($btnstrs) > 1){ - $subgomenus[] = $btnstrs; + if(count($btnstrs) > 1) $extkey = $btnstrs[1]; + if($str[0] == '&'){ + $str = substr($str, 1); + if(empty($extkey)) + $extkey = $str; + $menubtn .= "\n if (btn == '{$extkey}') {"; + $menubtn .= "\n edit_{$extkey}(id);"; + $menubtn .= "\n }"; + }else if($str[0] == '$'){ + $str = substr($str, 1); + if(empty($extkey)) + $extkey = $str; + $xid = 'xxxid'; + if(isset($btnstrs[2])) + $xid = $btnstrs[2]; + $menubtn .= "\n if (btn == '{$extkey}') {"; + $menubtn .= "\n ciyfn.sendsignal(window.top, 'manage_ifropen', {"; + $menubtn .= "\n url: '{$subpathn}{$extkey}.html?_{$xid}=' + id"; + $menubtn .= "\n , name: '{$str}' + table.data[id].name + ''"; + $menubtn .= "\n });"; + $menubtn .= "\n }"; + }else{ + if(empty($extkey)) + $extkey = $str; + $menubtn .= "\n if (btn == '{$extkey}') {"; + $menubtn .= "\n ciyfn.callfastfunc(dom, '是否{$str}?', '{$extkey}', { ids: id }, function (json) { table.updateline(json) });"; + $menubtn .= "\n }"; } - $menubtn .= "\n if (btn == '{$extkey}') {"; - $menubtn .= "\n ciyfn.callfastfunc(dom, '是否{$str}?', 'status', { ids: id }, function (json) { table.updateline(json) });"; - $menubtn .= "\n }"; + $extcls = ''; } - $editbtn .= "\n html += `{$str}`;"; + $editbtn .= "\n html += `{$str}`;"; } else { $bmenubtn = true; - $subs = explode('|', $str); //操作|成果|方法|-修改|删除 + $subs = explode('|', $str); //操作|成果|方法|-|修改|删除 $editbtn .= "\n html += `{$subs[0]}"; $editbtn .= "\n "; $editbtn .= "\n
    "; for ($j = 1; $j < count($subs); $j++) { - $ext = ''; - $name = $subs[$j]; - if ($name[0] == '-') { - $name = substr($name, 1); - $ext = ' class="upline"'; + $str = $subs[$j]; + if ($str == '-') { + $editbtn .= "\n
  • "; + } else { + $btnstrs = explode('.', $str); + $str = $btnstrs[0]; + $extkey = ''; + if(count($btnstrs) > 1) + $extkey = $btnstrs[1]; + if($str[0] == '&'){ + $str = substr($str, 1); + if(empty($extkey)) + $extkey = $str; + $menubtn .= "\n if (btn == '{$extkey}') {"; + $menubtn .= "\n {$extkey}(id);"; + $menubtn .= "\n }"; + }else if($str[0] == '$'){ + $str = substr($str, 1); + if(empty($extkey)) + $extkey = $str; + $xid = 'xxxid'; + if(isset($btnstrs[2])) + $xid = $btnstrs[2]; + $menubtn .= "\n if (btn == '{$extkey}') {"; + $menubtn .= "\n ciyfn.sendsignal(window.top, 'manage_ifropen', {"; + $menubtn .= "\n url: '{$subpathn}{$extkey}.html?_{$xid}=' + id"; + $menubtn .= "\n , name: '{$str}' + table.data[id].name + ''"; + $menubtn .= "\n });"; + $menubtn .= "\n }"; + }else{ + if(empty($extkey)) + $extkey = $str; + $menubtn .= "\n if (btn == '{$extkey}') {"; + $menubtn .= "\n ciyfn.callfastfunc(dom, '是否{$str}?', '{$extkey}', { ids: id }, function (json) { table.updateline(json) });"; + $menubtn .= "\n }"; + } + $editbtn .= "\n {$str}"; } - $btnstrs = explode('.', $name); - if(!isset($btnstrs[1])) - $btnstrs[1] = ''; - else - $subgomenus[] = $btnstrs; - $editbtn .= "\n {$btnstrs[0]}"; } $editbtn .= "\n
`;"; } @@ -586,6 +660,8 @@ if($hasedit){ $codex .= "\n dom: '.table'"; $codex .= "\n , url: 'list'"; $codex .= "\n , pagecount: 10"; + if (strpos($pcparam, ',listchk,') !== false) + $codex .= "\n , chkbox: true"; $codex .= "\n , fn_beforedata: function (json) {"; $codex .= "\n ciyfn.fillsearch({"; $codex .= "\n searchdom: '.search'"; @@ -611,42 +687,21 @@ if($hasedit){ $codex .= "\n });"; $codex .= "\n function menubtn(dom, btn) {"; $codex .= "\n var id = $5(dom).parent('tr').attr('data-id');{$menubtn}"; - $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) {"; - if ($chk_getupdate) { - $codex .= "\n ciyfn.callfunc('getdata', { id: id, act: act }, function (json) {"; - $codex .= "\n cb(json);"; - $codex .= "\n });"; - $codex .= "\n // cb({ data: id == 0 ? {} : table.data[id] });"; - }else{ - $codex .= "\n cb({ data: id == 0 ? {} : table.data[id] });"; + if ($hasedit || $hasview || $hasreview) { + $codex .= "\n function getdata(id, act, cb) {"; + if ($chk_getupdate) { + $codex .= "\n ciyfn.callfunc('getdata', { id: id, act: act }, function (json) {"; + $codex .= "\n cb(json);"; + $codex .= "\n });"; + $codex .= "\n // cb({ data: id == 0 ? {} : table.data[id] });"; + }else{ + $codex .= "\n cb({ data: id == 0 ? {} : table.data[id] });"; + } + $codex .= "\n }"; + $codex .= "\n"; } - $codex .= "\n }"; - $codex .= "\n"; if ($hasedit) { $codex .= "\n function edit(id) {"; $codex .= "\n getdata(id, 'edit', function (jsndat) {"; @@ -665,8 +720,6 @@ if($hasedit){ $codex .= "\n });"; } $codex .= "\n var dat = jsndat.data;"; - - $codex .= "\n var path = ciyfn.makeuploadpath('{$uploadpat}', ciyfn.getstorage(ciy_vars.tokenfield));"; foreach ($flds as $fld) { $cate = $fld['cate']; $col = $fld['col']; @@ -678,10 +731,12 @@ if($hasedit){ } else if ( $cate == 'FSIZE' || $cate == 'METRE' || $cate == 'DATE' || $cate == 'TIME' || $cate == 'BOOL' || $cate == 'WCNY' || $cate == 'UNIT' || $cate == 'CYC' || $cate == 'SEC' || $cate == 'TON' - || $cate == 'PCT' || $cate == 'CNY' || $cate == 'KG' || $cate == 'TC' || $cate == 'BR' + || $cate == 'PCT' || $cate == 'MCNY' || $cate == 'CNY' || $cate == 'KG' || $cate == 'TC' || $cate == 'BET' || $cate == 'LNY' || $cate == 'SNY' || $cate == 'WGT' || $cate == 'LGH' ) { $codex .= "\n ciycmp({ dom: $5('[com={$col}]', dom), value: dat.{$col} });"; + } else if ($cate == 'BR') { + $codex .= "\n ciycmp({ dom: $5('[com={$col}]', dom), value: dat.{$col}, autoheight: true });"; } else if ($cate == 'CATA' || $cate == 'CATU' || $cate == 'CATM' || $cate == 'CATS' || $cate == 'TINT' || $cate == 'DB') { list($dicttype, $dictname) = splitdict($fld['data']); if ($dicttype == 'dictciy') @@ -693,9 +748,12 @@ if($hasedit){ $range = 'table.once.' . $dictname; } else $range = "'{$dictname}'"; - $codex .= "\n ciycmp({ dom: $5('[com={$col}]', dom), value: dat.{$col}, range: {$range} });"; + if (isset($fld['set']['dbedit']) && $fld['set']['dbedit'] == 'text') + $codex .= "\n $5('[name={$col}]', dom).val(dat.{$col});"; + else + $codex .= "\n ciycmp({ dom: $5('[com={$col}]', dom), value: dat.{$col}, range: {$range} });"; } else if ($cate == 'MD' || $cate == 'DOWN' || $cate == 'AV' || $cate == 'IMG' || $cate == 'IMG1') { - $codex .= "\n ciycmp({ dom: $5('[com={$col}]', dom), value: dat.{$col}, path: path });"; + $codex .= "\n ciycmp({ dom: $5('[com={$col}]', dom), value: dat.{$col}, path: ciyfn.makeuploadpath('{$fld['set']['savepath']}', ciyfn.getstorage(ciy_vars.tokenfield)) });"; } else if ($cate == 'TBIN') { $codex .= "\n var values = [];"; $codex .= "\n var ibin = parseInt(dat.{$col});"; @@ -737,14 +795,19 @@ if($hasedit){ } } $codex .= "\n ciyfn.callfunc('update', opn.inputs, function (json) {"; - $codex .= "\n if (opn.btn == '保存(Ctrl+S)')"; - $codex .= "\n return;"; + if (strpos($pcparam, ',editsave,') !== false) { + $codex .= "\n if (opn.btn == '保存(Ctrl+S)')"; + $codex .= "\n return;"; + } $codex .= "\n table.updateline(json);"; $codex .= "\n opn.close();"; $codex .= "\n ciyfn.toast('提交成功');"; $codex .= "\n });"; $codex .= "\n },"; - $codex .= "\n btns: id == 0 ? [\"新建\", \"*关闭\"] : [\"#保存(Ctrl+S)\", \"提交\", \"*关闭\"],"; + if (strpos($pcparam, ',editsave,') !== false) + $codex .= "\n btns: id == 0 ? [\"新建\", \"*关闭\"] : [\"#保存(Ctrl+S)\", \"提交\", \"*关闭\"],"; + else + $codex .= "\n btns: id == 0 ? [\"新建\", \"*关闭\"] : [\"提交\", \"*关闭\"],"; $codex .= "\n });"; $codex .= "\n });"; $codex .= "\n }"; @@ -759,7 +822,7 @@ if($hasedit){ $cate = $fld['cate']; if (empty($fld['name'])) continue; - // if (empty($fld['name']) || $col == 'id' || $col == 'lat' || $col == $saascode) + // if (empty($fld['name']) || $col == 'id' || $col == 'lat' || $col == $saasfield) // continue; if (!$fld['bviw']) continue; @@ -770,7 +833,7 @@ if($hasedit){ $codex .= "\n html += '
';"; $codex .= "\n html += '
';"; $codex .= "\n html += ciyfn.tdshow(dat.{$col}, table.field.{$col}.ext, dat, table.once, table.json, true);"; - $codex .= "\n html += '
';"; + $codex .= "\n html += ' 
';"; $codex .= "\n"; } $codex .= "\n html += '
';"; @@ -795,9 +858,9 @@ if($hasedit){ continue; if (!$fld['bviw']) continue; - if ($col == 'auditstatus' || $col == 'audittimes' || $col == 'audituser' || $col == 'auditmsg') + if ($col == 'auditstatus' || $col == 'auditmsg') continue; - if ($saascode && $saascode[0] == $fld['col']) + if ($saasfield == $fld['col']) continue; $sgcol = (isset($fld['set']['colview']) ? $fld['set']['colview'] : '24'); $codex .= "\n html += '
';"; @@ -865,35 +928,49 @@ data; data; } - - - - if ($chk_multistatus) { + if ($hashelp) { $codex .= <<$name){ + $codex .= <<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'); + $verifyfunc = $post->get('verifyfunc', '', 'all'); + $codetable = $post->get('codetable', '', 'all'); + $saasfield = $post->get('saasfield', '', 'all'); + $saasusr = $post->get('saasusr', '', 'all'); $titname = $post->get('_bcod_titname', '', 'all'); - $saascode = $post->get('_bcod_saascode', '', 'all'); - if ($saascode) { - $saascode = explode('=', $saascode); - if (count($saascode) == 1) - $saascode[1] = ''; - } - $uploadpat = $post->get('_bcod_uploadpat', '', 'all'); - $liiddict = str_replace(',',',', $post->get('_bcod_liiddict', '', 'all')); - $tabdict = $post->get('_bcod_tabdict', '', 'all'); + $liiddict = str_replace(',', ',', $post->get('_bcod_liiddict', '', 'all')); $selectorder = $post->get('_bcod_select_order', '', 'all'); $btntop_newline = $post->get('_bcod_btntop_newline', '', 'all'); $btnlist_line = $post->get('_bcod_btnlist_line', '', 'all'); @@ -22,6 +15,7 @@ function code_pc_php($post) { $savepc = $post->get('_bcod_savepc', '', 'all'); $flds = calfld($post); + $hasview = strpos($btnlist_line, '查看') !== false; $hasadd = strpos($btntop_newline, '添加') !== false; //有添加能力 $hasexcelin = strpos($btntop_newline, '导入') !== false; $hasexcelout = strpos($btntop_newline, '导出') !== false; @@ -42,9 +36,10 @@ function code_pc_php($post) { if ($btntop_multibtn) { $btns = explode(',', $btntop_multibtn); foreach ($btns as $btn) { - if ($btn != '批量删除' && $btn != '审核通过' && $btn != '驳回' && $btn[0] != 'A') { + if ($btn != '批量删除' && $btn != '审核通过' && $btn != '驳回') + $chk_multistatus = true; + if ($btn[0] == 'A') $chk_multistatus = true; - } } } $nocolumn = array(); @@ -117,8 +112,8 @@ function code_pc_php($post) { $codex .= "\n if (!empty(\$val)) {"; list($dicttype, $dictname) = splitdict($fld['data']); if ($dicttype == 'dictcata') { - $codex .= "\n \$csqlt = new \ciy\sql('{$tabdict}');"; - $codex .= "\n \$csqlt->where('cbid in (select id from {$tabdict} where cbid=0 and codeid=\'{$col}\')');"; + $codex .= "\n \$csqlt = new \ciy\sql('{$codetable}');"; + $codex .= "\n \$csqlt->where('cbid in (select id from {$codetable} where cbid=0 and codeid=\'{$col}\')');"; $codex .= "\n \$csqlt->where('name like', \$val);"; $codex .= "\n \$trow = \$db->getone(\$csqlt);"; $codex .= "\n if (is_array(\$trow)) {"; @@ -147,7 +142,7 @@ function code_pc_php($post) { $codex .= "\n \$csql->where('{$col}&' . \$val . '=' . \$val);"; $codex .= "\n }"; } else if ( - $cate == 'METRE' || $cate == 'FSIZE' || $cate == 'WCNY' || $cate == 'SEC' || $cate == 'TON' || $cate == 'BET' + $cate == 'METRE' || $cate == 'FSIZE' || $cate == 'WCNY' || $cate == 'MCNY' || $cate == 'SEC' || $cate == 'TON' || $cate == 'BET' || $cate == 'PCT' || $cate == 'CNY' || $cate == 'NUM' || $cate == 'KG' || $cate == 'TC' || $cate == 'INT' || $cate == 'LNY' || $cate == 'SNY' || $cate == 'WGT' || $cate == 'LGH' ) { @@ -156,6 +151,8 @@ function code_pc_php($post) { $bet = 1024; else if ($cate == 'WCNY' || $cate == 'TON') $bet = 1000000; + else if ($cate == 'MCNY') + $bet = 10000; else if ($cate == 'SEC' || $cate == 'NUM' || $cate == 'INT') $bet = 1; else if ($cate == 'PCT' || $cate == 'CNY' || $cate == 'LNY' || $cate == 'SNY') @@ -189,9 +186,9 @@ function code_pc_php($post) { $codex .= "\n \$rsuser = {$verifyfunc}();"; $codex .= "\n \$post = new \ciy\post();"; $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 ($saasfield) { + if (!empty($saasusr)) + $codex .= "\n \$csql->where('{$saasfield}', \$rsuser['{$saasusr}']);"; } if (count($nocolumn) > 0) { $codex .= "\n \$csql->column('!" . implode(',', $nocolumn) . "', \$db->getraw('show full fields from {$tabname}'));"; @@ -210,8 +207,8 @@ 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]}')"; + if ($saasfield) { + $codex .= "\n if (\$fr == '{$saasfield}')"; $codex .= "\n \$field[\$fr]['c'] = ',' . \$field[\$fr]['c'];"; } $codex .= "\n }"; @@ -275,7 +272,7 @@ function code_pc_php($post) { else $codex .= "\n \$input[] = array('type' => 'daterange', 'form' => '{$col}', 'name' => '{$fld['name']}');"; } else if ( - $cate == 'METRE' || $cate == 'FSIZE' || $cate == 'WCNY' || $cate == 'SEC' || $cate == 'TON' + $cate == 'METRE' || $cate == 'FSIZE' || $cate == 'WCNY' || $cate == 'MCNY' || $cate == 'SEC' || $cate == 'TON' || $cate == 'PCT' || $cate == 'CNY' || $cate == 'NUM' || $cate == 'KG' || $cate == 'TC' || $cate == 'INT' || $cate == 'BET' || $cate == 'LNY' || $cate == 'SNY' || $cate == 'WGT' || $cate == 'LGH' ) { @@ -299,7 +296,7 @@ function code_pc_php($post) { foreach ($flds as $fld) { $cate = $fld['cate']; - if ($cate == 'DB' || $cate == 'CATS' || $cate == 'CATM') { + if ($cate == 'DB' || $cate == 'CATU' || $cate == 'CATS' || $cate == 'CATM') { if (empty($fld['set']['listload'])) { list($dicttype, $dictname) = splitdict($fld['data']); if ($dicttype == 'dictdb') { @@ -313,25 +310,33 @@ function code_pc_php($post) { } } $codex .= "\n }"; + $rels = array(); foreach ($flds as $fld) { if (!$fld['show']) continue; - if ($saascode && $saascode[0] == $fld['col']) + if ($saasfield == $fld['col']) continue; $cate = $fld['cate']; if ($cate == 'DB' || $cate == 'CATU' || $cate == 'CATS' || $cate == 'CATM') { if (isset($fld['set']['listload']) && $fld['set']['listload'] == 'rel') { list($dicttype, $dictname) = splitdict($fld['data']); if ($dicttype == 'dictdb') { - $codex .= "\n \$ret['{$dictname}'] = getrelation(\$db, \$rows, '{$dictname}', '{$fld['col']}');"; + if (isset($rels[$dictname])) + $rels[$dictname][] = $fld['col']; + else + $rels[$dictname] = array($fld['col']); } } } } + foreach ($rels as $dictname => $cols) { + $colsn = implode(',', $cols); + $codex .= "\n \$ret['{$dictname}'] = getrelation(\$db, \$rows, '{$dictname}', '{$colsn}');"; + } $codex .= "\n return succjson(\$ret);"; $codex .= "\n }"; - if ($chk_getupdate) { + if ($chk_getupdate && ($hasedit || $hasview || $hasreview)) { $codex .= "\n"; $codex .= "\n public static function json_getdata() {"; $codex .= "\n global \$db;"; @@ -342,9 +347,9 @@ 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){ - if(!empty($saascode[1])) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saasfield) { + if (!empty($saasusr)) + $codex .= "\n \$csql->where('{$saasfield}', \$rsuser['{$saasusr}']);"; } $codex .= "\n \$csql->where('id', \$id);"; $codex .= "\n \$row = \$db->getone(\$csql);"; @@ -353,8 +358,8 @@ function code_pc_php($post) { $codex .= "\n if (\$act == 'view' || \$act == 'review') {"; foreach ($flds as $fld) { $cate = $fld['cate']; - if ($cate == 'DB' || $cate == 'CATS' || $cate == 'CATM') { - if (isset($fld['set']['listload']) && $fld['set']['listload'] == 'rel') { + if ($cate == 'DB' || $cate == 'CATU' || $cate == 'CATS' || $cate == 'CATM') { + if (!$fld['show'] && empty($fld['set']['noup']) && isset($fld['set']['listload']) && $fld['set']['listload'] == 'rel') { list($dicttype, $dictname) = splitdict($fld['data']); if ($dicttype == 'dictdb') { $codex .= "\n \$csql = (new \ciy\sql('{$dictname}'))->column('id,name');"; @@ -372,8 +377,8 @@ function code_pc_php($post) { $codex .= "\n if (\$act == 'edit') {"; foreach ($flds as $fld) { $cate = $fld['cate']; - if ($cate == 'DB' || $cate == 'CATS' || $cate == 'CATM') { - if (isset($fld['set']['listload']) && $fld['set']['listload'] == 'rel') { + if ($cate == 'DB' || $cate == 'CATU' || $cate == 'CATS' || $cate == 'CATM') { + if (empty($fld['set']['noup']) && @$fld['set']['dbedit'] != 'text' && @$fld['set']['listload'] == 'rel') { list($dicttype, $dictname) = splitdict($fld['data']); if ($dicttype == 'dictdb') { $codex .= "\n \$csql = (new \ciy\sql('{$dictname}'))->column('id,name');"; @@ -398,7 +403,7 @@ function code_pc_php($post) { $codex .= "\n \$post = new \ciy\post();"; foreach ($flds as $fld) { $col = $fld['col']; - // if($col == $saascode || $col == 'addtimes' || $col == 'ip' || $col == 'uptimes') + // if($col == $saasfield || $col == 'addtimes' || $col == 'ip' || $col == 'uptimes') // continue; // if($col == 'auditstatus' || $col == 'audittimes' || $col == 'audituser' || $col == 'auditmsg') // continue; @@ -436,9 +441,9 @@ function code_pc_php($post) { $codex .= "\n \$datarow = null;"; $codex .= "\n if (\$id > 0) {"; $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode) { - if(!empty($saascode[1])) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saasfield) { + if (!empty($saasusr)) + $codex .= "\n \$csql->where('{$saasfield}', \$rsuser['{$saasusr}']);"; } $codex .= "\n \$csql->where('id', \$id);"; $codex .= "\n \$datarow = \$db->getone(\$csql);"; @@ -447,9 +452,9 @@ function code_pc_php($post) { $codex .= "\n }"; } else { $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode) { - if(!empty($saascode[1])) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saasfield) { + if (!empty($saasusr)) + $codex .= "\n \$csql->where('{$saasfield}', \$rsuser['{$saasusr}']);"; } $codex .= "\n \$csql->where('id', \$id);"; $codex .= "\n \$datarow = \$db->getone(\$csql);"; @@ -466,9 +471,9 @@ function code_pc_php($post) { } if (count($dups) > 0) { $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode){ - if(!empty($saascode[1])) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saasfield) { + if (!empty($saasusr)) + $codex .= "\n \$csql->where('{$saasfield}', \$rsuser['{$saasusr}']);"; } foreach ($dups as $dup) { $codex .= "\n \$csql->where('{$dup}', \${$dup});"; @@ -481,7 +486,7 @@ function code_pc_php($post) { $codex .= "\n \$updata = array();"; foreach ($flds as $fld) { $col = $fld['col']; - if($col == 'id' || $col == 'addtimes') + if ($col == 'id' || $col == 'addtimes') continue; // if($col == 'auditstatus' || $col == 'audittimes' || $col == 'audituser' || $col == 'auditmsg') // continue; @@ -503,7 +508,7 @@ function code_pc_php($post) { } else $codex .= "\n \$updata['{$col}'] = \${$col};"; } - $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; + $codex .= "\n \$csql = new \ciy\sql('{$tabname}'); //auto"; if ($hasadd) { $codex .= "\n if (\$id > 0) {"; $codex .= "\n \$csql->where('id', \$id);"; @@ -512,18 +517,16 @@ function code_pc_php($post) { $codex .= "\n } else {"; foreach ($flds as $fld) { $col = $fld['col']; - if ($col == 'id'){ - }else if ($fld['set']['noup'] == 'no') { - if($fld['type'] == 'int' || $fld['type'] == 'bigint') + 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]){ - if(!empty($saascode[1])) - $codex .= "\n \$updata['{$col}'] = \$rsuser['{$saascode[1]}'];"; - } - else if ($col == 'addtimes') + } else if ($saasfield) { + if (!empty($saasusr)) + $codex .= "\n \$updata['{$col}'] = \$rsuser['{$saasusr}'];"; + } else if ($col == 'addtimes') $codex .= "\n \$updata['{$col}'] = tostamp();"; else if ($col == 'auditstatus') $codex .= "\n \$updata['{$col}'] = 20;"; @@ -549,19 +552,27 @@ function code_pc_php($post) { $codex .= "\n return errjson(\$ex->getMessage());"; $codex .= "\n }"; $codex .= "\n \$ret['data'] = \$updata;"; + $rels = array(); foreach ($flds as $fld) { - if ($saascode && $saascode[0] == $fld['col']) + if ($saasfield == $fld['col']) continue; $cate = $fld['cate']; if ($cate == 'DB' || $cate == 'CATU' || $cate == 'CATS' || $cate == 'CATM') { if (isset($fld['set']['listload']) && $fld['set']['listload'] == 'rel') { list($dicttype, $dictname) = splitdict($fld['data']); if ($dicttype == 'dictdb') { - $codex .= "\n \$ret['{$dictname}'] = getrelation(\$db, [\$updata], '{$dictname}', '{$fld['col']}');"; + if (isset($rels[$dictname])) + $rels[$dictname][] = $fld['col']; + else + $rels[$dictname] = array($fld['col']); } } } } + foreach ($rels as $dictname => $cols) { + $colsn = implode(',', $cols); + $codex .= "\n \$ret['{$dictname}'] = getrelation(\$db, [\$updata], '{$dictname}', '{$colsn}');"; + } $codex .= "\n return succjson(\$ret);"; // $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; // $codex .= "\n \$csql->where('id', \$id);"; @@ -584,9 +595,9 @@ function code_pc_php($post) { $codex .= "\n if (empty(\$ids))"; $codex .= "\n return errjson('请选择至少一条');"; $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode){ - if(!empty($saascode[1])) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saasfield) { + if (!empty($saasusr)) + $codex .= "\n \$csql->where('{$saasfield}', \$rsuser['{$saasusr}']);"; } $codex .= "\n \$csql->where('id in', \$ids);"; $codex .= "\n \$rows = \$db->get(\$csql);"; @@ -639,9 +650,9 @@ function code_pc_php($post) { } } $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode){ - if(!empty($saascode[1])) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saasfield) { + if (!empty($saasusr)) + $codex .= "\n \$csql->where('{$saasfield}', \$rsuser['{$saasusr}']);"; } $codex .= "\n \$csql->where('id in', \$ids);"; $codex .= "\n \$rows = \$db->get(\$csql);"; @@ -649,8 +660,8 @@ function code_pc_php($post) { $codex .= "\n try {"; $codex .= "\n \$db->begin();"; $codex .= "\n foreach (\$rows as \$row) {"; - $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - $codex .= "\n \$csql->where('id', \$row['id']);"; + $codex .= "\n if (\$auditstatus == 100) {"; + $codex .= "\n }"; $codex .= "\n \$updata = array();"; foreach ($flds as $fld) { $col = $fld['col']; @@ -668,8 +679,6 @@ function code_pc_php($post) { $codex .= "\n if (\$db->update(\$csql, \$updata) === false)"; $codex .= "\n throw new \Exception('审核失败:' . \$db->error);"; $codex .= "\n \$ids[] = \$row['id'];"; - $codex .= "\n if (\$auditstatus == 100) {"; - $codex .= "\n }"; $codex .= "\n }"; $codex .= "\n \$db->commit();"; $codex .= "\n } catch (\Exception \$ex) {"; @@ -685,7 +694,7 @@ function code_pc_php($post) { if ($chk_multistatus) { $codex .= "\n"; - $codex .= "\n public static function json_multistatus() {"; + $codex .= "\n public static function json_multi_status() {"; $codex .= "\n global \$db;"; if ($verifyfunc) { $codex .= "\n \$rsuser = {$verifyfunc}();"; @@ -698,9 +707,9 @@ function code_pc_php($post) { $codex .= "\n if (empty(\$ids))"; $codex .= "\n return errjson('请选择至少一条');"; $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode){ - if(!empty($saascode[1])) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saasfield) { + if (!empty($saasusr)) + $codex .= "\n \$csql->where('{$saasfield}', \$rsuser['{$saasusr}']);"; } $codex .= "\n \$csql->where('id in', \$ids);"; $codex .= "\n \$rows = \$db->get(\$csql);"; @@ -708,8 +717,6 @@ function code_pc_php($post) { $codex .= "\n try {"; $codex .= "\n \$db->begin();"; $codex .= "\n foreach (\$rows as \$row) {"; - $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - $codex .= "\n \$csql->where('id', \$row['id']);"; $codex .= "\n \$updata = array();"; $codex .= "\n \$updata['status'] = \$status;"; $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; @@ -747,7 +754,7 @@ function code_pc_php($post) { foreach ($flds as $fld) { if (!$fld['bout']) continue; - if ($saascode && $saascode[0] == $fld['col']) + if ($saasfield == $fld['col']) continue; $col = $fld['col']; $name = $fld['name']; @@ -767,7 +774,7 @@ function code_pc_php($post) { foreach ($flds as $fld) { if (!$fld['bout']) continue; - if ($saascode && $saascode[0] == $fld['col']) + if ($saasfield == $fld['col']) continue; $col = $fld['col']; $cate = $fld['cate']; @@ -802,7 +809,7 @@ function code_pc_php($post) { foreach ($flds as $fld) { if ($fld['col'] != 'id' && !$fld['bout']) continue; - if ($saascode && $saascode[0] == $fld['col']) + if ($saasfield == $fld['col']) continue; $col = $fld['col']; $cate = $fld['cate']; @@ -830,6 +837,9 @@ function code_pc_php($post) { } else if ($cate == 'WCNY') { $codex .= "\n if (\$field == '{$col}')"; $codex .= "\n \$val = number_format(\$val / 1000000, 3) . '万元';"; + } else if ($cate == 'MCNY') { + $codex .= "\n if (\$field == '{$col}')"; + $codex .= "\n \$val = number_format(\$val / 10000, 4) . '元';"; } else if ($cate == 'BOOL') { $codex .= "\n if (\$field == '{$col}')"; $codex .= "\n \$val = (\$val == 1 ? \$code_{$col}[0]['name'] : @\$code_{$col}[1]['name']);"; @@ -1276,9 +1286,9 @@ function code_pc_php($post) { } if (count($dups) > 0) { $codex .= "\n \$csql = new \ciy\sql('{$tabname}');"; - if ($saascode){ - if(!empty($saascode[1])) - $codex .= "\n \$csql->where('{$saascode[0]}', \$rsuser['{$saascode[1]}']);"; + if ($saasfield) { + if (!empty($saasusr)) + $codex .= "\n \$csql->where('{$saasfield}', \$rsuser['{$saasusr}']);"; } foreach ($dups as $dup) { $codex .= "\n \$csql->where('{$dup}', \${$dup});"; @@ -1301,9 +1311,9 @@ function code_pc_php($post) { $codex .= "\n if (\$id == 0) {"; foreach ($flds as $fld) { $col = $fld['col']; - if ($saascode && $col == $saascode[0]){ - if(!empty($saascode[1])) - $codex .= "\n \$updata['{$col}'] = \$rsuser['{$saascode[1]}'];"; + if ($col == $saasfield) { + if (!empty($saasusr)) + $codex .= "\n \$updata['{$col}'] = \$rsuser['{$saasusr}'];"; } if ($col == 'addtimes') $codex .= "\n \$updata['{$col}'] = tostamp();"; diff --git a/web/admin/develop/code_saas.html b/web/admin/develop/code_saas.html index 164faaa..a8cc303 100644 --- a/web/admin/develop/code_saas.html +++ b/web/admin/develop/code_saas.html @@ -54,6 +54,35 @@
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ 多SaaS模式下,字段相同但用户SaaS标识不同 +
简单SaaS系统,用户SaaS标识一般与字段名称相同 +
例如: SaaS字段:orgid、用户标识:saas_a +
@@ -70,6 +99,7 @@ dom: '.table' , url: 'list' , pagecount: 10 + , chkbox: true , fn_beforedata: function (json) { ciyfn.fillsearch({ searchdom: '.search' @@ -80,8 +110,8 @@ , fn_tdcontent: function (key, datashow, field, data) { if (key == '_btn') { var html = ''; - html += `修改`; - html += `数据表`; + html += `修改`; + html += `数据表`; return html; } } @@ -121,6 +151,10 @@ $5('[name=name]', dom).val(dat.name); ciycmp({ dom: $5('[com=schem]', dom), value: dat.schem, range: jsndat.schema }); $5('[name=subpath]', dom).val(dat.subpath); + $5('[name=verifyfunc]', dom).val(dat.verifyfunc); + $5('[name=codetable]', dom).val(dat.codetable); + $5('[name=saasfield]', dom).val(dat.saasfield); + $5('[name=saasusr]', dom).val(dat.saasusr); } , cb: function (opn) { if (opn.btn == "关闭") diff --git a/web/admin/develop/code_saas.php b/web/admin/develop/code_saas.php index f44b497..f6d9263 100644 --- a/web/admin/develop/code_saas.php +++ b/web/admin/develop/code_saas.php @@ -22,7 +22,7 @@ class code_saas { $csql->limit($pageno, $pagecount); $mainrowcount = $post->getint('count'); $rows = $db->get($csql, $mainrowcount); - if($rows === false) + if ($rows === false) return errjson($db->error); $ret = array('where' => $where, 'pageno' => $pageno, 'pagecount' => $pagecount, 'count' => $mainrowcount, 'list' => $rows); if ($post->getbool('field')) { @@ -77,6 +77,14 @@ class code_saas { $name = $post->get('name'); $schem = $post->get('schem'); $subpath = $post->get('subpath'); + $verifyfunc = $post->get('verifyfunc'); + $codetable = $post->get('codetable'); + $saasfield = $post->get('saasfield'); + $saasusr = $post->get('saasusr'); + if (strpos($subpath, '\\') === false) + return errjson('相对路径需反斜杠\\'); + if (dirmake(PATH_WEB . $subpath) === false) + return errjson('创建目录失败'); $datarow = null; if ($id > 0) { $csql = new \ciy\sql('zc_dev_dbsaas'); @@ -85,12 +93,17 @@ class code_saas { if (!is_array($datarow)) return errjson('数据不存在'); } + try { $db->begin(); $updata = array(); $updata['name'] = $name; $updata['schem'] = $schem; $updata['subpath'] = $subpath; + $updata['verifyfunc'] = $verifyfunc; + $updata['codetable'] = $codetable; + $updata['saasfield'] = $saasfield; + $updata['saasusr'] = $saasusr; $csql = new \ciy\sql('zc_dev_dbsaas'); if ($id > 0) { $csql->where('id', $id); diff --git a/web/admin/login.php b/web/admin/login.php index f502936..dc0e6d3 100644 --- a/web/admin/login.php +++ b/web/admin/login.php @@ -7,6 +7,7 @@ class login { global $db; global $_token; $post = new \ciy\post(); + $model = $post->get('model'); $user = $post->get('user'); if (empty($user)) return errjson('请填写用户名'); @@ -66,7 +67,7 @@ class login { if ($db->update($csql, $updata) === false) return errjson('user数据库更新失败:' . $db->error); - savelog($db, $rsuser['id'], 'LOGIN', '登录成功'); + self::saveluser($db, 1, $rsuser['id'], $model); return self::getsync($rsuser, $oid, $sid); } public static function json_restorage() { @@ -129,8 +130,19 @@ class login { $csql = new \ciy\sql('zc_online'); $csql->where('id', $rsuser['_o']); $db->delete($csql); + self::saveluser($db, 2, $rsuser['id']); } - savelog($db, toint(@$rsuser['id']), 'LOGIN', '退出登录'); return succjson(); } + private static function saveluser($db, $isinout, $userid, $model = '') { + $updata = array(); + $updata['isinout'] = $isinout; + $updata['loguser'] = $userid; + $updata['addtimes'] = tostamp(); + $updata['ip'] = getip(); + $updata['model'] = $model; + $csql = new \ciy\sql('zc_luser'); + $db->insert($csql, $updata); + return false; + } } diff --git a/web/admin/rigger/admin.html b/web/admin/rigger/admin.html index 77a0093..c7bc631 100644 --- a/web/admin/rigger/admin.html +++ b/web/admin/rigger/admin.html @@ -87,7 +87,7 @@
- +
diff --git a/web/admin/rigger/cata.html b/web/admin/rigger/cata.html index ec4a99d..8e4cb57 100644 --- a/web/admin/rigger/cata.html +++ b/web/admin/rigger/cata.html @@ -129,7 +129,7 @@ return ''; } if (key == 'isuse') { - return ''; + return ''; } if (key == '_btn') { var html = ''; diff --git a/web/admin/rigger/cata.php b/web/admin/rigger/cata.php index 668c257..e671b93 100644 --- a/web/admin/rigger/cata.php +++ b/web/admin/rigger/cata.php @@ -46,7 +46,7 @@ class cata { $fshow = fieldadd($fshow, $field, -1, 'codeid', '代码|'); if (!empty($ext)) $fshow = fieldadd($fshow, $field, -1, 'extdata', $ext); - $fshow = fieldadd($fshow, $field, -1, 'isuse', '启用'); + $fshow = fieldadd($fshow, $field, -1, 'isuse', '行为'); $fshow = fieldadd($fshow, $field, -1, 'csort', '排序|'); $fshow = fieldadd($fshow, $field, -1, 'clas', '样式'); $fshow = fieldadd($fshow, $field, -1, '_btn', '操作'); @@ -226,9 +226,9 @@ class cata { $cnt = 0; try { $db->begin(); - if (count($codes) == 1 && strpos($code, ',') !== false && strpos($code, '.') !== false) { - //订单状态,TINT,1:创建订单.10:支付成功.20:评价 - $codes = explode('.', $code); + if (count($codes) == 1 && strpos($code, ',') !== false && strpos($code, ':') !== false) { + //订单状态,TINT,1:创建订单,10:支付成功,20:评价 + $codes = explode(',', $code); foreach ($codes as $c) { $cs = explode(':', $c); if (count($cs) < 2) diff --git a/web/admin/rigger/funcslow.go b/web/admin/rigger/funcslow.go index 5537605..fb62a5e 100644 --- a/web/admin/rigger/funcslow.go +++ b/web/admin/rigger/funcslow.go @@ -85,7 +85,7 @@ func Funcslow_del(w http.ResponseWriter, r *http.Request) bool { if userid == 0 { return false } - if admin.Nopower(c.CiyDB, userid, "p555d") { + if admin.Nopower(c.CiyDB, userid, "p556d") { return c.ErrJSON(w, "您未被授权操作") } ids := post.Get("ids") @@ -122,7 +122,7 @@ func Funcslow_exportxls(w http.ResponseWriter, r *http.Request) bool { if userid == 0 { return false } - if admin.Nopower(c.CiyDB, userid, "p555e") { + if admin.Nopower(c.CiyDB, userid, "p556e") { return c.ErrJSON(w, "您未被授权操作") } _, csql := funcslow_setwhere(post) diff --git a/web/admin/rigger/funcslow.php b/web/admin/rigger/funcslow.php index 958f444..1622fac 100644 --- a/web/admin/rigger/funcslow.php +++ b/web/admin/rigger/funcslow.php @@ -59,7 +59,7 @@ class funcslow { global $db; $rsuser = verifyfast(); - if (nopower($db, $rsuser['id'], 'p555d')) + if (nopower($db, $rsuser['id'], 'p556d')) return errjson('您未被授权操作'); $post = new \ciy\post(); @@ -94,7 +94,7 @@ class funcslow { global $db; $rsuser = verifyfast(); - if (nopower($db, $rsuser['id'], 'p555e')) + if (nopower($db, $rsuser['id'], 'p556e')) return errjson('您未被授权操作'); $post = new \ciy\post(); list($where, $csql) = self::setwhere($db, $post); diff --git a/web/admin/rigger/logfile.php b/web/admin/rigger/logfile.php index 5a92ea5..9d8a3af 100644 --- a/web/admin/rigger/logfile.php +++ b/web/admin/rigger/logfile.php @@ -20,7 +20,7 @@ class logfile { global $db; global $logpath; $rsuser = verifyfast(); - if (nopower($db, $rsuser['id'], 'p554d')) + if (nopower($db, $rsuser['id'], 'p555d')) return errjson('您未被授权操作'); $post = new \ciy\post(); $param = $post->get('param'); diff --git a/web/admin/rigger/luser.go b/web/admin/rigger/luser.go new file mode 100644 index 0000000..05ba66f --- /dev/null +++ b/web/admin/rigger/luser.go @@ -0,0 +1,110 @@ +package rigger + +import ( + "net/http" + + "ciyon/web/admin" + c "ciyon/zciyon" +) + +func luser_setwhere(post *c.CiyPost) (map[string]any, *c.CiySQL) { + query := post.Getobj("query") + csql := c.NewCiySQL("zc_luser") + liid := c.Getint(query, "liid") + if liid > 0 { + csql.Where("isinout", liid) + } + csql.Where("loguser", c.Getstr(query, "loguser")) + csql.Where_daterange("addtimes", c.Getstr(query, "addtimes")) + csql.Where("model like", c.Getstr(query, "model")) + order := c.Getstr(query, "order", "id desc") + csql.Order(order) + query["order"] = order + return query, csql +} +func Luser_init(w http.ResponseWriter, r *http.Request) bool { + post := c.NewCiyPost(w, r) + _, userid := admin.Verifyfast(r, c.CiyDB, post) + if userid == 0 { + return false + } + where, csql := luser_setwhere(post) + pageno := post.Getint("pageno", 1) + pagecount := post.Getint("pagecount", 10) + csql.Limit(pageno, pagecount) + rows, mainrowcount, err := c.CiyDB.Get(csql, post.Getint("count")) + if err != nil { + return c.ErrJSON(w, "读取错误", err) + } + ret := map[string]any{} + ret["where"] = where + ret["pageno"] = pageno + ret["pagecount"] = pagecount + ret["count"] = mainrowcount + ret["list"] = rows + if post.Getbool("field") { + field, fshow := c.CiyDB.GetField(csql) + ret["fshow"] = fshow + ret["field"] = field + } + if post.Getbool("once") { + once := map[string]any{} + input := make([]map[string]any, 0) + input = append(input, map[string]any{ + "form": "loguser", + "type": "select", + "name": "操作人", + "prop": ` style="min-width:6em;"`, + "select": "adminuser", + "all": "全部", + }) + input = append(input, map[string]any{ + "form": "addtimes", + "type": "daterange", + "name": "发生日期", + }) + input = append(input, map[string]any{ + "form": "model", + "type": "input", + "name": "设备指纹", + }) + once["input"] = input + ret["once"] = once + } + return c.SuccJSON(w, r, ret) +} +func Luser_del(w http.ResponseWriter, r *http.Request) bool { + post := c.NewCiyPost(w, r) + _, userid := admin.Verifyfast(r, c.CiyDB, post) + if userid == 0 { + return false + } + if admin.Nopower(c.CiyDB, userid, "p554d") { + return c.ErrJSON(w, "您未被授权操作") + } + ids := post.Get("ids") + if ids == "" { + return c.ErrJSON(w, "请选择至少一条") + } + csql := c.NewCiySQL("zc_luser") + csql.Where("id in", ids) + rows, _, err := c.CiyDB.Get(csql) + if err != nil { + return c.ErrJSON(w, "读取数据错误", err) + } + vids := make([]int, 0) + err = c.CiyDB.Tran(func() error { + for _, row := range rows { + delid := c.Toint(row["id"]) + c.Delme(c.CiyDB, delid, "zc_luser") + vids = append(vids, delid) + } + return nil + }) + if err != nil { + return c.ErrJSON(w, "事务"+err.Error()) + } + ret := map[string]any{} + ret["ids"] = vids + return c.SuccJSON(w, r, ret) +} diff --git a/web/admin/rigger/luser.html b/web/admin/rigger/luser.html new file mode 100644 index 0000000..a12ae28 --- /dev/null +++ b/web/admin/rigger/luser.html @@ -0,0 +1,71 @@ + + + + + + + + + + + + +
+ +
+
Loading...
+
+
+
+ 全选 + 反选 + | + 批量删除 +
+
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/web/admin/rigger/luser.php b/web/admin/rigger/luser.php new file mode 100644 index 0000000..d742fda --- /dev/null +++ b/web/admin/rigger/luser.php @@ -0,0 +1,95 @@ +get('query'); + $csql = new \ciy\sql('zc_luser'); + $liid = objint($query, 'liid'); + if ($liid > 0) + $csql->where('isinout', $liid); + $csql->where('loguser', objstr($query, 'loguser')); + $csql->where('model like', objstr($query, 'model')); + $csql->wheredaterange('addtimes', objstr($query, 'addtimes')); + $order = objstr($query, 'order', 'id desc'); + $csql->order($order); + $query['order'] = $order; + return [$query, $csql]; + } + public static function json_init() { + 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); + $ret = array('where' => $where, 'pageno' => $pageno, 'pagecount' => $pagecount, 'count' => $mainrowcount, 'list' => $rows); + if ($post->getbool('field')) { + $field = array(); + $fshow = $db->getfield($field, 'zc_luser'); + $ret['field'] = $field; + $ret['fshow'] = $fshow; + } + + if ($post->getbool('once')) { + $ret['once'] = array(); + $input = array(); + $input[] = array( + 'type' => 'select', + 'form' => 'loguser', + 'name' => '操作人', + 'prop' => ' style="min-width:6em;"', + 'select' => 'adminuser', + 'all' => '全部' + ); + $input[] = array( + 'type' => 'daterange', + 'form' => 'addtimes', + 'name' => '发生日期' + ); + $input[] = array( + 'type' => 'input', + 'form' => 'model', + 'name' => '设备指纹', + ); + $ret['once']['input'] = $input; + } + return succjson($ret); + } + public static function json_del() { + global $db; + $rsuser = verifyfast(); + + if (nopower($db, $rsuser['id'], 'p554d')) + return errjson('您未被授权操作'); + + $post = new \ciy\post(); + $ids = $post->get('ids'); + if (empty($ids)) + return errjson('请选择至少一条'); + $csql = new \ciy\sql('zc_luser'); + + $csql->where('id in', $ids); + $rows = $db->get($csql); + $vids = array(); + try { + $db->begin(); + foreach ($rows as $row) { + $delid = $row['id']; + delme($db, $delid, 'zc_luser'); + $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/ambap/ai.php b/web/ambap/ai.php new file mode 100644 index 0000000..d9c5ea2 --- /dev/null +++ b/web/ambap/ai.php @@ -0,0 +1,288 @@ +getint('aikey'); + $aikeyrow = null; + if ($aikey > 0) { + $csql = new \ciy\sql('zc_ai_key'); + $csql->where('id', $aikey); + $aikeyrow = $db->getone($csql); + if (!is_array($aikeyrow)) + return errjson('AI Key不存在'); + } + if (!is_array($aikeyrow)) { + $csql = new \ciy\sql('zc_ai_key'); + $csql->where('id', 1); + $aikeyrow = $db->getone($csql); + if (!is_array($aikeyrow)) + return errjson('AI Key未设置'); + } + $system = $post->get('system'); + $chat = $post->get('chat'); + if (empty($chat)) + return errjson('请输入聊天内容'); + $openai = new \ciy\openai($aikeyrow); + $openai->debug($debug); + $openai->setparam($post->get('aiprange')); + $openai->newsystem($system); + $retai = $openai->completion($chat, strpos($chat . $system, 'JSON') !== false); + if (is_string($retai)) + return errjson($retai); + $ret['ai'] = $retai; + return succjson($ret); + } + public static function json_aidecision($param = null, $debug = false) { + global $db; + set_time_limit(0); + $timespan = time(); + $post = new \ciy\post($param); + $id = $post->getint('id'); + $csql = new \ciy\sql('zc_ai_decision'); + $csql->where('id', $id); + $decisionrow = $db->getone($csql); + if (!is_array($decisionrow)) + return errjson('AI决策单元不存在'); + $csql = new \ciy\sql('zc_ai_key'); + $csql->where('id', $decisionrow['aikey']); + $aikeyrow = $db->getone($csql); + if (!is_array($aikeyrow)) + return errjson('AI Key未设置'); + + $funcdatarows = null; + if (!empty($decisionrow['funcids'])) { + $csql = new \ciy\sql('zc_ai_funcdata'); + $csql->where('id in', trim($decisionrow['funcids'], ',')); + $funcdatarows = $db->get($csql); + } + if (strpos($decisionrow['sysprompt'] . $decisionrow['roleprompt'], '{{know.') === false) { + $csql = new \ciy\sql('zc_ai_knowcata'); + $knowcatarows = $db->get($csql); + if (count($knowcatarows) > 0) { + if ($funcdatarows == null) + $funcdatarows = array(); + $descs = ''; + foreach ($knowcatarows as $knowcatarow) { + $descs .= "\n{知识库ID:" . $knowcatarow['id'] . ", " . $knowcatarow['name'] . ',' . $knowcatarow['aiguide'] . '}'; + } + $funcdatarows[] = array( + 'id' => 0, + 'name' => 'know', + 'funcname' => 'know', + 'descs' => '如果需要补充学习专业知识库信息,调用该函数。知识库列表有,' . $descs, + 'paramjson' => '*ID=准确的知识库ID', + 'funcparam' => '' + ); + } + } + $csql = new \ciy\sql('zc_ai_key'); + $csql->where('id', $decisionrow['aikey']); + $aikeyrow = $db->getone($csql); + if (!is_array($aikeyrow)) + return errjson('AI Key不存在'); + $system = preg_replace_callback('/\{\{([^}]+)\}\}/', function ($matches) use ($db, $post) { + $key = $matches[1]; + if (substr($key, 0, 5) == 'know.') { + $knowcataname = substr($key, 5); + $csql = new \ciy\sql('zc_ai_knowcata'); + $csql->where('name', $knowcataname); + $knowcatarow = $db->getone($csql); + if (!is_array($knowcatarow)) + return ''; + $csql = new \ciy\sql('zc_ai_knowledge'); + $csql->where('cataid', $knowcatarow['id']); + $knowrows = $db->get($csql); + $knowstr = ''; + foreach ($knowrows as $knowrow) { + $knowstr .= $knowrow['content'] . "\n"; + } + return $knowstr; + } + $val = $post->get($key); + if (is_array($val)) + $val = json_encode($val, JSON_UNESCAPED_UNICODE); + return $val . ''; + }, $decisionrow['sysprompt']); + $roleprompt = preg_replace_callback('/\{\{([^}]+)\}\}/', function ($matches) use ($db, $post) { + $key = $matches[1]; + if (substr($key, 0, 5) == 'know.') { + $knowcataname = substr($key, 5); + $csql = new \ciy\sql('zc_ai_knowcata'); + $csql->where('name', $knowcataname); + $knowcatarow = $db->getone($csql); + if (!is_array($knowcatarow)) + return ''; + $csql = new \ciy\sql('zc_ai_knowledge'); + $csql->where('cataid', $knowcatarow['id']); + $knowrows = $db->get($csql); + $knowstr = ''; + foreach ($knowrows as $knowrow) { + $knowstr .= $knowrow['content'] . "\n"; + } + return $knowstr; + } + $val = $post->get($key); + if (is_array($val)) + $val = json_encode($val, JSON_UNESCAPED_UNICODE); + return $val . ''; + }, $decisionrow['roleprompt']); + + $openai = new \ciy\openai($aikeyrow); + $openai->debug($debug); + $openai->setparam($decisionrow['aiprange']); + $openai->newsystem($system); + $retai = $openai->completion($roleprompt, strpos($roleprompt . $system, 'JSON') !== false, $funcdatarows, function ($funcarray) use ($funcdatarows) { + $funcdatarow = ccode($funcdatarows, substr($funcarray['name'], 1), 'id', null); + if (!is_array($funcdatarow)) + return 'ERR未定义函数:' . $funcarray['name']; + $funcname = $funcdatarow['funcname']; + if ($funcname[0] != '\\') + $funcname = '\\web\\admin\\aifunc\\' . $funcname; + if (!class_exists($funcname)) + return 'ERR无效类:' . $funcname; + if (!method_exists($funcname, 'main')) + return 'ERR无效函数:' . $funcname . '::main'; + $funcname .= '::main'; + $arguments = json_decode($funcarray['arguments'], true); + $funcparams = getstrparam($funcdatarow['funcparam'], "\n"); + foreach ($funcparams as $key => $val) { + $arguments[$key] = $val; + } + return call_user_func($funcname, $arguments); + }); + if (is_string($retai)) { + $ret = array(); + $ret['sec'] = time() - $timespan + 1; //用时 + $ret['ci'] = 0; //置信度 + $ret['version'] = $decisionrow['version']; + if ($post->get('_more') == 'ok') { + $ret['messages'] = $openai->messages; //交互过程 + $ret['roleprompt'] = $roleprompt; //提示词 + $ret['system'] = $system; //角色描述 + } + return errjson('AI执行失败: ' . $retai, 10, $ret); + } + + $decci = 0; + $aichat = json_encode($openai->messages, JSON_UNESCAPED_UNICODE); + $resulttxt = json_encode($retai, JSON_UNESCAPED_UNICODE); + if ($decisionrow['aicalkey'] > 0 && !empty($decisionrow['calprompt'])) { + $post->post['result.ai'] = $aichat; + $post->post['result.data'] = $resulttxt; + $csql = new \ciy\sql('zc_ai_key'); + $csql->where('id', $decisionrow['aicalkey']); + $aikeyrow = $db->getone($csql); + if (!is_array($aikeyrow)) + return errjson('置信度 AI Key不存在'); + $calprompt = preg_replace_callback('/\{\{([^}]+)\}\}/', function ($matches) use ($db, $post) { + $key = $matches[1]; + if (substr($key, 0, 5) == 'know.') { + $knowcataname = substr($key, 5); + $csql = new \ciy\sql('zc_ai_knowcata'); + $csql->where('name', $knowcataname); + $knowcatarow = $db->getone($csql); + if (!is_array($knowcatarow)) + return ''; + $csql = new \ciy\sql('zc_ai_knowledge'); + $csql->where('cataid', $knowcatarow['id']); + $knowrows = $db->get($csql); + $knowstr = ''; + foreach ($knowrows as $knowrow) { + $knowstr .= $knowrow['content'] . "\n"; + } + return $knowstr; + } + $val = $post->get($key); + if (is_array($val)) + $val = json_encode($val, JSON_UNESCAPED_UNICODE); + return $val . ''; + }, $decisionrow['calprompt']); + $openai = new \ciy\openai($aikeyrow); + $openai->debug($debug); + $openai->setparam($decisionrow['aicalprange']); + $openai->newsystem(); + $retcalai = $openai->completion($calprompt, true); + $decci = (int)$retcalai['confidence']; + } else if ($decisionrow['aicalkey'] == 0 && !empty($decisionrow['aicalfunc'])) { + $funcname = $decisionrow['aicalfunc']; + if ($funcname[0] != '\\') + $funcname = '\\web\\admin\\aifunc\\' . $funcname; + if (!class_exists($funcname)) + return errjson('置信度 无效类:' . $funcname); + if (!method_exists($funcname, 'main')) + return errjson('置信度 无效函数:' . $funcname . '::main'); + $funcname .= '::main'; + $decci = call_user_func($funcname, $retai, $decisionrow['calprompt']); + } + $ret['sec'] = time() - $timespan + 1; //用时 + $ret['ci'] = $decci; //置信度 + $ret['ai'] = $retai; //结果 + $ret['version'] = $decisionrow['version']; + if ($post->get('_more') == 'ok') { + $ret['messages'] = $openai->messages; //交互过程 + $ret['roleprompt'] = $roleprompt; //提示词 + $ret['system'] = $system; //角色描述 + } + return succjson($ret); + } + public static function multiparam($input, $sep) { + $len = strlen($input); + $ips = array(); + $i = 0; + $inMultiline = false; + $currentParam = ''; + $currentValue = ''; + + while ($i < $len) { + if (!$inMultiline) { + $paramStart = $i; + while ($i < $len && $input[$i] !== $sep) { + if ($input[$i] === "\n") + return '参数格式不合法'; + $i++; + } + if ($i == $len) + return '参数格式不合法,应用' . $sep . '号分隔'; + $currentParam = trim(substr($input, $paramStart, $i - $paramStart)); + if (empty($currentParam)) + return '参数没有参数名'; + $i++; + if ($i < $len && $input[$i] === '`') { + $inMultiline = true; + $i++; + $currentValue = ''; + } else { + $valueStart = $i; + while ($i < $len && $input[$i] !== "\n") + $i++; + $currentValue = trim(substr($input, $valueStart, $i - $valueStart)); + $ips[] = $currentParam . $sep . $currentValue; + $i++; + } + } else { + $valueStart = $i; + while ($i < $len && $input[$i] !== '`') + $i++; + $currentValue .= trim(substr($input, $valueStart, $i - $valueStart)); + if ($i < $len && $input[$i] === '`') { + $ips[] = $currentParam . $sep . $currentValue; + $inMultiline = false; + $i++; + if ($i < $len && $input[$i] === "\n") { + $i++; + } + } else { + $ips[] = $currentParam . $sep . $currentValue; + break; + } + } + } + if (count($ips) == 0) + return '参数都不符合条件'; + return $ips; + } +} diff --git a/web/ambap/login.php b/web/ambap/login.php index e7e9896..7575d7b 100644 --- a/web/ambap/login.php +++ b/web/ambap/login.php @@ -103,6 +103,7 @@ class login { $rsuser['password'] = $pass; $rsuser['myinvmoney'] = 0; $rsuser['mycashmoney'] = 0; + $rsuser['mybondmoney'] = 0; $rsuser['mypnt'] = 0; $rsuser['trytime'] = 0; $rsuser['logintimes'] = tostamp(); @@ -176,6 +177,7 @@ class login { $rsuser['userlevel'] = 10; $rsuser['myinvmoney'] = 0; $rsuser['mycashmoney'] = 0; + $rsuser['mybondmoney'] = 0; $rsuser['mypnt'] = $newpnt; $rsuser['logintimes'] = time(); $rsuser['wxminakey'] = $sskey; @@ -356,6 +358,7 @@ class login { $ret['me']['userlevel'] = $userrow['userlevel']; $ret['me']['myinvmoney'] = $userrow['myinvmoney']; $ret['me']['mycashmoney'] = $userrow['mycashmoney']; + $ret['me']['mybondmoney'] = $userrow['mybondmoney']; $ret['me']['mypnt'] = $userrow['mypnt']; $ret['me']['certs'] = $userrow['certs']; $ret['me']['needpass'] = empty($userrow['password']); diff --git a/web/ambap/me.php b/web/ambap/me.php index c60a695..c7aeb10 100644 --- a/web/ambap/me.php +++ b/web/ambap/me.php @@ -523,6 +523,10 @@ class me { $cash = $post->getint('cash') * 100; if ($rsuser['mycashmoney'] < $cash) return errjson('余额不足'); + if ($rsuser['mybondmoney'] > 0) { + if ($rsuser['mycashmoney'] - $rsuser['mybondmoney'] < $cash) + return errjson('余额不足,保证金不能直接提现,请先退保证金'); + } $cashtype = 1; $csql = new \ciy\sql('ap_usr_ext'); $csql->where('id', $rsuser['id']); @@ -767,7 +771,7 @@ class me { $rsuser = verifyfast(); $csql = new \ciy\sql('ap_user'); $csql->where('id', $rsuser['id']); - $csql->column('myinvmoney,mycashmoney,mypnt'); + $csql->column('myinvmoney,mycashmoney,mybondmoney,mypnt'); $ret['user'] = $db->getone($csql); return succjson($ret); } @@ -776,7 +780,7 @@ class me { $rsuser = verifyfast(); $csql = new \ciy\sql('ap_user'); $csql->where('id', $rsuser['id']); - $csql->column('myinvmoney,mycashmoney,mypnt'); + $csql->column('myinvmoney,mycashmoney,mybondmoney,mypnt'); $ret['user'] = $db->getone($csql); $csql = new \ciy\sql('ap_cash_out'); $csql->where('vuser', $rsuser['id']); @@ -857,9 +861,9 @@ class me { $csql->where('vuser', $rsuser['id']); $liid = objint($query, 'liid'); if ($liid == 1) - $csql->where('cashietype<100'); + $csql->where('iemoney>0'); if ($liid == 2) - $csql->where('cashietype>=100'); + $csql->where('iemoney<0'); $csql->order(objstr($query, 'order', 'id desc')); $pageno = $post->getint('pageno', 1); $pagecount = $post->getint('pagecount', 10); diff --git a/web/api/ai.php b/web/api/ai.php new file mode 100644 index 0000000..4cfa672 --- /dev/null +++ b/web/api/ai.php @@ -0,0 +1,288 @@ +getint('aikey'); + $aikeyrow = null; + if ($aikey > 0) { + $csql = new \ciy\sql('zc_ai_key'); + $csql->where('id', $aikey); + $aikeyrow = $db->getone($csql); + if (!is_array($aikeyrow)) + return errjson('AI Key不存在'); + } + if (!is_array($aikeyrow)) { + $csql = new \ciy\sql('zc_ai_key'); + $csql->where('id', 1); + $aikeyrow = $db->getone($csql); + if (!is_array($aikeyrow)) + return errjson('AI Key未设置'); + } + $system = $post->get('system'); + $chat = $post->get('chat'); + if (empty($chat)) + return errjson('请输入聊天内容'); + $openai = new \ciy\openai($aikeyrow); + $openai->debug($debug); + $openai->setparam($post->get('aiprange')); + $openai->newsystem($system); + $retai = $openai->completion($chat, strpos($chat . $system, 'JSON') !== false); + if (is_string($retai)) + return errjson($retai); + $ret['ai'] = $retai; + return succjson($ret); + } + public static function json_aidecision($param = null, $debug = false) { + global $db; + set_time_limit(0); + $timespan = time(); + $post = new \ciy\post($param); + $id = $post->getint('id'); + $csql = new \ciy\sql('zc_ai_decision'); + $csql->where('id', $id); + $decisionrow = $db->getone($csql); + if (!is_array($decisionrow)) + return errjson('AI决策单元不存在'); + $csql = new \ciy\sql('zc_ai_key'); + $csql->where('id', $decisionrow['aikey']); + $aikeyrow = $db->getone($csql); + if (!is_array($aikeyrow)) + return errjson('AI Key未设置'); + + $funcdatarows = null; + if (!empty($decisionrow['funcids'])) { + $csql = new \ciy\sql('zc_ai_funcdata'); + $csql->where('id in', trim($decisionrow['funcids'], ',')); + $funcdatarows = $db->get($csql); + } + if (strpos($decisionrow['sysprompt'] . $decisionrow['roleprompt'], '{{know.') === false) { + $csql = new \ciy\sql('zc_ai_knowcata'); + $knowcatarows = $db->get($csql); + if (count($knowcatarows) > 0) { + if ($funcdatarows == null) + $funcdatarows = array(); + $descs = ''; + foreach ($knowcatarows as $knowcatarow) { + $descs .= "\n{知识库ID:" . $knowcatarow['id'] . ", " . $knowcatarow['name'] . ',' . $knowcatarow['aiguide'] . '}'; + } + $funcdatarows[] = array( + 'id' => 0, + 'name' => 'know', + 'funcname' => 'know', + 'descs' => '如果需要补充学习专业知识库信息,调用该函数。知识库列表有,' . $descs, + 'paramjson' => '*ID=准确的知识库ID', + 'funcparam' => '' + ); + } + } + $csql = new \ciy\sql('zc_ai_key'); + $csql->where('id', $decisionrow['aikey']); + $aikeyrow = $db->getone($csql); + if (!is_array($aikeyrow)) + return errjson('AI Key不存在'); + $system = preg_replace_callback('/\{\{([^}]+)\}\}/', function ($matches) use ($db, $post) { + $key = $matches[1]; + if (substr($key, 0, 5) == 'know.') { + $knowcataname = substr($key, 5); + $csql = new \ciy\sql('zc_ai_knowcata'); + $csql->where('name', $knowcataname); + $knowcatarow = $db->getone($csql); + if (!is_array($knowcatarow)) + return ''; + $csql = new \ciy\sql('zc_ai_knowledge'); + $csql->where('cataid', $knowcatarow['id']); + $knowrows = $db->get($csql); + $knowstr = ''; + foreach ($knowrows as $knowrow) { + $knowstr .= $knowrow['content'] . "\n"; + } + return $knowstr; + } + $val = $post->get($key); + if (is_array($val)) + $val = json_encode($val, JSON_UNESCAPED_UNICODE); + return $val . ''; + }, $decisionrow['sysprompt']); + $roleprompt = preg_replace_callback('/\{\{([^}]+)\}\}/', function ($matches) use ($db, $post) { + $key = $matches[1]; + if (substr($key, 0, 5) == 'know.') { + $knowcataname = substr($key, 5); + $csql = new \ciy\sql('zc_ai_knowcata'); + $csql->where('name', $knowcataname); + $knowcatarow = $db->getone($csql); + if (!is_array($knowcatarow)) + return ''; + $csql = new \ciy\sql('zc_ai_knowledge'); + $csql->where('cataid', $knowcatarow['id']); + $knowrows = $db->get($csql); + $knowstr = ''; + foreach ($knowrows as $knowrow) { + $knowstr .= $knowrow['content'] . "\n"; + } + return $knowstr; + } + $val = $post->get($key); + if (is_array($val)) + $val = json_encode($val, JSON_UNESCAPED_UNICODE); + return $val . ''; + }, $decisionrow['roleprompt']); + + $openai = new \ciy\openai($aikeyrow); + $openai->debug($debug); + $openai->setparam($decisionrow['aiprange']); + $openai->newsystem($system); + $retai = $openai->completion($roleprompt, strpos($roleprompt . $system, 'JSON') !== false, $funcdatarows, function ($funcarray) use ($funcdatarows) { + $funcdatarow = ccode($funcdatarows, substr($funcarray['name'], 1), 'id', null); + if (!is_array($funcdatarow)) + return 'ERR未定义函数:' . $funcarray['name']; + $funcname = $funcdatarow['funcname']; + if ($funcname[0] != '\\') + $funcname = '\\web\\admin\\aifunc\\' . $funcname; + if (!class_exists($funcname)) + return 'ERR无效类:' . $funcname; + if (!method_exists($funcname, 'main')) + return 'ERR无效函数:' . $funcname . '::main'; + $funcname .= '::main'; + $arguments = json_decode($funcarray['arguments'], true); + $funcparams = getstrparam($funcdatarow['funcparam'], "\n"); + foreach ($funcparams as $key => $val) { + $arguments[$key] = $val; + } + return call_user_func($funcname, $arguments); + }); + if (is_string($retai)) { + $ret = array(); + $ret['sec'] = time() - $timespan + 1; //用时 + $ret['ci'] = 0; //置信度 + $ret['version'] = $decisionrow['version']; + if ($post->get('_more') == 'ok') { + $ret['messages'] = $openai->messages; //交互过程 + $ret['roleprompt'] = $roleprompt; //提示词 + $ret['system'] = $system; //角色描述 + } + return errjson('AI执行失败: ' . $retai, 10, $ret); + } + + $decci = 0; + $aichat = json_encode($openai->messages, JSON_UNESCAPED_UNICODE); + $resulttxt = json_encode($retai, JSON_UNESCAPED_UNICODE); + if ($decisionrow['aicalkey'] > 0 && !empty($decisionrow['calprompt'])) { + $post->post['result.ai'] = $aichat; + $post->post['result.data'] = $resulttxt; + $csql = new \ciy\sql('zc_ai_key'); + $csql->where('id', $decisionrow['aicalkey']); + $aikeyrow = $db->getone($csql); + if (!is_array($aikeyrow)) + return errjson('置信度 AI Key不存在'); + $calprompt = preg_replace_callback('/\{\{([^}]+)\}\}/', function ($matches) use ($db, $post) { + $key = $matches[1]; + if (substr($key, 0, 5) == 'know.') { + $knowcataname = substr($key, 5); + $csql = new \ciy\sql('zc_ai_knowcata'); + $csql->where('name', $knowcataname); + $knowcatarow = $db->getone($csql); + if (!is_array($knowcatarow)) + return ''; + $csql = new \ciy\sql('zc_ai_knowledge'); + $csql->where('cataid', $knowcatarow['id']); + $knowrows = $db->get($csql); + $knowstr = ''; + foreach ($knowrows as $knowrow) { + $knowstr .= $knowrow['content'] . "\n"; + } + return $knowstr; + } + $val = $post->get($key); + if (is_array($val)) + $val = json_encode($val, JSON_UNESCAPED_UNICODE); + return $val . ''; + }, $decisionrow['calprompt']); + $openai = new \ciy\openai($aikeyrow); + $openai->debug($debug); + $openai->setparam($decisionrow['aicalprange']); + $openai->newsystem(); + $retcalai = $openai->completion($calprompt, true); + $decci = (int)$retcalai['confidence']; + } else if ($decisionrow['aicalkey'] == 0 && !empty($decisionrow['aicalfunc'])) { + $funcname = $decisionrow['aicalfunc']; + if ($funcname[0] != '\\') + $funcname = '\\web\\admin\\aifunc\\' . $funcname; + if (!class_exists($funcname)) + return errjson('置信度 无效类:' . $funcname); + if (!method_exists($funcname, 'main')) + return errjson('置信度 无效函数:' . $funcname . '::main'); + $funcname .= '::main'; + $decci = call_user_func($funcname, $retai, $decisionrow['calprompt']); + } + $ret['sec'] = time() - $timespan + 1; //用时 + $ret['ci'] = $decci; //置信度 + $ret['ai'] = $retai; //结果 + $ret['version'] = $decisionrow['version']; + if ($post->get('_more') == 'ok') { + $ret['messages'] = $openai->messages; //交互过程 + $ret['roleprompt'] = $roleprompt; //提示词 + $ret['system'] = $system; //角色描述 + } + return succjson($ret); + } + public static function multiparam($input, $sep) { + $len = strlen($input); + $ips = array(); + $i = 0; + $inMultiline = false; + $currentParam = ''; + $currentValue = ''; + + while ($i < $len) { + if (!$inMultiline) { + $paramStart = $i; + while ($i < $len && $input[$i] !== $sep) { + if ($input[$i] === "\n") + return '参数格式不合法'; + $i++; + } + if ($i == $len) + return '参数格式不合法,应用' . $sep . '号分隔'; + $currentParam = trim(substr($input, $paramStart, $i - $paramStart)); + if (empty($currentParam)) + return '参数没有参数名'; + $i++; + if ($i < $len && $input[$i] === '`') { + $inMultiline = true; + $i++; + $currentValue = ''; + } else { + $valueStart = $i; + while ($i < $len && $input[$i] !== "\n") + $i++; + $currentValue = trim(substr($input, $valueStart, $i - $valueStart)); + $ips[] = $currentParam . $sep . $currentValue; + $i++; + } + } else { + $valueStart = $i; + while ($i < $len && $input[$i] !== '`') + $i++; + $currentValue .= trim(substr($input, $valueStart, $i - $valueStart)); + if ($i < $len && $input[$i] === '`') { + $ips[] = $currentParam . $sep . $currentValue; + $inMultiline = false; + $i++; + if ($i < $len && $input[$i] === "\n") { + $i++; + } + } else { + $ips[] = $currentParam . $sep . $currentValue; + break; + } + } + } + if (count($ips) == 0) + return '参数都不符合条件'; + return $ips; + } +} diff --git a/web/api/message.php b/web/api/message.php new file mode 100644 index 0000000..510bc8c --- /dev/null +++ b/web/api/message.php @@ -0,0 +1,59 @@ +where('id', $uid); + $uextrow = $db->getone($csql); + if (!is_array($uextrow)) + return false; + $mail = $uextrow['email']; + } + if (empty($mail)) + return false; + //在sendtimes到时间且donetimes<10发送。 + //发送成功donetimes=time + //发送失败donetimes++,sendtimes=time+600 + + //发送完成donetimes+=100 + //通知失败donetimes-=99,sendtimes=time+600 + $updata = array(); + $updata['vuser'] = $uid; + $updata['email'] = $mail; + $updata['chan'] = $chan; + $updata['addtimes'] = tostamp(); + $updata['sendtimes'] = $sendtimes; + $updata['donetimes'] = 0; + $updata['name'] = $mailname; + $updata['content'] = $mailcontent; + $csql = new \ciy\sql('ap_usr_sendmail'); + if ($db->insert($csql, $updata) === false) + throw new \Exception('新建邮件失败:' . $db->error); + } + static function sendsms($db, $chan, $uid, $mobile, $sendtimes, $jsoncontent) { + if (empty($mobile)) { + $csql = new \ciy\sql('ap_user'); + $csql->where('id', $uid); + $uextrow = $db->getone($csql); + if (!is_array($uextrow)) + return false; + $mobile = $uextrow['mobile']; + } + if (empty($mobile)) + return false; + $updata = array(); + $updata['vuser'] = $uid; + $updata['mobile'] = $mobile; + $updata['chan'] = $chan; + $updata['addtimes'] = tostamp(); + $updata['sendtimes'] = $sendtimes; + $updata['donetimes'] = 0; + $updata['content'] = $jsoncontent; + $csql = new \ciy\sql('ap_usr_sendsms'); + if ($db->insert($csql, $updata) === false) + throw new \Exception('新建短信失败:' . $db->error); + } +} diff --git a/web/api/thirdapi.php b/web/api/thirdapi.php new file mode 100644 index 0000000..e9399f0 --- /dev/null +++ b/web/api/thirdapi.php @@ -0,0 +1,27 @@ +request('https://luckycola.com.cn/tools/sensiWords', json_encode($post)); + $result = $http->get_data(); + $json = json_decode($result, true); + if ($json === null) + return '内容分析请求失败'; + if ($json['code'] != 0) + return $json['msg']; + if($json['isPass'] == true) + return true; + savelogfile('bakword', $result); + return '有违禁词,不能发布'; +//{"code":-99,"msg":"colaKey无效","data":{}} +//{"code":0,"msg":"检测成功","isPass":true,"data":{"words":[],"text":"asdfsadf"}} +//{"code":0,"msg":"检测成功","isPass":false,"data":{"words":["法轮","法轮大法"],"text":"法轮大法好啊啊阿萨德"}} + } +} diff --git a/web/api/v1.php b/web/api/v1.php index dde805a..7314657 100644 --- a/web/api/v1.php +++ b/web/api/v1.php @@ -25,7 +25,7 @@ class v1 { $updata['notifyurl'] = $notifyurl; $updata['retimes'] = 0; $updata['uptimes'] = 0; - $updata['nexttimes'] = 9999999999999; + $updata['nexttimes'] = MAXTIMES; $updata['addtimes'] = time(); $updata['signature'] = ''; $updata['orderstatus'] = 10; diff --git a/web/jscss/ciy.js b/web/jscss/ciy.js index b099d56..b20e2e4 100644 --- a/web/jscss/ciy.js +++ b/web/jscss/ciy.js @@ -836,9 +836,9 @@ ciyfn.getdictdata = function (datakey, once, reldata) { return reldata[datakey]; if (isarray(window[datakey])) return window[datakey]; - if (datakey.indexOf('.') == -1 && datakey.indexOf(':') == -1) + if (datakey.indexOf(',') == -1 && datakey.indexOf(':') == -1) return new Array(); - var svs = ciyfn.split(datakey, '.'); + var svs = ciyfn.split(datakey, ','); datas = new Array(); for (var i = 0; i < svs.length; i++) { var ind = svs[i].indexOf(':'); @@ -1713,7 +1713,7 @@ ciyfn.alert = function (content, cb, opn) { } htmldom.find('.content').css('height', (ctheight + 2) + 'px'); var dialogcss = {}; - var w = toint(htmldom.css().width); + var w = toint(htmldom.find('.content').css().width) + 5; if (!opn.width && opn.frame) { if ('ontouchstart' in window) w = window.innerWidth - 10; @@ -1727,7 +1727,8 @@ ciyfn.alert = function (content, cb, opn) { w = window.innerWidth - 30; if (w < 300) w = 300; - dialogcss.width = w + 'px'; + if (Math.abs(w - toint(htmldom.css().width)) > 6) + dialogcss.width = w + 'px'; dialogcss.height = 'auto'; var h = toint(htmldom.css().height); if (opn.height == 'max') { @@ -2076,7 +2077,7 @@ ciyfn.savedict = function (arr) { if (arr[code][d].clas) cs.clas = arr[code][d].clas; if (arr[code][d].isuse != 1) - cs.no = true; + cs.isuse = 2; if (arr[code][d].upid > 0) { for (var i in arr[code]) { if (arr[code][d].upid == arr[code][i].id) { @@ -2758,4 +2759,8 @@ document.addEventListener('DOMContentLoaded', function () { } } }); + $5(document).on('click', '.help', itm => { + var help = $5(itm.currentTarget).attr('help'); + ciyfn.alert(help.replace(/\\n/g, '
')); + }); }); \ No newline at end of file diff --git a/web/jscss/ciycmp.js b/web/jscss/ciycmp.js index 4ad3210..b7ce456 100644 --- a/web/jscss/ciycmp.js +++ b/web/jscss/ciycmp.js @@ -711,6 +711,7 @@ ciycmpfunc.ciyradio = function (opn) { opn.initevent = opn.initevent || opn.dom.hasattr('initevent'); opn.hasmore = opn.hasmore || opn.dom.hasattr('hasmore'); opn.hasline = opn.hasline || opn.dom.hasattr('hasline'); + opn.chkuse = opn.chkuse || opn.dom.hasattr('chkuse'); opn.all = opn.all || opn.dom.attr('all') || ''; opn.minwidth = opn.minwidth || opn.dom.attr('minwidth') || 'auto'; if (typeof (opn.fn_item) !== 'function') @@ -736,7 +737,7 @@ ciycmpfunc.ciyradio = function (opn) { var selname = ''; for (var i in this.range) { var range = this.range[i]; - if (range.isuse == 2) + if (opn.chkuse && range.isuse == 2) continue; if (opn.filter && range[opn.filter.field] != opn.filter.value) continue; @@ -780,6 +781,7 @@ ciycmpfunc.ciycheckbox = function (opn) { opn.initevent = opn.initevent || opn.dom.hasattr('initevent'); opn.hasmore = opn.hasmore || opn.dom.hasattr('hasmore'); opn.hasline = opn.hasline || opn.dom.hasattr('hasline'); + opn.chkuse = opn.chkuse || opn.dom.hasattr('chkuse'); opn.range = opn.range || opn.dom.attr('range'); opn.minwidth = opn.minwidth || opn.dom.attr('minwidth') || ''; if (opn.dom.attr('text')) { @@ -821,7 +823,7 @@ ciycmpfunc.ciycheckbox = function (opn) { var selnames = []; for (var i in this.range) { var range = this.range[i]; - if (range.isuse == 2) + if (opn.chkuse && range.isuse == 2) continue; if (opn.filter && range[opn.filter.field] != opn.filter.value) continue; @@ -904,6 +906,7 @@ ciycmpfunc.ciyselect = function (opn) { this.onchange = opn.onchange; opn.initevent = opn.initevent || opn.dom.hasattr('initevent'); opn.hasmore = opn.hasmore || opn.dom.hasattr('hasmore'); + opn.chkuse = opn.chkuse || opn.dom.hasattr('chkuse'); opn.minsearch = toint(opn.minsearch || opn.dom.attr('minsearch') || 0); opn.all = opn.all || opn.dom.attr('all') || ''; opn.range = opn.range || opn.dom.attr('range'); @@ -979,7 +982,7 @@ ciycmpfunc.ciyselect = function (opn) { if (!badd) this.range = []; for (var i in ranges) { - if (ranges[i].isuse == 2) + if (opn.chkuse && ranges[i].isuse == 2) continue; if (!ranges[i]._nofilter && opn.filter && ranges[i][opn.filter.field] != opn.filter.value) continue; @@ -1136,7 +1139,7 @@ ciycmpfunc.ciyinputbet = function (opn) { opn.units[i] = opn.units[i].substring(1); } } - opn.width = opn.width || opn.dom.attr('width') || '5em'; + opn.width = opn.width || opn.dom.attr('width') || '6em'; opn.align = opn.align || opn.dom.attr('align') || 'right'; var html = ''; html += ''; @@ -1217,7 +1220,7 @@ ciycmpfunc.ciyupload = function (opn) { // v2 opn.imgheight = toint(opn.imgheight || opn.dom.attr('imgheight')); opn.maxsize = toint(opn.maxsize || opn.dom.attr('maxsize')); opn.zipjpg = tofloat(opn.zipjpg || opn.dom.attr('zipjpg')); - opn.zipext = opn.zipext || opn.dom.attr('zipext') || 'jpg,png'; + opn.zipext = opn.zipext || opn.dom.attr('zipext') || 'jpg,png,webp'; if (opn.zipext) opn.zipext = opn.zipext.toUpperCase().split(','); opn.waterfont = opn.waterfont || opn.dom.attr('waterfont') || '28px Arial'; diff --git a/web/jscss/ciycmp2.js b/web/jscss/ciycmp2.js index 113e8e3..65afbea 100644 --- a/web/jscss/ciycmp2.js +++ b/web/jscss/ciycmp2.js @@ -5,15 +5,13 @@ 'use strict'; ciyfn.markdown = function (markdown) { // #,!,`,@lcr,|表格 - if (markdown.substring(0, 4) != '[MD]') - return markdown; - markdown = markdown.substring(4).trim(); + if (markdown.substring(0, 4) == '[MD]') + markdown = markdown.substring(4).trim(); var mds = markdown.split('\n'); var html = ''; - var titnum2 = 0; - var titnum3 = 0; - var titnum4 = 0; var ispvs = 0; //0文本,1html,2表格 + var isol = false; + var titnum = [0, 0, 0, 0, 0]; var tabalign = {}; for (var m in mds) { if (mds[m].length == 0) { @@ -24,6 +22,10 @@ ciyfn.markdown = function (markdown) { if (mds[m].length > 0 && mds[m].trim() == '') { if (ispvs == 2) html += ''; + if (isol) { + isol = false; + html += ''; + } ispvs = 0; html += '
'; continue; @@ -32,27 +34,39 @@ ciyfn.markdown = function (markdown) { if (ispvs == 2) html += ''; ispvs = 0; + if (isol) { + isol = false; + html += ''; + } var cr = mds[m].substring(1, 2).toLowerCase(); - if (mds[m].substring(0, 4) == '####') { - titnum4++; - html += '

' + titnum2 + '.' + titnum3 + '.' + titnum4 + '、' + convertcode(mds[m].substring(4)) + '

'; + if (mds[m].substring(0, 5) == '#####') { + if (mds[m].substring(5, 6) == '1') + html += '
' + olnum(4, titnum, '、') + convertcode(mds[m].substring(6)) + '
'; + else + html += '
' + convertcode(mds[m].substring(5)) + '
'; + } else if (mds[m].substring(0, 4) == '####') { + if (mds[m].substring(4, 5) == '1') + html += '

' + olnum(3, titnum, '、') + convertcode(mds[m].substring(5)) + '

'; + else + html += '

' + convertcode(mds[m].substring(4)) + '

'; } else if (mds[m].substring(0, 3) == '###') { - titnum3++; - titnum4 = 0; - html += '

' + titnum2 + '.' + titnum3 + '、' + convertcode(mds[m].substring(3)) + '

'; - } - else if (mds[m].substring(0, 2) == '##') { - titnum2++; - titnum3 = 0; - html += '

' + titnum2 + '、' + convertcode(mds[m].substring(2)) + '

'; - } - else if (cr == 'c') + if (mds[m].substring(3, 4) == '1') + html += '

' + olnum(2, titnum, '、') + convertcode(mds[m].substring(4)) + '

'; + else + html += '

' + convertcode(mds[m].substring(3)) + '

'; + } else if (mds[m].substring(0, 2) == '##') { + if (mds[m].substring(2, 3) == '1') + html += '

' + olnum(1, titnum, '、') + convertcode(mds[m].substring(3)) + '

'; + else + html += '

' + convertcode(mds[m].substring(2)) + '

'; + } else if (cr == 'c') html += '

' + convertcode(mds[m].substring(2)) + '

'; else if (cr == 'r') html += '

' + convertcode(mds[m].substring(2)) + '

'; + else if (cr == '1') + html += '

' + olnum(0, titnum, '、') + convertcode(mds[m].substring(2)) + '

'; else - html += '

' + convertcode(mds[m].substring(1)) + '

'; - + html += '

' + convertcode(mds[m].substr(1)) + '

'; } else if (mds[m][0] == '@') {//c居中,r靠右 if (ispvs == 2) html += ''; @@ -62,7 +76,13 @@ ciyfn.markdown = function (markdown) { html += '
' + convertcode(mds[m].substring(2)) + '
'; else if (cr == 'r') html += '
' + convertcode(mds[m].substring(2)) + '
'; - else + else if (cr == '1') { + if (!isol) { + isol = true; + html += '
    '; + } + html += '
  1. ' + convertcode(mds[m].substr(2)) + '
  2. '; + } else html += mds[m].substring(1); } else if (mds[m][0] == '!') {//图片 @@ -121,12 +141,35 @@ ciyfn.markdown = function (markdown) { if (ispvs == 2) html += ''; ispvs = 0; + if (isol) { + isol = false; + html += '
'; + } html += '
' + convertcode(mds[m]) + '
'; } } if (ispvs == 2) html += ''; + if (isol) { + isol = false; + html += ''; + } return html; + function olnum(idx, olnum, end) { + console.log(idx, olnum, end); + olnum[idx]++; + for (var i = idx + 1; i < olnum.length; i++) + olnum[i] = 0; + for (var i = 0; i <= idx; i++) { + if (olnum[i] == 0) + continue; + var ols = []; + for (var j = i; j <= idx; j++) { + ols.push(olnum[j]); + } + return ols.join('.') + end; + } + } function convertcode(md) { var bcode = false; md = md.replace(/ /g, ' '); @@ -171,7 +214,7 @@ ciyfn.markdown = function (markdown) { let mis = md.substring(ind + 1, ind2).split(']('); if (mis.length != 2) break; - let url = mis[1]; + let url = ciyfn.file_stor(mis[1]); let text = mis[0]; if (text == '') text = url; @@ -194,6 +237,7 @@ ciycmpfunc.ciyselcas = function (opn) { this.onchange = opn.onchange; opn.initevent = opn.initevent || opn.dom.hasattr('initevent'); opn.hasmore = opn.hasmore || opn.dom.hasattr('hasmore'); + opn.chkuse = opn.chkuse || opn.dom.hasattr('chkuse'); opn.minsearch = toint(opn.minsearch || opn.dom.attr('minsearch') || 0); opn.all = opn.all || opn.dom.attr('all') || ''; opn.placeholder = ciyfn.lang(opn.placeholder || opn.dom.attr('placeholder') || '请选择'); @@ -237,7 +281,7 @@ ciycmpfunc.ciyselcas = function (opn) { return console.error('ciy_selcas range null', opn.name); this.range = []; for (var i in opn.range) { - if (opn.range[i].isuse == 2) + if (opn.chkuse && opn.range[i].isuse == 2) continue; if (!opn.range[i].upid) opn.range[i].upid = 0; @@ -311,6 +355,7 @@ ciycmpfunc.ciyselmulti = function (opn) { this.onchange = opn.onchange; opn.initevent = opn.initevent || opn.dom.hasattr('initevent'); opn.hasmore = opn.hasmore || opn.dom.hasattr('hasmore'); + opn.chkuse = opn.chkuse || opn.dom.hasattr('chkuse'); opn.minsearch = toint(opn.minsearch || opn.dom.attr('minsearch') || 0); opn.minwidth = opn.minwidth || opn.dom.attr('minwidth') || ''; opn.placeholder = opn.placeholder || opn.dom.attr('placeholder') || '请选择'; @@ -381,7 +426,7 @@ ciycmpfunc.ciyselmulti = function (opn) { var ranges = []; for (var i in this.range) { var range = this.range[i]; - if (range.isuse == 2) + if (opn.chkuse && range.isuse == 2) continue; if (opn.filter && range[opn.filter.field] != opn.filter.value) continue; @@ -403,7 +448,7 @@ ciycmpfunc.ciyselmulti = function (opn) { return console.error('ciy_select range null', opn.name); this.range = []; for (var i in ranges) { - if (ranges[i].isuse == 2) + if (opn.chkuse && ranges[i].isuse == 2) continue; if (!ranges[i]._nofilter && opn.filter && ranges[i][opn.filter.field] != opn.filter.value) continue; @@ -552,18 +597,20 @@ ciycmpfunc.ciyinputcyc = function (opn) { var eus = opn.enableunit.split(','); opn.enableunit = []; for (var i in eus) { - var eu = eus[i].trim().toUpperCase(); - if (eu == 'MONTH' || eu == 'DAY' || eu == 'SEC') + var eu = eus[i].trim().toLowerCase(); + if (eu == 'month' || eu == 'day' || eu == 'hour' || eu == 'min' || eu == 'sec') opn.enableunit.push(eu); } if (opn.enableunit.length == 0) - opn.enableunit = ['MONTH', 'DAY', 'SEC']; + opn.enableunit = ['month', 'day', 'hour', 'min', 'sec']; var html = ''; html += ''; html += ''; - if (opn.enableunit.indexOf('MONTH') >= 0) html += ''; - if (opn.enableunit.indexOf('DAY') >= 0) html += ''; - if (opn.enableunit.indexOf('SEC') >= 0) html += ''; + if (opn.enableunit.indexOf('month') >= 0) html += ''; + if (opn.enableunit.indexOf('day') >= 0) html += ''; + if (opn.enableunit.indexOf('hour') >= 0) html += ''; + if (opn.enableunit.indexOf('min') >= 0) html += ''; + if (opn.enableunit.indexOf('sec') >= 0) html += ''; html += ''; opn.dom.html(html).css({ display: 'inline-flex' }); var valuedom = opn.dom.children(0); @@ -575,23 +622,65 @@ ciycmpfunc.ciyinputcyc = function (opn) { if (newvalue !== undefined) { var dat = toint(newvalue); if (dat < 0) { - data.num = -dat; data.unit = 'month'; + data.num = -dat; + } else if (dat % 86400 == 0) { + data.unit = 'day'; + data.num = toint(dat / 86400); + } else if (dat % 3600 == 0) { + data.unit = 'hour'; + data.num = toint(dat / 3600); + } else if (dat % 60 == 0) { + data.unit = 'min'; + data.num = toint(dat / 60); } else { - if (dat % 86400 > 0) { - data.num = dat; - data.unit = 'sec'; - } else { - data.num = toint(dat / 86400); - data.unit = 'day'; - } + data.unit = 'sec'; + data.num = toint(dat); } this.value = dat; + if (data.unit == 'month' && opn.enableunit.indexOf('month') == -1) { + data.num *= 30; + data.unit = 'day'; + } + if (data.unit == 'day' && opn.enableunit.indexOf('day') == -1) { + data.num *= 24; + data.unit = 'hour'; + } + if (data.unit == 'hour' && opn.enableunit.indexOf('hour') == -1) { + data.num *= 60; + data.unit = 'min'; + } + if (data.unit == 'min' && opn.enableunit.indexOf('min') == -1) { + data.num *= 60; + data.unit = 'sec'; + } + if (data.unit == 'sec' && opn.enableunit.indexOf('sec') == -1) { + if (opn.enableunit.indexOf('min') > -1) { + data.num = Math.ceil(data.num / 60); + data.unit = 'min'; + } + else if (opn.enableunit.indexOf('hour') > -1) { + data.num = Math.ceil(data.num / 3600); + data.unit = 'hour'; + } + else if (opn.enableunit.indexOf('day') > -1) { + data.num = Math.ceil(data.num / 86400); + data.unit = 'day'; + } + else if (opn.enableunit.indexOf('month') > -1) { + data.num = -Math.floor(data.num / 86400 / 30); + data.unit = 'month'; + } + } showinpdom.val(data.num); showseldom.val(data.unit); } else { var dat = data.num; - if (data.unit == 'day') + if (data.unit == 'min') + dat = dat * 60; + else if (data.unit == 'hour') + dat = dat * 3600; + else if (data.unit == 'day') dat = dat * 86400; else if (data.unit == 'month') dat = -dat; @@ -719,9 +808,9 @@ ciycmpfunc.ciytimepoint = function (opn) { opn.initevent = opn.initevent || opn.dom.hasattr('initevent'); opn.hasmore = opn.hasmore || opn.dom.hasattr('hasmore'); opn.placeholder = ciyfn.lang(opn.placeholder || opn.dom.attr('placeholder') || '请选择'); - opn.type = opn.type || opn.dom.attr('type') || 'minute'; //minute,second + opn.type = opn.type || opn.dom.attr('type') || 'min'; //min,sec opn.inpwidth = '4em'; - if (opn.type == 'second') + if (opn.type == 'sec') opn.inpwidth = '5.5em'; var csstxt = ''; csstxt += 'ciy-timepoint>._pulldt{user-select: none;position: fixed;top: 0;left: 0;right: 0;bottom: 0;display:none;z-index:100000;}'; @@ -790,7 +879,7 @@ ciycmpfunc.ciytimepoint = function (opn) { if (newvalue !== undefined) { this.value = str_timepoint(newvalue); } - var dat = ciyfn.totimepoint(this.value, opn.type == 'second'); + var dat = ciyfn.totimepoint(this.value, opn.type == 'sec'); valuedom.val(this.value); valnamedom.val(dat); if (this.value != 0) { @@ -866,7 +955,7 @@ ciycmpfunc.ciytimepoint = function (opn) { var html = ''; html += '
' + dtimevalue[0] + '
' + ciyfn.lang('选择小时') + '
' html += '
' + dtimevalue[1] + '
' + ciyfn.lang('选择分钟') + '
' - if (opn.type == 'second') + if (opn.type == 'sec') html += '
' + dtimevalue[2] + '
' + ciyfn.lang('选择秒钟') + '
' html += '' timebtndom.html(html); @@ -956,6 +1045,7 @@ ciycmpfunc.ciymarkdown = function (opn) { opn.zipext = tofloat(opn.zipext || opn.dom.attr('zipext')); opn.waterfont = opn.waterfont || opn.dom.attr('waterfont') || '28px Arial'; opn.watertext = opn.watertext || opn.dom.attr('watertext') || ''; + opn.fileext = (opn.fileext || opn.dom.attr('fileext') || '.pdf,.zip,.docx,.doc,.pptx,.ppt,.xlsx,.xls,.txt,.rar,.7z,.tar,.glb').toLowerCase().split(','); opn.action = opn.action || opn.dom.attr('action'); if (!opn.action) { opn.action = "/z/?func=" + ciy_vars.uploadurl; @@ -982,8 +1072,9 @@ ciycmpfunc.ciymarkdown = function (opn) {
- 上传图片 - 上传视频 + 图片 + 视频 + 附件