From c405da46ef0eb9f8228d7fe843a7df4bd8f2e129 Mon Sep 17 00:00:00 2001 From: meng Date: Thu, 16 Feb 2023 04:02:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0api=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api.php | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 api.php diff --git a/api.php b/api.php new file mode 100644 index 0000000..75c6f4f --- /dev/null +++ b/api.php @@ -0,0 +1,75 @@ +web('common'); +$uniacid = $_W['uniacid'] = intval($_GPC['i']); + +$_W['attachurl'] = $_W['attachurl_local'] = $_W['siteroot'] . $_W['config']['upload']['attachdir'] . '/'; + +if (!empty($_W['setting']['remote'][$_W['uniacid']]['type'])) { + $_W['setting']['remote'] = $_W['setting']['remote'][$_W['uniacid']]; +} + +$info = uni_setting_load('remote', $uniacid); +if(!empty($info['remote'])){ + if($info['remote']['type'] !=0){ + $_W['setting']['remote'] = $info['remote']; + } +} +if (!empty($_W['setting']['remote']['type'])) { + if ($_W['setting']['remote']['type'] == ATTACH_FTP) { + $_W['attachurl'] = $_W['attachurl_remote'] = $_W['setting']['remote']['ftp']['url'] . '/'; + } elseif ($_W['setting']['remote']['type'] == ATTACH_OSS) { + $_W['attachurl'] = $_W['attachurl_remote'] = $_W['setting']['remote']['alioss']['url'] . '/'; + } elseif ($_W['setting']['remote']['type'] == ATTACH_QINIU) { + $_W['attachurl'] = $_W['attachurl_remote'] = $_W['setting']['remote']['qiniu']['url'] . '/'; + } elseif ($_W['setting']['remote']['type'] == ATTACH_COS) { + $_W['attachurl'] = $_W['attachurl_remote'] = $_W['setting']['remote']['cos']['url'] . '/'; + } +} + +//$uniacid = $_GPC['i'] = 4; + +// check微擎绑定 +if(!empty($_GPC['formwe7'])){ + $bind = pdo_fetch('SELECT * FROM '. tablename('ewei_shop_wxapp_bind'). ' WHERE wxapp=:wxapp LIMIT 1', array(':wxapp'=>$uniacid)); + if(!empty($bind) && !empty($bind['uniacid'])){ + $uniacid = $_GPC['i'] = $bind['uniacid']; + } +} + +header("ACCESS-CONTROL-ALLOW-ORIGIN:*"); + +if(empty($uniacid)){ + die('Access Denied.'); +} +$site = WeUtility::createModuleSite('ewei_shopv2'); +$_GPC['c']='site'; +$_GPC['a']='entry'; +$_GPC['m']='ewei_shopv2'; +$_GPC['do']='mobile'; +$_W['uniacid'] = (int)$_GPC['i']; + +$_W['account'] = uni_fetch($_W['uniacid']); +$_W['acid'] = (int)$_W['account']['acid']; + +if (!isset($_GPC['r'])){ + $_GPC['r']='open_api'; +}else{ + $_GPC['r']='open_api.'.$_GPC['r']; +} +if(!is_error($site)) { + $method = 'doMobileMobile'; + $site->uniacid = $uniacid ; + $site->inMobile = true; + if (method_exists($site, $method)) { + $r = $site->$method(); + if (!empty($r)) { + echo $r;die; + } + exit; + + } +} +