diff --git a/web/admin/cemap/glb.html b/web/admin/cemap/glb.html
index fb0fdb4..ae824a8 100644
--- a/web/admin/cemap/glb.html
+++ b/web/admin/cemap/glb.html
@@ -211,7 +211,7 @@
//, noparent:true
, fn_showed: function (doc, dom) {
var dat = jsndat.data;
- ciycmp({ dom: $5('[com=cpath]', dom), value: dat.cpath, range: table.once.zc_cemap_pglb });
+ ciycmp({ dom: $5('[com=cpath]', dom), value: dat.cpath, range: table.json.zc_cemap_pglb });
$5('[name=name]', dom).val(dat.name);
ciycmp({ dom: $5('[com=url]', dom), value: dat.url, path: 'glb', stor: Glob.stor });
}
diff --git a/web/admin/cemap/glb.php b/web/admin/cemap/glb.php
index 58c7ed2..667d81c 100644
--- a/web/admin/cemap/glb.php
+++ b/web/admin/cemap/glb.php
@@ -35,7 +35,7 @@ class glb {
$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);
+ $ret = array('searchwhere' => $where, 'pageno' => $pageno, 'pagecount' => $pagecount, 'count' => $mainrowcount, 'list' => $rows);
if ($post->getbool('field')) {
$field = array();
$fshow = $db->getfield($field, 'zc_cemap_glb');
@@ -49,13 +49,13 @@ class glb {
$ret['fshow'] = $fshow;
}
if ($post->getbool('once')) {
- $ret['once'] = array();
+ $ret['once'] = true;
$input = array();
$input[] = array('type' => 'input', 'form' => 'cpath', 'name' => '路径', 'prop' => ' style="width:8em;"');
$input[] = array('type' => 'input', 'form' => 'name', 'name' => '名称', 'prop' => ' style="width:8em;"');
- $ret['once']['input'] = $input;
+ $ret['searchinput'] = $input;
$csql = (new \ciy\sql('zc_cemap_pglb'))->column('id,name,upid');
- $ret['once']['zc_cemap_pglb'] = $db->get($csql);
+ $ret['zc_cemap_pglb'] = $db->get($csql);
}
return succjson($ret);
}
diff --git a/web/admin/cemap/pathbill.php b/web/admin/cemap/pathbill.php
index 9027d8c..a63b09a 100644
--- a/web/admin/cemap/pathbill.php
+++ b/web/admin/cemap/pathbill.php
@@ -20,12 +20,12 @@ class pathbill {
$ret['fshow'] = $fshow;
}
if ($post->getbool('once')) {
- $ret['once'] = array();
+ $ret['once'] = true;
$input = array();
$input[] = array(
'type' => 'input', 'form' => 'name', 'name' => '分类名称', 'prop' => ' style="width:8em;"'
);
- $ret['once']['input'] = $input;
+ $ret['searchinput'] = $input;
}
return succjson($ret);
}
diff --git a/web/admin/cemap/pathglb.php b/web/admin/cemap/pathglb.php
index 6211e03..af21219 100644
--- a/web/admin/cemap/pathglb.php
+++ b/web/admin/cemap/pathglb.php
@@ -20,12 +20,12 @@ class pathglb {
$ret['fshow'] = $fshow;
}
if ($post->getbool('once')) {
- $ret['once'] = array();
+ $ret['once'] = true;
$input = array();
$input[] = array(
'type' => 'input', 'form' => 'name', 'name' => '分类名称', 'prop' => ' style="width:8em;"'
);
- $ret['once']['input'] = $input;
+ $ret['searchinput'] = $input;
}
return succjson($ret);
}
diff --git a/web/admin/develop/code_create.html b/web/admin/develop/code_create.html
index c3654a2..89c591a 100644
--- a/web/admin/develop/code_create.html
+++ b/web/admin/develop/code_create.html
@@ -428,6 +428,7 @@
|| data.COLUMN_NAME == 'ip') {
spset.noup = 'no';
}
+
if (data.COLUMN_NAME == table.json.dbsaas.saasfield) {
spset.noup = 'saas';
}
diff --git a/web/admin/develop/code_pc_html.php b/web/admin/develop/code_pc_html.php
index 3bc0593..f05ea99 100644
--- a/web/admin/develop/code_pc_html.php
+++ b/web/admin/develop/code_pc_html.php
@@ -784,9 +784,8 @@ if($hasedit){
$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 == 'FILEMD') {
$codex .= "\n var path = ciyfn.makeuploadpath('{$fld['set']['savepath']}', ciyfn.getstorage(ciy_vars.tokenfield));";
- $codex .= "\n path = path.replace(/{Y}/g, new Date().getFullYear()).replace(/{m}/g, ciyfn.topad0(new Date().getMonth() + 1, 2)).replace(/{d}/g, ciyfn.topad0(new Date().getDate(), 2));";
$codex .= "\n ciyfn.ajax({";
- $codex .= "\n url: ciyfn.file_stor('/' + path + '/' + dat.id + '_' + dat.{$col} + '.txt')";
+ $codex .= "\n url: ciyfn.file_stor('/md/{$fld['set']['savepath']}/' + dat.id + '_' + dat.{$col} + '.txt')";
$codex .= "\n , method: 'GET'";
$codex .= "\n , success: function (res) {";
$codex .= "\n ciycmp({ dom: $5('[com={$col}]', dom), value: res, path: path });";
diff --git a/web/admin/develop/code_pc_php.php b/web/admin/develop/code_pc_php.php
index 0265b21..18bb3c8 100644
--- a/web/admin/develop/code_pc_php.php
+++ b/web/admin/develop/code_pc_php.php
@@ -591,7 +591,7 @@ function code_pc_php($post) {
foreach ($flds as $fld) {
$col = $fld['col'];
if ($fld['cate'] == 'FILEMD'){
- $codex .= "\n if (storsave('/{Y}/{m}{d}/{$fld['set']['savepath']}/' . \$id . '_' . \${$col} . '.txt', \${$col}_text) === false)";
+ $codex .= "\n if (storsave('/md/{$fld['set']['savepath']}/' . \$id . '_' . \${$col} . '.txt', \${$col}_text) === false)";
$codex .= "\n return errjson('写入失败');";
}
}
diff --git a/web/ambap/ciyai.php b/web/ambap/ciyai.php
new file mode 100644
index 0000000..6750d89
--- /dev/null
+++ b/web/ambap/ciyai.php
@@ -0,0 +1,285 @@
+getint('aikey');
+ $aikeyrow = null;
+ if ($aikey > 0) {
+ $csql = new \ciy\sql($tabpre.'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($tabpre.'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, $tabpre = 'zc_') {
+ global $db;
+ set_time_limit(0);
+ $timespan = time();
+ $post = new \ciy\post($param);
+ $id = $post->getint('id');
+ $csql = new \ciy\sql($tabpre.'ai_decision');
+ $csql->where('id', $id);
+ $decisionrow = $db->getone($csql);
+ if (!is_array($decisionrow))
+ return errjson('AI决策单元不存在');
+ $csql = new \ciy\sql($tabpre.'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($tabpre.'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($tabpre.'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($tabpre.'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, $tabpre) {
+ $key = $matches[1];
+ if (substr($key, 0, 5) == 'know.') {
+ $knowcataname = substr($key, 5);
+ $csql = new \ciy\sql($tabpre.'ai_knowcata');
+ $csql->where('name', $knowcataname);
+ $knowcatarow = $db->getone($csql);
+ if (!is_array($knowcatarow))
+ return '';
+ $csql = new \ciy\sql($tabpre.'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, $tabpre) {
+ $key = $matches[1];
+ if (substr($key, 0, 5) == 'know.') {
+ $knowcataname = substr($key, 5);
+ $csql = new \ciy\sql($tabpre.'ai_knowcata');
+ $csql->where('name', $knowcataname);
+ $knowcatarow = $db->getone($csql);
+ if (!is_array($knowcatarow))
+ return '';
+ $csql = new \ciy\sql($tabpre.'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 (substr($funcname, 0, 4) != 'http') {
+ 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);
+ }
+ //远程调用url
+ $http = new \ciy\http();
+ $http->request($funcname, $funcarray['arguments']);
+ $datastr = $http->get_data();
+ return json_decode($datastr, true);
+ });
+ if (is_string($retai))
+ return errjson('AI识别失败: ' . $retai);
+
+ $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($tabpre.'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, $tabpre) {
+ $key = $matches[1];
+ if (substr($key, 0, 5) == 'know.') {
+ $knowcataname = substr($key, 5);
+ $csql = new \ciy\sql($tabpre.'ai_knowcata');
+ $csql->where('name', $knowcataname);
+ $knowcatarow = $db->getone($csql);
+ if (!is_array($knowcatarow))
+ return '';
+ $csql = new \ciy\sql($tabpre.'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['version'] = $decisionrow['version'];
+ $ret['sec'] = time() - $timespan + 1; //用时
+ $ret['ci'] = $decci; //置信度
+ $ret['ai'] = $retai; //结果
+ 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/common.php b/web/ambap/common.php
index 24f0e58..a9d6fd9 100644
--- a/web/ambap/common.php
+++ b/web/ambap/common.php
@@ -127,7 +127,7 @@ function gettoken($db, $id) {
$csql->where('id', $id);
$tokenrow = $db->getone($csql);
if (!is_array($tokenrow))
- return array();
+ return '获取数据库token失败:' . $id;
$cfgtoken = str_replace('{PATH_ROOT}', PATH_ROOT, $tokenrow['cfgtoken']);
$cfg = getstrparam($cfgtoken, "\n");
$cfg['accesstoken'] = $tokenrow['accesstoken'];
diff --git a/web/ambap/login.php b/web/ambap/login.php
index 44d0005..915b178 100644
--- a/web/ambap/login.php
+++ b/web/ambap/login.php
@@ -133,14 +133,13 @@ class login {
$post = new \ciy\post();
$code = $post->get('code');
$upid = $post->getint('upid');
- $wxcfg = gettoken($db, 1);
- $wxpay = new \ciy\wxfunc($wxcfg);
- $ret = $wxpay->code2Session($code);
- if (!is_array($ret))
- return errjson($ret);
+ $weixinapi = new \web\api\weixin(1);
+ $wxret = $weixinapi->call('https://api.weixin.qq.com/sns/jscode2session?grant_type=authorization_code&appid={appid}&secret={appsecret}&js_code=' . $code);
+ if (is_string($wxret))
+ return errjson($wxret);
- $openid = $ret['openid'];
- $sskey = $ret['session_key'];
+ $openid = $wxret['openid'];
+ $sskey = $wxret['session_key'];
$csql = new \ciy\sql('ap_user');
$csql->where('wxminaid', $openid);
$rsuser = $db->getone($csql);
@@ -151,8 +150,8 @@ class login {
$userid = $rsuser['id'];
if ($rsuser['upid'] == 0 && $upid > 0 && $upid != $userid)
$rsuser['upid'] = $upid;
- if (isset($ret['unionid']))
- $rsuser['wxunionid'] = $ret['unionid'];
+ if (isset($wxret['unionid']))
+ $rsuser['wxunionid'] = $wxret['unionid'];
$rsuser['wxminakey'] = $sskey;
$rsuser['wxminaid'] = $openid;
$rsuser['trytime'] = 0;
@@ -168,11 +167,11 @@ class login {
$newpnt = 1000; //注册赠送积分
$rsuser = array();
$rsuser['upid'] = $upid;
- if (isset($ret['unionid']))
- $rsuser['wxunionid'] = $ret['unionid'];
+ if (isset($wxret['unionid']))
+ $rsuser['wxunionid'] = $wxret['unionid'];
$rsuser['icon'] = '';
$rsuser['certs'] = '';
- $rsuser['name'] = ':' . substr($openid, -6);
+ $rsuser['name'] = '';
$rsuser['mobile'] = '';
$rsuser['stpstatus'] = 10;
$rsuser['userlevel'] = 10;
@@ -368,12 +367,13 @@ class login {
$ret['me']['mypnt'] = $userrow['mypnt'];
$ret['me']['certs'] = $userrow['certs'];
$ret['me']['needpass'] = empty($userrow['password']);
- $csql = new \ciy\sql('zc_debug_user');
- $csql->where('targettype', 21);
- $csql->where('isuse', 1);
- $csql->where('user', $userrow['mobile']);
- $ret['me']['dbg'] = is_array($db->getone($csql));
-
+ if (!empty($userrow['mobile'])) {
+ $csql = new \ciy\sql('zc_debug_user');
+ $csql->where('targettype', 21);
+ $csql->where('isuse', 1);
+ $csql->where('user', $userrow['mobile']);
+ $ret['me']['dbg'] = is_array($db->getone($csql));
+ }
$csql = new \ciy\sql('ap_usr_ext');
$csql->where('id', $userrow['id']);
$extrow = $db->getone($csql);
diff --git a/web/ambap/me.php b/web/ambap/me.php
index 6f067d8..f43813c 100644
--- a/web/ambap/me.php
+++ b/web/ambap/me.php
@@ -122,19 +122,15 @@ class me {
$param['openid'] = $rsuser['wxminaid'];
$param['notify_url'] = $_token['maindomain'] . 'wxpay.transfer';
$param['transfer_remark'] = '佣金奖励';
- $param['transfer_amount'] = $cashmoney;
+ $param['transfer_amount'] = toint($cashmoney);
$param['transfer_scene_report_infos'] = array();
$param['transfer_scene_report_infos'][] = array('info_type' => '岗位类型', 'info_content' => '采集员');
$param['transfer_scene_report_infos'][] = array('info_type' => '报酬说明', 'info_content' => '用户主动申请提现');
-
- $wxcfg = gettoken($db, 1);
- $wxpay = new \ciy\wxfunc($wxcfg);
- $rettransfer = $wxpay->transfer($param);
- if (is_string($rettransfer))
- return errjson($rettransfer);
- $rettransfer['mchid'] = $wxpay->mchid;
- $rettransfer['appid'] = $wxpay->appid;
- $ret['transfer'] = $rettransfer;
+ $weixinapi = new \web\api\weixin(1);
+ $wxret = $weixinapi->transfer($param);
+ if (is_string($wxret))
+ return errjson($wxret);
+ $ret['transfer'] = $wxret;
return succjson($ret);
}
private static function caltax($money) {
@@ -195,12 +191,7 @@ class me {
}
try {
$db->begin();
- $updata = array();
- $updata['mycashmoney'] = array('mycashmoney-' . $cash);
- $csql = new \ciy\sql('ap_user');
- $csql->where('id', $rsuser['id']);
- if ($db->update($csql, $updata) === false)
- throw new \Exception('更新账户失败:' . $db->error);
+ \web\cdao::usercashoe($db, 11, $rsuser['id'], -$cash, '提现');
$updata = array();
$updata['cashstatus'] = 10;
$updata['cashmoney'] = $cash;
@@ -361,9 +352,8 @@ class me {
$param['amount']['total'] = (int)$money;
$param['payer'] = array();
$param['payer']['openid'] = $rsuser['wxminaid'];
- $wxcfg = gettoken($db, 1);
- $wxpay = new \ciy\wxfunc($wxcfg);
- $retpay = $wxpay->pay($param);
+ $weixinapi = new \web\api\weixin(1);
+ $retpay = $weixinapi->pay($param);
if (is_string($retpay))
return errjson($retpay);
$retpay['orderid'] = $orderid;
@@ -440,9 +430,8 @@ class me {
$param['amount']['total'] = (int)$payprice;
$param['payer'] = array();
$param['payer']['openid'] = $rsuser['wxminaid'];
- $wxcfg = gettoken($db, 1);
- $wxpay = new \ciy\wxfunc($wxcfg);
- $retpay = $wxpay->pay($param);
+ $weixinapi = new \web\api\weixin(1);
+ $retpay = $weixinapi->pay($param);
if (is_string($retpay))
return errjson($retpay);
$retpay['orderid'] = $orderid;
@@ -514,6 +503,11 @@ class me {
return errjson('新增失败:' . $db->error);
return succjson();
}
+ public static function json_user_show_more() {
+ global $db;
+ $ret['data'] = null;
+ return succjson($ret);
+ }
public static function json_safe_real_init() {
global $db;
$rsuser = verifyfast();
@@ -521,6 +515,7 @@ class me {
$csql->where('vuser', $rsuser['id']);
$csql->order('id desc');
$ret['data'] = $db->getone($csql);
+ $ret['inputtype'] = 1;
return succjson($ret);
}
public static function json_safe_real_submit() {
@@ -774,40 +769,25 @@ class me {
return succjson();
}
public static function json_share_qrcode_get() {
- global $db;
$rsuser = verifyfast();
$filename = '/xcxqrcode/' . $rsuser['id'] . '.jpg';
$ret['qrcode'] = $filename;
$filename = PATH_WEB . 'ud' . $filename;
if (file_exists($filename))
return succjson($ret);
- $wxcfg = gettoken($db, 1);
- $wx = new \ciy\wxfunc($wxcfg);
- if ($wxcfg['exptimes'] < time()) {
- $access = $wx->getaccess();
- if (is_string($access))
- return errjson($access);
- settoken($db, 1, $access);
- $wx->accesstoken = $access['accesstoken'];
- }
$param = array();
$param['scene'] = 'upid=' . $rsuser['id'] . '&carduser=' . $rsuser['id'];
$param['page'] = 'pages/main/index';
$param['check_path'] = true;
$param['env_version'] = 'release';
$param['width'] = 1280;
- $retwx = $wx->getwxacodeunlimit($param);
- if (@$retwx[0] == '{') {
- $json = json_decode($retwx, true);
- if ($json === null)
- return errjson('微信服务器无法连接getwxacodeunlimit');
- if (isset($json['errmsg']))
- return errjson($json['errmsg']);
- return errjson('生成二维码失败');
- }
+ $weixinapi = new \web\api\weixin(1);
+ $wxret = $weixinapi->call('https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={accesstoken}', $param, true);
+ if (is_string($wxret))
+ return errjson($wxret);
dirmake(dirname($filename));
$fp = fopen($filename, 'w');
- fwrite($fp, $retwx);
+ fwrite($fp, $wxret['bin']);
fclose($fp);
return succjson($ret);
}
@@ -1029,13 +1009,12 @@ class me {
$param['amount']['total'] = (int)$money;
$param['payer'] = array();
$param['payer']['openid'] = $rsuser['wxminaid'];
- $wxcfg = gettoken($db, 1);
- $wxpay = new \ciy\wxfunc($wxcfg);
- $ret = $wxpay->pay($param);
- if (is_string($ret))
- return errjson($ret);
- $ret['orderid'] = $orderid;
- return succjson($ret);
+ $weixinapi = new \web\api\weixin(1);
+ $retpay = $weixinapi->pay($param);
+ if (is_string($retpay))
+ return errjson($retpay);
+ $retpay['orderid'] = $orderid;
+ return succjson($retpay);
}
public static function json_me_balance_get() {
global $db;
diff --git a/web/ambap/wxpay.php b/web/ambap/wxpay.php
index 7e661bb..41a347c 100644
--- a/web/ambap/wxpay.php
+++ b/web/ambap/wxpay.php
@@ -57,6 +57,15 @@ class wxpay {
throw new \Exception('更新ap_cash_in失败:' . $db->error);
//sendusermsg($db, $orderrow['userid'], '集市通知', '买家已付款,请及时处理', '/work/ec/order_detail?id=' . $noid);
+ $updata = array();
+ $updata['cashietype'] = 10;
+ $updata['iemoney'] = $inmoney;
+ $updata['vuser'] = $userid;
+ $updata['name'] = '在线充值';
+ $updata['addtimes'] = tostamp();
+ $csql = new \ciy\sql('ap_cash_ie');
+ if ($db->insert($csql, $updata) === false)
+ throw new \Exception('新建消费收支失败:' . $db->error);
$updata = array();
$updata['mymoney'] = array('mymoney+' . $inmoney);
$updata['myinvmoney'] = array('myinvmoney+' . $inmoney);
diff --git a/web/api/thirdapi.php b/web/api/thirdapi.php
index e9399f0..a1d057f 100644
--- a/web/api/thirdapi.php
+++ b/web/api/thirdapi.php
@@ -3,7 +3,26 @@
namespace web\api;
class thirdapi {
- static function checkbadword($wordstr, $strict = 1) {
+ static function checkbadword_wx($content, $rsuser) {
+ $post = array();
+ $post['content'] = $content;
+ $post['version'] = 2;
+ $post['scene'] = 4;
+ $post['openid'] = $rsuser['wxminaid'];
+ $weixinapi = new \web\api\weixin(1);
+ //https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/sec-center/sec-check/msgSecCheck.html
+ $wxret = $weixinapi->call('https://api.weixin.qq.com/wxa/msg_sec_check?access_token={accesstoken}', $post);
+ if (is_string($wxret))
+ return errjson($wxret);
+ $json['code'] = 1;
+ if ($wxret['result']['suggest'] == 'pass')
+ return true;
+ $wxret['user'] = $rsuser;
+ savelogfile('wx_badword', json_encode($wxret));
+ return '有违禁词,不能发布';
+ }
+ static function checkbadword_luckycola($wordstr, $strict = 1) {
+ return true;
$http = new \ciy\http();
$post = array();
$post['ColaKey'] = 'V0txKKBrP8xzyN1761587699258qq6ro7N0sC'; //2025-12-27 1:54:59 https://luckycola.com.cn/public/dist/#/userCenter
diff --git a/web/api/weixin.php b/web/api/weixin.php
new file mode 100644
index 0000000..0326592
--- /dev/null
+++ b/web/api/weixin.php
@@ -0,0 +1,158 @@
+token = null;
+ $ret = gettoken($db, $tokenid);
+ if (is_string($ret))
+ return $this->err($ret);
+ $this->tokenid = $tokenid;
+ $this->token = $ret;
+ }
+ function err($ret, $log = '') {
+ savelogfile('WXPAY', $ret . $log);
+ return $ret;
+ }
+ public function call($url, $post = null, $isbinary = false) {
+ if (!$this->token)
+ return 'token不存在';
+ if (strpos($url, '{accesstoken}') !== false) {
+ $ret = $this->getaccesstoken();
+ if (is_string($ret))
+ return $ret;
+ $url = str_replace('{accesstoken}', $ret['accesstoken'], $url);
+ }
+ if (strpos($url, '{appid}') !== false)
+ $url = str_replace('{appid}', $this->token['appid'], $url);
+ if (strpos($url, '{appsecret}') !== false)
+ $url = str_replace('{appsecret}', $this->token['appsecret'], $url);
+
+ $http = new \ciy\http();
+ $http->set_headeronce('Content-Type', 'application/json');
+ $http->set_headeronce('Accept', 'application/json');
+ if (is_array($post))
+ $post = json_encode($post, JSON_UNESCAPED_UNICODE);
+ $http->request($url, $post);
+ $statcode = $http->get_statcode();
+ if ($statcode != 200 && $statcode != 204)
+ return $this->err('微信服务器无法连接,错误码:' . $statcode);
+ $result = $http->get_data();
+ if ($isbinary) {
+ if (@$result[0] != '{')
+ return array('bin' => $result);
+ }
+ $json = json_decode($result, true);
+ if ($json === null)
+ return $this->err('微信服务器返回数据失败', $result);
+ if (isset($json['errcode']) && $json['errcode'] != 0)
+ return $this->err('微信服务器返回错误:' . @$json['errmsg']);
+ return $json;
+ }
+ public function refund($param) { //退款
+ $result = $this->certcall('https://api.mch.weixin.qq.com', '/v3/refund/domestic/refunds', $param);
+ if (is_string($result))
+ return $result;
+ return $result;
+ }
+ public function transfer($param) { //提现
+ $param['appid'] = $this->token['appid'];
+ $result = $this->certcall('https://api.mch.weixin.qq.com', '/v3/fund-app/mch-transfer/transfer-bills', $param);
+ if (is_string($result))
+ return $result;
+ $result['mchid'] = $this->token['mchid'];
+ $result['appid'] = $this->token['appid'];
+ return $result;
+ }
+ public function pay($param) { //支付
+ $param['appid'] = $this->token['appid'];
+ $param['mchid'] = $this->token['mchid'];
+ $result = $this->certcall('https://api.mch.weixin.qq.com', '/v3/pay/transactions/jsapi', $param);
+ if (is_string($result))
+ return $result;
+
+ $timestamp = time() . '';
+ $nonce = uniqid() . uniqid();
+ $pkey = openssl_pkey_get_private(file_get_contents($this->token['pem_path']));
+ $message = $this->token['appid'] . "\n" . $timestamp . "\n" . $nonce . "\nprepay_id=" . $result['prepay_id'] . "\n";
+
+ openssl_sign($message, $raw_sign, $pkey, 'sha256WithRSAEncryption');
+ $sign = base64_encode($raw_sign);
+
+ $ret['appId'] = $this->token['appid'];
+ $ret['timeStamp'] = $timestamp;
+ $ret['nonceStr'] = $nonce;
+ $ret['package'] = 'prepay_id=' . $result['prepay_id'];
+ $ret['signType'] = 'RSA';
+ $ret['paySign'] = $sign;
+ return $ret;
+ }
+ private function certcall($domain, $url, $post) {
+ if (!file_exists($this->token['pem_path']))
+ return $this->err('证书文件不存在', $this->token['pem_path']);
+ $timestamp = time() . '';
+ $nonce = uniqid() . uniqid();
+ $post = json_encode($post, JSON_UNESCAPED_UNICODE);
+ $message = "POST\n" . $url . "\n" . $timestamp . "\n" . $nonce . "\n" . $post . "\n";
+ $pkey = openssl_pkey_get_private(file_get_contents($this->token['pem_path']));
+ openssl_sign($message, $raw_sign, $pkey, 'sha256WithRSAEncryption');
+ $sign = base64_encode($raw_sign);
+ $token = 'mchid="' . $this->token['mchid'] . '",nonce_str="' . $nonce . '",timestamp="' . $timestamp . '",serial_no="' . $this->token['pem_no'] . '",signature="' . $sign . '"';
+ $http = new \ciy\http();
+ $http->set_headeronce('Content-Type', 'application/json');
+ $http->set_headeronce('Accept', 'application/json');
+ $http->set_headeronce('Authorization', 'WECHATPAY2-SHA256-RSA2048 ' . $token);
+ $http->request($domain . $url, $post);
+ $statcode = $http->get_statcode();
+ if ($statcode == 200 || $statcode == 204) {
+ $result = $http->get_data();
+ $json = json_decode($result, true);
+ if ($json === null)
+ return array('code' => 1);
+ if (isset($json['message']))
+ return $this->err('微信服务器返回错误:' . $json['message']);
+ $json['code'] = 1;
+ return $json;
+ } else {
+ $res['errmsg'] = 1;
+ $result = $http->get_data();
+ $json = json_decode($result, true);
+ if ($json === null)
+ return $this->err('微信服务器无法连接pay', $result);
+ if (isset($json['message']))
+ return $this->err('微信服务器返回错误:' . $json['message']);
+ return $this->err('微信服务器返回json:' . $result);
+ }
+ }
+ private function getaccesstoken() {
+ global $db;
+ if ($this->token['exptimes'] > time())
+ return array('accesstoken' => $this->token['accesstoken']);
+ $http = new \ciy\http();
+ $http->set_headeronce('Content-Type', 'application/json');
+ $http->set_headeronce('Accept', 'application/json');
+ $http->request('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $this->token['appid'] . '&secret=' . $this->token['appsecret']);
+ $result = $http->get_data();
+ $json = json_decode($result, true);
+ if ($json === null)
+ return $this->err('微信服务器无法连接token', $result);
+ if (toint(@$json['errcode']) != 0)
+ return $this->err($json['errmsg']);
+ $accesstoken = @$json['access_token'];
+ if (empty($accesstoken))
+ return $this->err('微信token授权失败', $result);
+ $exptimes = time() + toint($json['expires_in']);
+ $updata = array();
+ $updata['accesstoken'] = $accesstoken;
+ $updata['exptimes'] = $exptimes;
+ $ret = settoken($db, $this->tokenid, $updata);
+ if (is_string($ret))
+ return $this->err($ret);
+ return array('accesstoken' => $accesstoken);
+ }
+}
diff --git a/web/jscss/ciycmp2.js b/web/jscss/ciycmp2.js
index 55810ea..2269002 100644
--- a/web/jscss/ciycmp2.js
+++ b/web/jscss/ciycmp2.js
@@ -40,33 +40,50 @@ ciyfn.markdown = function (markdown) {
}
var cr = mds[m].substring(1, 2).toLowerCase();
if (mds[m].substring(0, 5) == '#####') {
- if (mds[m].substring(5, 6) == '1')
+ oladd(4, titnum);
+ if (mds[m].substring(5, 6) == '.')
html += '
' + olnum(4, titnum, '、') + convertcode(mds[m].substring(6)) + '
';
+ else if (mds[m].substring(5, 6) == ':')
+ 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')
+ oladd(3, titnum);
+ if (mds[m].substring(4, 5) == '.')
html += '
' + olnum(3, titnum, '、') + convertcode(mds[m].substring(5)) + '
';
+ else if (mds[m].substring(4, 5) == ':')
+ html += '
' + olnum(3, titnum, ' ') + convertcode(mds[m].substring(5)) + '
';
else
html += '
' + convertcode(mds[m].substring(4)) + '
';
} else if (mds[m].substring(0, 3) == '###') {
- if (mds[m].substring(3, 4) == '1')
+ oladd(2, titnum);
+ if (mds[m].substring(3, 4) == '.')
html += '
' + olnum(2, titnum, '、') + convertcode(mds[m].substring(4)) + '
';
+ else if (mds[m].substring(3, 4) == ':')
+ 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')
+ oladd(1, titnum);
+ if (mds[m].substring(2, 3) == '.')
html += '
' + olnum(1, titnum, '、') + convertcode(mds[m].substring(3)) + '
';
+ else if (mds[m].substring(2, 3) == ':')
+ 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].substr(1)) + '
';
+ } else {
+ oladd(0, titnum);
+ if (cr == 'c')
+ html += '
' + convertcode(mds[m].substring(2)) + '
';
+ else if (cr == 'r')
+ html += '
' + convertcode(mds[m].substring(2)) + '
';
+ else if (cr == '.')
+ html += '
' + olnum(0, titnum, '、') + convertcode(mds[m].substring(2)) + '
';
+ else if (cr == ':')
+ html += '
' + olnum(0, titnum, ' ') + convertcode(mds[m].substring(2)) + '
';
+ else
+ html += '
' + convertcode(mds[m].substr(1)) + '
';
+ }
} else if (mds[m][0] == '@') {//c居中,r靠右
if (ispvs == 2)
html += '';
@@ -76,7 +93,7 @@ ciyfn.markdown = function (markdown) {
html += '
' + convertcode(mds[m].substring(2)) + '
';
else if (cr == 'r')
html += '
' + convertcode(mds[m].substring(2)) + '
';
- else if (cr == '1') {
+ else if (cr == '.') {
if (!isol) {
isol = true;
html += '
';
@@ -155,11 +172,12 @@ ciyfn.markdown = function (markdown) {
html += '
';
}
return html;
- function olnum(idx, olnum, end) {
- console.log(idx, olnum, end);
+ function oladd(idx, olnum) {
olnum[idx]++;
for (var i = idx + 1; i < olnum.length; i++)
olnum[i] = 0;
+ }
+ function olnum(idx, olnum, end) {
for (var i = 0; i <= idx; i++) {
if (olnum[i] == 0)
continue;
@@ -754,7 +772,7 @@ ciycmpfunc.ciymap = function (opn) {
opn.initevent = opn.initevent || opn.dom.hasattr('initevent');
opn.bet = toint(opn.bet || opn.dom.attr('bet') || 10000000);
opn.mapkey = opn.mapkey || opn.dom.hasattr('mapkey');
- if(opn.bet < 1)
+ if (opn.bet < 1)
opn.bet = 1;
var html = '';
html += '
';
@@ -767,7 +785,7 @@ ciycmpfunc.ciymap = function (opn) {
var showbtndom = opn.dom.children(2);
var showspandom = opn.dom.children(3);
function caldectoint(dec) {
- if(opn.bet <= 1)
+ if (opn.bet <= 1)
return dec;
return toint(dec * opn.bet);
}
@@ -1074,7 +1092,7 @@ ciycmpfunc.ciymarkdown = function (opn) {