Initial project files: BESCMS full source
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'type' => 'app',
|
||||
'name' => '微信',
|
||||
'author' => '迅睿云软件',
|
||||
'icon' => 'fa fa-weixin',
|
||||
|
||||
];
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
if (!method_exists(\Phpcmf\Service::M('table'), 'install_schema')) {
|
||||
return dr_return_data(0, '请先升级迅睿系统后再安装本插件');
|
||||
}
|
||||
|
||||
if (!dr_is_app('member')) {
|
||||
return dr_return_data(0, '需要先安装官方版的<用户系统>插件');
|
||||
}
|
||||
|
||||
return dr_return_data(1, 'ok');
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 缓存参数配置
|
||||
*
|
||||
* 模型名称 => 项目目录
|
||||
*
|
||||
**/
|
||||
|
||||
return [
|
||||
|
||||
'weixin' => 'weixin',
|
||||
|
||||
];
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
[
|
||||
'icon' => 'fa fa-weixin',
|
||||
'name' => dr_lang('转存为微信内容库'.WEIXIN_MORE_NAME),
|
||||
'uri' => 'weixin/content/module_add',
|
||||
'url' => 'javascript:;" onclick="dr_module_send_ajax(\''.dr_url('weixin/content/module_add', ['mid' => '{mid}']).'\')',
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
/*
|
||||
[
|
||||
'name' => '微信客服群发'.WEIXIN_MORE_NAME, // 站点权限是插件的链接名称
|
||||
'icon' => 'fa fa-weixin', // 图标
|
||||
'color' => 'green', // 颜色class red green blue
|
||||
'url' => 'javascript:layer.confirm(\'您确定要推送吗?\', { btn: [\'是\',\'否\'] }, function(){layer.closeAll(); dr_iframe_show(\'\', \''.SELF.'?s=weixin&c=send&m=show_add&mid={mid}&id={cid}\'); });', // 后台链接:对于点击的地址mid是模块目录,cid是内容id
|
||||
'uri' => 'weixin/send/add', // 对应的uri权限判断,后面章节会介绍权限写法
|
||||
'field' => '', // 统计数量的字段,填写模块内容的主表字段,只能填写int数字类型的字段
|
||||
],*/
|
||||
[
|
||||
'name' => '微信模板消息'.WEIXIN_MORE_NAME, // 站点权限是插件的链接名称
|
||||
'icon' => 'fa fa-weixin', // 图标
|
||||
'color' => 'red', // 颜色class red green blue
|
||||
'url' => 'javascript:layer.confirm(\'您确定要推送吗?\', { btn: [\'是\',\'否\'] }, function(){ layer.closeAll(); dr_bfb_submit(\'\',\'myform\', \''.SELF.'?s=weixin&c=sendtpl&m=show_add&mid={mid}&id={cid}\') });', // 后台链接:对于点击的地址mid是模块目录,cid是内容id
|
||||
'uri' => 'weixin/sendtpl/add', // 对应的uri权限判断,后面章节会介绍权限写法
|
||||
'field' => '', // 统计数量的字段,填写模块内容的主表字段,只能填写int数字类型的字段
|
||||
'check' => 'is_tpl_use',
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CSRF过滤白名单
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
'home' => [
|
||||
'weixin/home/index'
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
$more = \Phpcmf\Service::L('cache')->get_auth_data('more_weixin', 1);
|
||||
if (!$more) {
|
||||
$more = 1;
|
||||
} else {
|
||||
// 防止丢失
|
||||
\Phpcmf\Service::L('cache')->set_auth_data('more_weixin', $more, 1);
|
||||
}
|
||||
|
||||
if (isset($_GET['gzh_id']) && $_GET['gzh_id']) {
|
||||
$more = intval($_GET['gzh_id']);
|
||||
}
|
||||
|
||||
$data = \Phpcmf\Service::L('cache')->get_file('app_weixin', $more); // 配置
|
||||
if (!$data) {
|
||||
$more = 1;
|
||||
}
|
||||
|
||||
define('WEIXIN_MORE_ID', $more);
|
||||
define('WEIXIN_MORE_NAME', $data ? '【'.$data.'】' : '');
|
||||
|
||||
\Phpcmf\Hooks::on('cms_init', function() {
|
||||
// 微信中访问网站时,未登录时直接授权微信登录
|
||||
if (IS_API
|
||||
|| IS_API_HTTP
|
||||
|| in_array(APP_DIR, ['weixin', 'api', 'member'])
|
||||
|| in_array(\Phpcmf\Service::L('Router')->class, ['register', 'login', 'api', 'go'])) {
|
||||
return;
|
||||
} elseif (!IS_MEMBER && !\Phpcmf\Service::C()->uid) {
|
||||
\Phpcmf\Service::C()->init_file('weixin');
|
||||
$config = \Phpcmf\Service::M('Weixin', 'Weixin')->get_config('config'); // 配置
|
||||
if (isset($config['autologin']) && $config['autologin']
|
||||
&& strpos((string)$_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')) {
|
||||
// 公众号内自动登陆
|
||||
if ($config['autologin'] == 1) {
|
||||
dr_redirect(SITE_URL.'index.php?s=weixin&c=go&url='.urlencode(FC_NOW_URL));
|
||||
} else {
|
||||
// 提示绑定:静默获取openid,已绑定则直接登录,未绑定则提示
|
||||
$openid = \Phpcmf\Service::L('input')->get_cookie('weixin_gzh_openid');
|
||||
if (!$openid) {
|
||||
dr_redirect(SITE_URL.'index.php?s=weixin&c=go&m=check&url='.urlencode(FC_NOW_URL));
|
||||
} else {
|
||||
$uid = 0;
|
||||
$user = \Phpcmf\Service::M()->table(weixin_wxtable('user'))->where('openid', $openid)->getRow();
|
||||
$oauth = \Phpcmf\Service::M()->table('member_oauth')->where('oauth', 'wechat')->where('oid', $openid)->getRow();
|
||||
if (!$user || !$user['uid']) {
|
||||
if ($oauth) {
|
||||
$uid = $oauth['uid'];
|
||||
}
|
||||
} else {
|
||||
$uid = $user['uid'];
|
||||
}
|
||||
if ($uid) {
|
||||
$member = \Phpcmf\Service::M('member')->member_info($uid);
|
||||
if ($member) {
|
||||
$user && \Phpcmf\Service::M()->table(weixin_wxtable('user'))->update($user['id'], ['uid' => $uid]);
|
||||
$oauth && \Phpcmf\Service::M()->table('member_oauth')->update($oauth['id'], ['uid' => $uid]);
|
||||
\Phpcmf\Service::M('member')->save_cookie($member, 1);
|
||||
XR_C()->_msg(1, dr_lang('自动登录成功'), FC_NOW_URL);
|
||||
} else {
|
||||
$user && \Phpcmf\Service::M()->table(weixin_wxtable('user'))->update($user['id'], ['uid' => 0]);
|
||||
$oauth && \Phpcmf\Service::M()->table('member_oauth')->update($oauth['id'], ['uid' => 0]);
|
||||
$uid = 0;
|
||||
XR_C()->_msg(0, dr_lang('账号不存在,解绑成功'));
|
||||
}
|
||||
}
|
||||
if (!$uid) {
|
||||
$text = $config['bang_text'] ? $config['bang_text'] : '您还没有绑定本站账号,是否立即绑定?';
|
||||
define('MY_WEIXIN_BIND_URL', SITE_URL.'index.php?s=weixin&c=go&url='.urlencode(FC_NOW_URL));
|
||||
define('MY_WEIXIN_BIND_TEXT', $text);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
\Phpcmf\Hooks::on('cms_view_end', function() {
|
||||
|
||||
if (!defined('MY_WEIXIN_BIND_URL') || !MY_WEIXIN_BIND_URL) {
|
||||
return;
|
||||
} elseif (IS_AJAX || IS_API_HTTP || defined('SC_HTML_FILE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cookieName = 'weixin_bind_prompt';
|
||||
$today = date('Ymd', SYS_TIME);
|
||||
if (\Phpcmf\Service::L('input')->get_cookie($cookieName) == $today) {
|
||||
return;
|
||||
}
|
||||
\Phpcmf\Service::L('input')->set_cookie($cookieName, $today, 86400);
|
||||
|
||||
$url = MY_WEIXIN_BIND_URL;
|
||||
$text = json_encode(MY_WEIXIN_BIND_TEXT, JSON_UNESCAPED_UNICODE);
|
||||
$script = '<script type="text/javascript">'
|
||||
.'(function(){'
|
||||
.'var _k='.json_encode($cookieName).',_d='.json_encode($today).';'
|
||||
.'if(document.cookie.indexOf(_k+"="+_d)>=0){return;}'
|
||||
.'document.cookie=_k+"="+_d+";path=/;max-age=86400";'
|
||||
.'if(typeof layer==="undefined"){return;}'
|
||||
.'layer.confirm('.$text.',{icon:3,shade:0.3,title:dr_lang("提示"),btn:[dr_lang("确定"),dr_lang("取消")]},function(index){'
|
||||
.'layer.close(index);window.location.href='.json_encode($url).';'
|
||||
.'});'
|
||||
.'})();'
|
||||
.'</script>';
|
||||
|
||||
if (ob_get_level() > 0) {
|
||||
$html = ob_get_clean();
|
||||
if (stripos($html, '</body>') !== false) {
|
||||
$html = preg_replace('/<\/body>/i', $script.'</body>', $html, 1);
|
||||
} else {
|
||||
$html .= $script;
|
||||
}
|
||||
ob_start();
|
||||
echo $html;
|
||||
} else {
|
||||
echo $script;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,460 @@
|
||||
<?php
|
||||
|
||||
|
||||
$this->weixin = $this->get_cache('weixin'.(WEIXIN_MORE_ID > 1 ? '_more_'.WEIXIN_MORE_ID : '')); // 配置
|
||||
|
||||
// 获取微信表名
|
||||
function weixin_wxtable($name, $wxid = WEIXIN_MORE_ID) {
|
||||
$prefix = $wxid > 1 ? 'more_'.$wxid.'_' : '';
|
||||
if ($name != 'weixin') {
|
||||
$name = 'weixin_'.$name;
|
||||
}
|
||||
return $prefix.$name;
|
||||
}
|
||||
|
||||
// 获取access_token
|
||||
function weixin_get_access_token($data = []) {
|
||||
|
||||
if (is_array($data) && $data) {
|
||||
$config = $data;
|
||||
} elseif ($data == 'update') {
|
||||
// 重写写入
|
||||
$config = \Phpcmf\Service::C()->weixin['account'];
|
||||
} else {
|
||||
$cache_data = \Phpcmf\Service::L('cache')->get_auth_data('weixin_access_token_'.WEIXIN_MORE_ID, 1, 2200);
|
||||
if (is_array($cache_data)) {
|
||||
if ($cache_data['endtime'] && $cache_data['endtime'] > SYS_TIME && $cache_data['access_token']) {
|
||||
return dr_return_data(1, $cache_data['access_token']);
|
||||
} elseif (!\Phpcmf\Service::C()->weixin['account']) {
|
||||
return dr_return_data(0, '未配置微信接入参数');
|
||||
}
|
||||
}
|
||||
$config = \Phpcmf\Service::C()->weixin['account'];
|
||||
}
|
||||
if (!$config['appid'] || !$config['appsecret']) {
|
||||
return dr_return_data(0, 'appid或者appsecret没填写');
|
||||
}
|
||||
|
||||
$result = wx_get_https_json_data('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$config['appid'].'&secret='.$config['appsecret']);
|
||||
if (!$result['code']) {
|
||||
return dr_return_data(0, 'AccessToken:'.$result['msg']);
|
||||
} elseif (!$result['data']['access_token']) {
|
||||
return dr_return_data(0, 'AccessToken为空,请重试');
|
||||
}
|
||||
|
||||
$result['data']['endtime'] = SYS_TIME + 2360;
|
||||
$rt = \Phpcmf\Service::L('cache')->set_auth_data('weixin_access_token_'.WEIXIN_MORE_ID, $result['data'], 1);
|
||||
if (!$rt) {
|
||||
return dr_return_data(0, 'AccessToken:/cache/authcode/目录不可写,文件写入失败');
|
||||
}
|
||||
|
||||
return dr_return_data(1, $result['data']['access_token']);
|
||||
}
|
||||
|
||||
// 小程序获取access_token
|
||||
function xcx_get_access_token($data = []) {
|
||||
|
||||
if (is_array($data) && $data) {
|
||||
$config = $data;
|
||||
} elseif ($data == 'update') {
|
||||
// 重写写入
|
||||
$config = \Phpcmf\Service::C()->weixin['xcx'];
|
||||
} else {
|
||||
$cache_data = \Phpcmf\Service::L('cache')->get_auth_data('xcx_access_token_'.WEIXIN_MORE_ID, 1, 2200);
|
||||
if (is_array($cache_data)) {
|
||||
if ($cache_data['endtime'] && $cache_data['endtime'] > SYS_TIME && $cache_data['access_token']) {
|
||||
return dr_return_data(1, $cache_data['access_token']);
|
||||
} elseif (!\Phpcmf\Service::C()->weixin['xcx']) {
|
||||
return dr_return_data(0, '未配置小程序接入参数');
|
||||
}
|
||||
}
|
||||
$config = \Phpcmf\Service::C()->weixin['xcx'];
|
||||
}
|
||||
if (!$config['appid'] || !$config['appsecret']) {
|
||||
return dr_return_data(0, 'appid或者appsecret没填写');
|
||||
}
|
||||
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $config['appid'] . '&secret=' . $config['appsecret'] . '';
|
||||
$result = wx_get_https_json_data($url);
|
||||
if (!$result['code']) {
|
||||
return dr_return_data(0, 'AccessToken:'.$result['msg']);
|
||||
} elseif (!$result['data']['access_token']) {
|
||||
return dr_return_data(0, 'AccessToken为空,请重试');
|
||||
}
|
||||
|
||||
$result['data']['endtime'] = SYS_TIME + 2360;
|
||||
$rt = \Phpcmf\Service::L('cache')->set_auth_data('xcx_access_token_'.WEIXIN_MORE_ID, $result['data'], 1);
|
||||
if (!$rt) {
|
||||
return dr_return_data(0, 'AccessToken:/cache/authcode/目录不可写,文件写入失败');
|
||||
}
|
||||
|
||||
return dr_return_data(1, $result['data']['access_token']);
|
||||
}
|
||||
|
||||
function ihttp_request($url, $post = '', $extra = array(), $timeout = 60) {
|
||||
$urlset = parse_url($url);
|
||||
if (empty($urlset['path'])) {
|
||||
$urlset['path'] = '/';
|
||||
}
|
||||
if (!empty($urlset['query'])) {
|
||||
$urlset['query'] = "?{$urlset['query']}";
|
||||
}
|
||||
if (empty($urlset['port'])) {
|
||||
$urlset['port'] = $urlset['scheme'] == 'https' ? '443' : '80';
|
||||
}
|
||||
if (strexists($url, 'https://') && !extension_loaded('openssl')) {
|
||||
if (!extension_loaded("openssl")) {
|
||||
return dr_return_data(0, ' 请开启您PHP环境的openssl');
|
||||
}
|
||||
}
|
||||
if (function_exists('curl_init') && function_exists('curl_exec')) {
|
||||
$ch = curl_init();
|
||||
if (!empty($extra['ip'])) {
|
||||
$extra['Host'] = $urlset['host'];
|
||||
$urlset['host'] = $extra['ip'];
|
||||
unset($extra['ip']);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_URL, $urlset['scheme'] . '://' . $urlset['host'] . ($urlset['port'] == '80' ? '' : ':' . $urlset['port']) . $urlset['path'] . $urlset['query']);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 1);
|
||||
//@curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
|
||||
if ($post) {
|
||||
if (is_array($post)) {
|
||||
$filepost = false;
|
||||
foreach ($post as $name => &$value) {
|
||||
if (version_compare(phpversion(), '5.6') >= 0 && substr($value, 0, 1) == '@') {
|
||||
$value = new CURLFile(ltrim($value, '@'));
|
||||
if (version_compare(phpversion(), '7.4.3') == 0) {
|
||||
return dr_return_data(0, ' 本功能无法在php7.4.3中运行,请升级到php7.4.3以后的版本');
|
||||
}
|
||||
}
|
||||
if ((is_string($value) && substr($value, 0, 1) == '@') || (class_exists('CURLFile') && $value instanceof CURLFile)) {
|
||||
$filepost = true;
|
||||
}
|
||||
}
|
||||
if (!$filepost) {
|
||||
$post = http_build_query($post);
|
||||
}
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
||||
}
|
||||
if (!empty($GLOBALS['_W']['config']['setting']['proxy'])) {
|
||||
$urls = parse_url($GLOBALS['_W']['config']['setting']['proxy']['host']);
|
||||
if (!empty($urls['host'])) {
|
||||
curl_setopt($ch, CURLOPT_PROXY, "{$urls['host']}:{$urls['port']}");
|
||||
$proxytype = 'CURLPROXY_' . strtoupper($urls['scheme']);
|
||||
if (!empty($urls['scheme']) && defined($proxytype)) {
|
||||
curl_setopt($ch, CURLOPT_PROXYTYPE, constant($proxytype));
|
||||
} else {
|
||||
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
|
||||
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
|
||||
}
|
||||
if (!empty($GLOBALS['_W']['config']['setting']['proxy']['auth'])) {
|
||||
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $GLOBALS['_W']['config']['setting']['proxy']['auth']);
|
||||
}
|
||||
}
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_SSLVERSION, 1);
|
||||
if (defined('CURL_SSLVERSION_TLSv1')) {
|
||||
curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1');
|
||||
if (!empty($extra) && is_array($extra)) {
|
||||
$headers = array();
|
||||
foreach ($extra as $opt => $value) {
|
||||
if (strexists($opt, 'CURLOPT_')) {
|
||||
curl_setopt($ch, constant($opt), $value);
|
||||
} elseif (is_numeric($opt)) {
|
||||
curl_setopt($ch, $opt, $value);
|
||||
} else {
|
||||
$headers[] = "{$opt}: {$value}";
|
||||
}
|
||||
}
|
||||
if (!empty($headers)) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
}
|
||||
}
|
||||
$data = curl_exec($ch);
|
||||
$status = curl_getinfo($ch);
|
||||
$errno = curl_errno($ch);
|
||||
$error = curl_error($ch);
|
||||
curl_close($ch);
|
||||
if ($errno || empty($data)) {
|
||||
return dr_return_data(0, '同步出错:'.$error);
|
||||
} else {
|
||||
return ihttp_response_parse($data);
|
||||
}
|
||||
}
|
||||
$method = empty($post) ? 'GET' : 'POST';
|
||||
$fdata = "{$method} {$urlset['path']}{$urlset['query']} HTTP/1.1\r\n";
|
||||
$fdata .= "Host: {$urlset['host']}\r\n";
|
||||
if (function_exists('gzdecode')) {
|
||||
$fdata .= "Accept-Encoding: gzip, deflate\r\n";
|
||||
}
|
||||
$fdata .= "Connection: close\r\n";
|
||||
if (!empty($extra) && is_array($extra)) {
|
||||
foreach ($extra as $opt => $value) {
|
||||
if (!strexists($opt, 'CURLOPT_')) {
|
||||
$fdata .= "{$opt}: {$value}\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$body = '';
|
||||
if ($post) {
|
||||
if (is_array($post)) {
|
||||
$body = http_build_query($post);
|
||||
} else {
|
||||
$body = urlencode($post);
|
||||
}
|
||||
$fdata .= 'Content-Length: ' . strlen($body) . "\r\n\r\n{$body}";
|
||||
} else {
|
||||
$fdata .= "\r\n";
|
||||
}
|
||||
if ($urlset['scheme'] == 'https') {
|
||||
$fp = fsockopen('ssl://' . $urlset['host'], $urlset['port'], $errno, $error);
|
||||
} else {
|
||||
$fp = fsockopen($urlset['host'], $urlset['port'], $errno, $error);
|
||||
}
|
||||
stream_set_blocking($fp, true);
|
||||
stream_set_timeout($fp, $timeout);
|
||||
if (!$fp) {
|
||||
return dr_return_data(0, '同步出错:'.$error);
|
||||
} else {
|
||||
fwrite($fp, $fdata);
|
||||
$content = '';
|
||||
while (!feof($fp))
|
||||
$content .= fgets($fp, 512);
|
||||
fclose($fp);
|
||||
return ihttp_response_parse($content, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ihttp_response_parse($data, $chunked = false) {
|
||||
$rlt = array();
|
||||
$headermeta = explode('HTTP/', $data);
|
||||
if (count($headermeta) > 2) {
|
||||
$data = 'HTTP/' . array_pop($headermeta);
|
||||
}
|
||||
$pos = strpos($data, "\r\n\r\n");
|
||||
$split1[0] = substr($data, 0, $pos);
|
||||
$split1[1] = substr($data, $pos + 4, strlen($data));
|
||||
|
||||
$split2 = explode("\r\n", $split1[0], 2);
|
||||
preg_match('/^(\S+) (\S+) (.*)$/', $split2[0], $matches);
|
||||
$rlt['code'] = $matches[2];
|
||||
$rlt['status'] = $matches[3];
|
||||
$rlt['responseline'] = $split2[0];
|
||||
$header = explode("\r\n", $split2[1]);
|
||||
$isgzip = false;
|
||||
$ischunk = false;
|
||||
foreach ($header as $v) {
|
||||
$pos = strpos($v, ':');
|
||||
$key = substr($v, 0, $pos);
|
||||
$value = trim(substr($v, $pos + 1));
|
||||
if (is_array($rlt['headers'][$key])) {
|
||||
$rlt['headers'][$key][] = $value;
|
||||
} elseif (!empty($rlt['headers'][$key])) {
|
||||
$temp = $rlt['headers'][$key];
|
||||
unset($rlt['headers'][$key]);
|
||||
$rlt['headers'][$key][] = $temp;
|
||||
$rlt['headers'][$key][] = $value;
|
||||
} else {
|
||||
$rlt['headers'][$key] = $value;
|
||||
}
|
||||
if(!$isgzip && strtolower($key) == 'content-encoding' && strtolower($value) == 'gzip') {
|
||||
$isgzip = true;
|
||||
}
|
||||
if(!$ischunk && strtolower($key) == 'transfer-encoding' && strtolower($value) == 'chunked') {
|
||||
$ischunk = true;
|
||||
}
|
||||
}
|
||||
if($chunked && $ischunk) {
|
||||
$rlt['content'] = ihttp_response_parse_unchunk($split1[1]);
|
||||
} else {
|
||||
$rlt['content'] = $split1[1];
|
||||
}
|
||||
if($isgzip && function_exists('gzdecode')) {
|
||||
$rlt['content'] = gzdecode($rlt['content']);
|
||||
}
|
||||
|
||||
$rlt['meta'] = $data;
|
||||
if($rlt['code'] == '100') {
|
||||
return ihttp_response_parse($rlt['content']);
|
||||
}
|
||||
|
||||
|
||||
$data = json_decode($rlt['content'], true);
|
||||
if (!$data) {
|
||||
if($rlt['code'] != '200' && $rlt['status']) {
|
||||
return dr_return_data(0, $rlt['status']);
|
||||
}
|
||||
return dr_return_data(0, $rlt['content'].'不是一个有效的json数据');
|
||||
} elseif (isset($data['errcode']) && $data['errcode']) {
|
||||
return dr_return_data(0, '错误代码('.dr_weixin_error_msg($data['errcode']).'):'.$data['errmsg']);
|
||||
}
|
||||
|
||||
return dr_return_data(1, 'ok', $data);
|
||||
}
|
||||
|
||||
function strexists($string, $find) {
|
||||
return !(strpos($string, $find) === FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 通过code从工作平台获取openid机器access_token
|
||||
* @param string $code 微信跳转回来带上的code
|
||||
*
|
||||
* @return openid
|
||||
*/
|
||||
function weixin_GetOpenidFromMp($code)
|
||||
{
|
||||
$url = weixin_CreateOauthUrlForOpenid($code);
|
||||
//初始化curl
|
||||
$ch = curl_init();
|
||||
//设置超时
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,FALSE);
|
||||
curl_setopt($ch, CURLOPT_HEADER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
|
||||
//运行curl,结果以jason形式返回
|
||||
$res = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
//取出openid
|
||||
$data = json_decode($res,true);
|
||||
$openid = $data['openid'];
|
||||
return $openid;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 构造获取code的url连接
|
||||
* @param string $redirectUrl 微信服务器回跳的url,需要url编码
|
||||
*
|
||||
* @return 返回构造好的url
|
||||
*/
|
||||
function weixin_CreateOauthUrlForCode($redirectUrl)
|
||||
{
|
||||
|
||||
$wx = \Phpcmf\Service::C()->get_cache('weixin'.(WEIXIN_MORE_ID > 1 ? '_more_'.WEIXIN_MORE_ID : '')); // 配置
|
||||
$urlObj["appid"] = $wx['account']['appid'];
|
||||
$urlObj["redirect_uri"] = "$redirectUrl";
|
||||
$urlObj["response_type"] = "code";
|
||||
$urlObj["scope"] = "snsapi_base";
|
||||
$urlObj["state"] = "STATE"."#wechat_redirect";
|
||||
$bizString = weixin_ToUrlParams($urlObj);
|
||||
return "https://open.weixin.qq.com/connect/oauth2/authorize?".$bizString;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 构造获取open和access_toke的url地址
|
||||
* @param string $code,微信跳转带回的code
|
||||
*
|
||||
* @return 请求的url
|
||||
*/
|
||||
function weixin_CreateOauthUrlForOpenid($code)
|
||||
{
|
||||
$wx = \Phpcmf\Service::C()->get_cache('weixin'.(WEIXIN_MORE_ID > 1 ? '_more_'.WEIXIN_MORE_ID : '')); // 配置
|
||||
$urlObj["appid"] = $wx['account']['appid'];
|
||||
$urlObj["secret"] = $wx['account']['appsecret'];
|
||||
$urlObj["code"] = $code;
|
||||
$urlObj["grant_type"] = "authorization_code";
|
||||
$bizString = weixin_ToUrlParams($urlObj);
|
||||
return "https://api.weixin.qq.com/sns/oauth2/access_token?".$bizString;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 拼接签名字符串
|
||||
* @param array $urlObj
|
||||
*
|
||||
* @return 返回已经拼接好的字符串
|
||||
*/
|
||||
function weixin_ToUrlParams($urlObj)
|
||||
{
|
||||
$buff = "";
|
||||
foreach ($urlObj as $k => $v)
|
||||
{
|
||||
if($k != "sign"){
|
||||
$buff .= $k . "=" . $v . "&";
|
||||
}
|
||||
}
|
||||
|
||||
$buff = trim($buff, "&");
|
||||
return $buff;
|
||||
}
|
||||
|
||||
// 从url获取json数据
|
||||
function wx_get_https_json_data($url, $ct = 0) {
|
||||
|
||||
if (!$url) {
|
||||
return dr_return_data(0, 'url为空');
|
||||
}
|
||||
|
||||
$response = dr_catcher_data($url);
|
||||
$data = json_decode($response, true);
|
||||
if (!$data) {
|
||||
return dr_return_data(0, var_export($response, true).' 不是一个有效的json数据');
|
||||
} elseif (isset($data['errcode']) && $data['errcode']) {
|
||||
if ($data['errcode'] == '40001' && $ct == 0 && strpos($url, 'access_token=')) {
|
||||
// 重新获取token
|
||||
list($a, $b) = explode('access_token=', $url);
|
||||
if (strpos($b, '&') !== false) {
|
||||
list($b) = explode('&', $b);
|
||||
}
|
||||
$rt = weixin_get_access_token('update');
|
||||
if ($rt['code']) {
|
||||
return wx_get_https_json_data(str_replace($b, $rt['msg'], $url), 1);
|
||||
}
|
||||
}
|
||||
return dr_return_data(0, '错误代码('.$data['errcode'].'):'.$data['errmsg']);
|
||||
}
|
||||
|
||||
return dr_return_data(1, 'ok', $data);
|
||||
}
|
||||
|
||||
// 从url获取json数据
|
||||
function wx_post_https_json_data($url, $param = [], $ct = 0) {
|
||||
$rt = dr_post_json_data($url, json_encode($param, JSON_UNESCAPED_UNICODE));
|
||||
if ($rt['code']) {
|
||||
if (isset($rt['data']['errcode']) && $rt['data']['errcode']) {
|
||||
if ($rt['data']['errcode'] == '40001' && $ct == 0 && strpos($url, 'access_token=')) {
|
||||
// 重新获取token
|
||||
list($a, $b) = explode('access_token=', $url);
|
||||
if (strpos($b, '&') !== false) {
|
||||
list($b) = explode('&', $b);
|
||||
}
|
||||
$rt = weixin_get_access_token('update');
|
||||
if ($rt['code']) {
|
||||
return wx_post_https_json_data(str_replace($b, $rt['msg'], $url), $param, 1);
|
||||
}
|
||||
}
|
||||
return dr_return_data(0, '错误代码('.dr_weixin_error_msg($rt['data']['errcode']).'):'.$rt['data']['errmsg']);
|
||||
}
|
||||
}
|
||||
return $rt;
|
||||
}
|
||||
|
||||
// 微信端的错误码转
|
||||
function dr_weixin_error_msg($code) {
|
||||
if ($code == '40001') {
|
||||
// 清除掉token
|
||||
\Phpcmf\Service::L('cache')->del_auth_data('weixin_access_token_'.(WEIXIN_MORE_ID > 1 ? '_more_'.WEIXIN_MORE_ID : ''), 1);
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
$rt = \Phpcmf\Service::M('table')->install_schema([
|
||||
'tables' => [
|
||||
'app_weixin' => [
|
||||
'comment' => '多公众号表',
|
||||
'drop' => true,
|
||||
'fields' => [
|
||||
'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
|
||||
'name' => 'varchar(200) NOT NULL COMMENT \'公众号名称\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
],
|
||||
],
|
||||
'weixin' => [
|
||||
'comment' => '微信配置',
|
||||
'drop' => true,
|
||||
'fields' => [
|
||||
'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'Id\'',
|
||||
'name' => 'varchar(100) NOT NULL COMMENT \'表名称\'',
|
||||
'value' => 'text NOT NULL COMMENT \'字段配置项目\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'UNIQUE KEY `name` (`name`)',
|
||||
],
|
||||
],
|
||||
'weixin_follow' => [
|
||||
'comment' => '微信粉丝同步表',
|
||||
'drop' => true,
|
||||
'fields' => [
|
||||
'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
|
||||
'openid' => 'varchar(255) NOT NULL COMMENT \'唯一id\'',
|
||||
'status' => 'tinyint(1) NOT NULL',
|
||||
'uid' => 'int(10) NOT NULL',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `uid` (`uid`)',
|
||||
'KEY `status` (`status`)',
|
||||
'KEY `openid` (`openid`)',
|
||||
],
|
||||
],
|
||||
'weixin_group' => [
|
||||
'comment' => '微信粉丝分组表',
|
||||
'drop' => true,
|
||||
'fields' => [
|
||||
'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
|
||||
'tag' => 'int(10) NOT NULL COMMENT \'微信TagId\'',
|
||||
'name' => 'varchar(100) NOT NULL COMMENT \'标签名称\'',
|
||||
'count' => 'int(10) NOT NULL COMMENT \'粉丝人数\'',
|
||||
'groupid' => 'int(10) NOT NULL COMMENT \'用户组id\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `tag` (`tag`)',
|
||||
'KEY `groupid` (`groupid`)',
|
||||
],
|
||||
],
|
||||
'weixin_user' => [
|
||||
'comment' => '微信粉丝表',
|
||||
'drop' => true,
|
||||
'fields' => [
|
||||
'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
|
||||
'uid' => 'int(10) unsigned DEFAULT NULL COMMENT \'会员id\'',
|
||||
'username' => 'varchar(100) NOT NULL COMMENT \'会员名\'',
|
||||
'groupids' => 'varchar(100) NOT NULL COMMENT \'标签组id值\'',
|
||||
'openid' => 'varchar(50) NOT NULL COMMENT \'唯一id\'',
|
||||
'nickname' => 'varchar(255) NOT NULL COMMENT \'微信昵称\'',
|
||||
'sex' => 'tinyint(1) unsigned DEFAULT NULL COMMENT \'性别\'',
|
||||
'city' => 'varchar(30) DEFAULT NULL COMMENT \'城市\'',
|
||||
'country' => 'varchar(30) DEFAULT NULL COMMENT \'国家\'',
|
||||
'province' => 'varchar(30) DEFAULT NULL COMMENT \'省\'',
|
||||
'headimgurl' => 'varchar(255) DEFAULT NULL COMMENT \'头像地址\'',
|
||||
'unionid' => 'varchar(255) DEFAULT NULL COMMENT \'绑定账号\'',
|
||||
'remark' => 'varchar(255) DEFAULT NULL COMMENT \'对粉丝的备注\'',
|
||||
'subscribe' => 'int(10) unsigned NOT NULL COMMENT \'关注时间\'',
|
||||
'subscribe_time' => 'int(10) unsigned NOT NULL COMMENT \'最近时间\'',
|
||||
'content' => 'text NOT NULL COMMENT \'字段\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'UNIQUE KEY `openid` (`openid`)',
|
||||
'KEY `subscribe` (`subscribe`)',
|
||||
'KEY `subscribe_time` (`subscribe_time`)',
|
||||
],
|
||||
],
|
||||
'weixin_menu' => [
|
||||
'comment' => '微信自定义菜单表',
|
||||
'drop' => true,
|
||||
'fields' => [
|
||||
'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
|
||||
'pid' => 'int(10) NOT NULL COMMENT \'父id\'',
|
||||
'name' => 'varchar(255) NOT NULL COMMENT \'菜单名称\'',
|
||||
'type' => 'varchar(20) NOT NULL COMMENT \'菜单类型\'',
|
||||
'value' => 'text NOT NULL COMMENT \'执行值\'',
|
||||
'displayorder' => 'int(10) NOT NULL COMMENT \'排序值\'',
|
||||
'gid' => 'int(10) NOT NULL COMMENT \'标签组id\'',
|
||||
'menuid' => 'int(10) NOT NULL COMMENT \'个性菜单id\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `pid` (`pid`)',
|
||||
'KEY `displayorder` (`displayorder`)',
|
||||
'KEY `gid` (`gid`)',
|
||||
],
|
||||
],
|
||||
'weixin_content' => [
|
||||
'comment' => '微信素材内容表',
|
||||
'drop' => true,
|
||||
'fields' => [
|
||||
'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
|
||||
'tid' => 'varchar(20) NOT NULL COMMENT \'素材类型\'',
|
||||
'title' => 'varchar(255) NOT NULL COMMENT \'标题\'',
|
||||
'content' => 'text NOT NULL COMMENT \'内容值数组\'',
|
||||
'media_id' => 'varchar(255) NOT NULL COMMENT \'微信media_id\'',
|
||||
'publish_id' => 'varchar(255) NOT NULL COMMENT \'publish_id\'',
|
||||
'article_id' => 'varchar(255) NOT NULL COMMENT \'article_id\'',
|
||||
'status' => 'tinyint(1) unsigned DEFAULT NULL COMMENT \'\'',
|
||||
'nums' => 'tinyint(2) unsigned DEFAULT NULL COMMENT \'\'',
|
||||
'inputtime' => 'int(10) NOT NULL COMMENT \'录入时间\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `inputtime` (`inputtime`)',
|
||||
],
|
||||
],
|
||||
'weixin_media_id' => [
|
||||
'comment' => '微信素材多媒体id表',
|
||||
'drop' => true,
|
||||
'fields' => [
|
||||
'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
|
||||
'file' => 'varchar(255) NOT NULL COMMENT \'文件编码\'',
|
||||
'media_id' => 'varchar(255) NOT NULL COMMENT \'微信media_id\'',
|
||||
'url' => 'varchar(255) NOT NULL COMMENT \'对应地址\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `file` (`file`)',
|
||||
],
|
||||
],
|
||||
'weixin_send' => [
|
||||
'comment' => '微信客服消息发布表',
|
||||
'drop' => true,
|
||||
'fields' => [
|
||||
'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
|
||||
'cid' => 'int(10) NOT NULL COMMENT \'cid\'',
|
||||
'openid' => 'varchar(255) NOT NULL COMMENT \'openid\'',
|
||||
'content' => 'text NOT NULL COMMENT \'内容值数组\'',
|
||||
'status' => 'tinyint(1) unsigned DEFAULT NULL COMMENT \'状态1成功,2失败,0未发送\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `cid` (`cid`)',
|
||||
],
|
||||
],
|
||||
'weixin_message' => [
|
||||
'comment' => '微信消息记录表',
|
||||
'drop' => true,
|
||||
'fields' => [
|
||||
'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
|
||||
'tid' => 'varchar(20) NOT NULL COMMENT \'消息类型\'',
|
||||
'userid' => 'int(10) NOT NULL COMMENT \'用户id\'',
|
||||
'openid' => 'varchar(255) NOT NULL COMMENT \'openid\'',
|
||||
'nickname' => 'varchar(255) NOT NULL COMMENT \'昵称\'',
|
||||
'headimgurl' => 'varchar(255) NOT NULL COMMENT \'头像\'',
|
||||
'content' => 'text NOT NULL COMMENT \'消息内容\'',
|
||||
'file' => 'text NOT NULL COMMENT \'xiazia\'',
|
||||
'status' => 'tinyint(1) unsigned DEFAULT NULL COMMENT \'状态1更新,0未更新\'',
|
||||
'inputtime' => 'int(10) NOT NULL COMMENT \'录入时间\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `openid` (`openid`)',
|
||||
'KEY `userid` (`userid`)',
|
||||
'KEY `nickname` (`nickname`)',
|
||||
'KEY `inputtime` (`inputtime`)',
|
||||
],
|
||||
],
|
||||
'weixin_template' => [
|
||||
'comment' => '微信模板消息记录表',
|
||||
'drop' => true,
|
||||
'fields' => [
|
||||
'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
|
||||
'title' => 'varchar(200) NOT NULL COMMENT \'主题\'',
|
||||
'groupid' => 'int(10) NOT NULL COMMENT \'发送标签组\'',
|
||||
'counts' => 'int(10) NOT NULL COMMENT \'发送数\'',
|
||||
'content' => 'text NOT NULL COMMENT \'消息内容\'',
|
||||
'template' => 'varchar(200) NOT NULL COMMENT \'模板ID\'',
|
||||
'url' => 'varchar(200) NOT NULL COMMENT \'对应url\'',
|
||||
'color' => 'varchar(200) NOT NULL COMMENT \'主题颜色\'',
|
||||
'inputtime' => 'int(10) NOT NULL COMMENT \'录入时间\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `inputtime` (`inputtime`)',
|
||||
],
|
||||
],
|
||||
'weixin_reply' => [
|
||||
'comment' => '微信素材自动回复表',
|
||||
'drop' => true,
|
||||
'fields' => [
|
||||
'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
|
||||
'tid' => 'varchar(20) NOT NULL COMMENT \'素材类型\'',
|
||||
'title' => 'varchar(255) NOT NULL COMMENT \'规则名称\'',
|
||||
'keyword' => 'varchar(255) NOT NULL COMMENT \'关键字\'',
|
||||
'content' => 'text NOT NULL COMMENT \'内容值数组\'',
|
||||
'counts' => 'int(10) NOT NULL COMMENT \'命中次数\'',
|
||||
'displayorder' => 'int(10) NOT NULL COMMENT \'权重值\'',
|
||||
'updatetime' => 'int(10) NOT NULL COMMENT \'最近命中时间\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `keyword` (`keyword`)',
|
||||
'KEY `displayorder` (`displayorder`)',
|
||||
'KEY `updatetime` (`updatetime`)',
|
||||
],
|
||||
],
|
||||
],
|
||||
'seeds' => [],
|
||||
]);
|
||||
if (empty($rt['code'])) {
|
||||
log_message('error', 'Weixin install_schema: '.($rt['msg'] ?? ''));
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 菜单配置
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
'admin' => [
|
||||
|
||||
'app-weixin' => [
|
||||
'name' => '微信',
|
||||
'icon' => 'fa fa-weixin',
|
||||
'left' => [
|
||||
'app-weixin-home' => [
|
||||
'name' => '系统设置',
|
||||
'icon' => 'fa fa-home',
|
||||
'link' => [
|
||||
[
|
||||
'name' => '公众号',
|
||||
'icon' => 'fa fa-weixin',
|
||||
'uri' => 'weixin/account/index',
|
||||
],
|
||||
[
|
||||
'name' => '小程序',
|
||||
'icon' => 'fa fa-link',
|
||||
'uri' => 'weixin/xcx/index',
|
||||
],
|
||||
[
|
||||
'name' => '系统配置',
|
||||
'icon' => 'fa fa-cog',
|
||||
'uri' => 'weixin/config/index',
|
||||
],
|
||||
[
|
||||
'name' => '菜单管理',
|
||||
'icon' => 'fa fa-list',
|
||||
'uri' => 'weixin/menu/index',
|
||||
],
|
||||
[
|
||||
'name' => '请求日志',
|
||||
'icon' => 'fa fa-shield',
|
||||
'uri' => 'weixin/log/index',
|
||||
],
|
||||
[
|
||||
'name' => '更多公众号',
|
||||
'icon' => 'fa fa-users',
|
||||
'uri' => 'weixin/more/index',
|
||||
],
|
||||
],
|
||||
],
|
||||
'app-weixin-content' =>[
|
||||
'name' => '公众号内容',
|
||||
'icon' => 'fa fa-th-large',
|
||||
'link' => [
|
||||
[
|
||||
'name' => '内容管理',
|
||||
'icon' => 'fa fa-edit',
|
||||
'uri' => 'weixin/content/index',
|
||||
],
|
||||
[
|
||||
'name' => '自动回复',
|
||||
'icon' => 'fa fa-comments',
|
||||
'uri' => 'weixin/reply/index',
|
||||
],
|
||||
]
|
||||
],
|
||||
'app-weixin-fans' =>[
|
||||
'name' => '公众号粉丝',
|
||||
'icon' => 'fa fa-user',
|
||||
'link' => [
|
||||
[
|
||||
'name' => '粉丝管理',
|
||||
'icon' => 'fa fa-user',
|
||||
'uri' => 'weixin/user/index',
|
||||
],
|
||||
[
|
||||
'name' => '用户标签组',
|
||||
'icon' => 'fa fa-users',
|
||||
'uri' => 'weixin/group/index',
|
||||
],
|
||||
]
|
||||
],
|
||||
'app-weixin-message' =>[
|
||||
'name' => '公众号消息',
|
||||
'icon' => 'fa fa-envelope',
|
||||
'link' => [
|
||||
[
|
||||
'name' => '消息记录',
|
||||
'icon' => 'fa fa-envelope',
|
||||
'uri' => 'weixin/message/index',
|
||||
],
|
||||
[
|
||||
'name' => '客服群发',
|
||||
'icon' => 'fa fa-envelope-o',
|
||||
'uri' => 'weixin/send/index',
|
||||
],
|
||||
[
|
||||
'name' => '高级群发',
|
||||
'icon' => 'fa fa-volume-up',
|
||||
'uri' => 'weixin/sendall/index',
|
||||
],
|
||||
[
|
||||
'name' => '模板群发',
|
||||
'icon' => 'fa fa-puzzle-piece',
|
||||
'uri' => 'weixin/template/index',
|
||||
],
|
||||
[
|
||||
'name' => '内容模板群发设置',
|
||||
'icon' => 'fa fa-th-large',
|
||||
'uri' => 'weixin/sendtpl/index',
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/*
|
||||
* 自定义通知类型
|
||||
* */
|
||||
|
||||
return [
|
||||
'name' => '微信公众号',
|
||||
'file' => 'weixin',
|
||||
'help' => 'javascript:dr_help(481);',
|
||||
'height' => '200',
|
||||
'class' => 'weixin',
|
||||
];
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
// 加载主程序的路由
|
||||
require COREPATH.'Config/Routes.php';
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$t = \Phpcmf\Service::M('table');
|
||||
$m = \Phpcmf\Service::M();
|
||||
foreach ([
|
||||
'app_weixin',
|
||||
'weixin',
|
||||
'weixin_follow',
|
||||
'weixin_group',
|
||||
'weixin_user',
|
||||
'weixin_menu',
|
||||
'weixin_content',
|
||||
'weixin_media_id',
|
||||
'weixin_send',
|
||||
'weixin_message',
|
||||
'weixin_template',
|
||||
'weixin_reply',
|
||||
] as $name) {
|
||||
$t->drop_table($m->dbprefix($name), true);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* 更新数据结构
|
||||
*/
|
||||
$prefix = \Phpcmf\Service::M()->prefix;
|
||||
$table = $prefix.'weixin_content';
|
||||
$t = \Phpcmf\Service::M('table');
|
||||
$m = \Phpcmf\Service::M();
|
||||
|
||||
if ($m->is_table_exists($table)) {
|
||||
if (!$m->is_field_exists($table, 'nums')) {
|
||||
$t->add_field($table, 'nums', 'tinyint(2)', 'DEFAULT \'0\'', '');
|
||||
}
|
||||
if (!$m->is_field_exists($table, 'status')) {
|
||||
$t->add_field($table, 'status', 'tinyint(2)', 'DEFAULT \'0\'', '');
|
||||
}
|
||||
if (!$m->is_field_exists($table, 'publish_id')) {
|
||||
$t->add_field($table, 'publish_id', 'varchar(255)', 'DEFAULT \'\'', '');
|
||||
}
|
||||
if (!$m->is_field_exists($table, 'article_id')) {
|
||||
$t->add_field($table, 'article_id', 'varchar(255)', 'DEFAULT \'\'', '');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'id' => '226',
|
||||
'vip' => '',
|
||||
'cms' => '4.7.3',
|
||||
'version' => '5.42',
|
||||
'license' => '375C71349B295FBE2DCDCA9206F20A1703',
|
||||
'updatetime' => '2026-06-26 15:12:04',
|
||||
'downtime' => '2026-08-08 00:54:28',
|
||||
|
||||
];
|
||||
Reference in New Issue
Block a user