From dff6e29972cab3edd9e3497e9777c263b8fd8d67 Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Sun, 24 Oct 2021 11:36:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=BA=97=E8=BF=9E=E6=8E=A5=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Common.php | 8 ++++-- app/admin/controller/Config.php | 1 + app/admin/view/default/config/index.html | 9 ++++++ app/admin/view/default/index/init.html | 4 +++ app/common.php | 26 +++++++++++------ app/service/ConfigService.php | 3 ++ app/service/PackageInstallService.php | 16 +++++------ app/service/PluginsService.php | 2 +- app/service/StoreService.php | 36 +++++++++++++++--------- config/shopxo.php | 27 ++++++++++-------- 10 files changed, 86 insertions(+), 46 deletions(-) diff --git a/app/admin/controller/Common.php b/app/admin/controller/Common.php index 45735267e..5a31f2ed8 100755 --- a/app/admin/controller/Common.php +++ b/app/admin/controller/Common.php @@ -212,15 +212,19 @@ class Common extends BaseController MyViewAssign('admin_theme_site_name', MyC('admin_theme_site_name', 'ShopXO', true)); // 站点商店信息 + $site_store_error = ''; $site_store_info = StoreService::SiteStoreInfo(); if(empty($site_store_info)) { - $res = StoreService::SiteStoreAccountsBindHandle(); - if(!empty($res) && isset($res['code']) && $res['code'] == 0) + $ret = StoreService::SiteStoreAccountsBindHandle(); + if($ret['code'] == 0) { $site_store_info = StoreService::SiteStoreInfo(); + } else { + $site_store_error = $ret['msg']; } } + MyViewAssign('site_store_error', $site_store_error); MyViewAssign('site_store_info', $site_store_info); // 更多链接地址 diff --git a/app/admin/controller/Config.php b/app/admin/controller/Config.php index 729457012..62863b1e8 100755 --- a/app/admin/controller/Config.php +++ b/app/admin/controller/Config.php @@ -54,6 +54,7 @@ class Config extends Common MyViewAssign('common_is_enable_list', MyConst('common_is_enable_list')); MyViewAssign('common_login_type_list', MyConst('common_login_type_list')); MyViewAssign('common_close_open_list', MyConst('common_close_open_list')); + MyViewAssign('common_is_text_list', MyConst('common_is_text_list')); // 配置信息 MyViewAssign('data', ConfigService::ConfigList()); diff --git a/app/admin/view/default/config/index.html b/app/admin/view/default/config/index.html index 4b836efcb..d26e46e3d 100755 --- a/app/admin/view/default/config/index.html +++ b/app/admin/view/default/config/index.html @@ -86,6 +86,15 @@

扩展

+
+ + +
+
diff --git a/app/admin/view/default/index/init.html b/app/admin/view/default/index/init.html index d0bcb5c3a..3d3562ad0 100755 --- a/app/admin/view/default/index/init.html +++ b/app/admin/view/default/index/init.html @@ -22,6 +22,10 @@ 修改 {{else /}} 绑定ShopXO商店账户 + + {{if !empty($site_store_error)}} + {{$site_store_error}} + {{/if}} {{/if}} diff --git a/app/common.php b/app/common.php index 9eed13db1..82ed83864 100755 --- a/app/common.php +++ b/app/common.php @@ -256,10 +256,20 @@ function GetHttpCode($url, $timeout = 5) curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_exec($ch); - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); - curl_close($ch); - return $code; + + // 返回结果 + $result = curl_exec($ch); + if($result !== false) + { + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + return DataReturn('success', 0, $code); + } else { + $error_code = curl_errno($ch); + $error_msg = curl_error($ch); + curl_close($ch); + return DataReturn($error_msg.' ('.$error_code.')', -9999, $error_code); + } } /** @@ -2032,7 +2042,6 @@ function CurlGet($url, $timeout = 10) curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_URL, $url); - $result = curl_exec($ch); curl_close($ch); return $result; @@ -2087,11 +2096,12 @@ function CurlPost($url, $post, $is_json = false, $timeout = 30) if($result !== false) { curl_close($ch); - return $result; + return DataReturn('success', 0, $result); } else { - $error = curl_errno($ch); + $error_code = curl_errno($ch); + $error_msg = curl_error($ch); curl_close($ch); - return "curl出错,错误码:$error"; + return DataReturn($error_msg.' ('.$error_code.')', -9999, $error_code); } } diff --git a/app/service/ConfigService.php b/app/service/ConfigService.php index 2b1bb33e1..9eee26ca1 100755 --- a/app/service/ConfigService.php +++ b/app/service/ConfigService.php @@ -102,6 +102,9 @@ class ConfigService 'home_max_limit_image', 'home_max_limit_video', 'home_max_limit_file', + + // 是否采用https连接商店 + 'common_is_https_connect_store', ]; /** diff --git a/app/service/PackageInstallService.php b/app/service/PackageInstallService.php index 4c939cb8a..284dc8a41 100644 --- a/app/service/PackageInstallService.php +++ b/app/service/PackageInstallService.php @@ -338,17 +338,15 @@ class PackageInstallService */ public static function HttpRequest($url, $data) { - $res = CurlPost($url, $data); - $result = json_decode($res, true); + $ret = CurlPost($url, $data); + if($ret['code'] != 0) + { + return $ret; + } + $result = json_decode($ret['data'], true); if(empty($result)) { - return DataReturn('商店网络不通['.$res.']', -1); - } - - // 是否非数组 - if(is_string($result)) - { - return DataReturn($result, -1); + return DataReturn('商店返回数据有误'.(empty($ret['data']) ? '' : '('.$ret['data'].')'), -1); } // 请求成功 diff --git a/app/service/PluginsService.php b/app/service/PluginsService.php index 5233ed5fc..95b9797a4 100755 --- a/app/service/PluginsService.php +++ b/app/service/PluginsService.php @@ -349,7 +349,7 @@ class PluginsService $ret = StoreService::PluginsLegalCheck($check_params); MyCache($key, $ret, 3600); } - if($ret['code'] != 0) + if(!in_array($ret['code'], [0, -9999])) { return $ret; } diff --git a/app/service/StoreService.php b/app/service/StoreService.php index 87f8d69ac..e5493fc6d 100644 --- a/app/service/StoreService.php +++ b/app/service/StoreService.php @@ -276,15 +276,16 @@ class StoreService // http状态验证 $key = 'cache_store_url_http_code'; $time = 600; - $code = MyCache($key); - if($code === null) + $ret = MyCache($key); + if(empty($ret)) { - $code = GetHttpCode(self::StoreUrl(), 2); - MyCache($key, $code, $time); + $ret = GetHttpCode(self::StoreUrl(), 2); + MyCache($key, $ret, $time); } - if(!in_array($code, [200, 301, 302, 307, 308])) + if(!in_array($ret['data'], [200, 301, 302, 307, 308])) { - return DataReturn('商店网络不通', 0); + $ret['msg'] = '商店连接失败[ '.$ret['msg'].' ]'; + return $ret; } // 基础数据获取 @@ -310,19 +311,26 @@ class StoreService 'php_sapi_name' => php_sapi_name(), 'client_date' => date('Y-m-d H:i:s'), ]; - $res = CurlPost($url, array_merge($data, $params)); - $result = json_decode($res, true); + $ret = CurlPost($url, array_merge($data, $params)); + if($ret['code'] != 0) + { + // 网络不通 + MyCache($key, 0, $ret['data']); + $ret['msg'] = '商店连接失败[ '.$ret['msg'].' ]'; + return $ret; + } + + // 数据解析 + $result = json_decode($ret['data'], true); if(empty($result)) { - // 网络不通、返回非有效json数据则认为网络不通 - MyCache($key, 0, $time); - return DataReturn('商店网络不通', 0); + return DataReturn('商店返回数据有误'.(empty($ret['data']) ? '' : '('.$ret['data'].')'), -1); } // 是否非数组 if(is_string($result)) { - return DataReturn($result, -1); + return DataReturn('商店返回数据无效[ '.$result.' ]', -1); } // 请求成功 @@ -330,12 +338,12 @@ class StoreService { if(empty($result['data'])) { - return DataReturn('无对应数据、请稍后再试!', -1); + return DataReturn('商店返回无对应数据、请稍后再试!', -1); } return $result; } - return DataReturn(empty($result['msg']) ? '异常错误失败、请稍后再试!' : $result['msg'], -1); + return DataReturn(empty($result['msg']) ? '商店返回异常错误、请稍后再试!' : '商店返回[ '.$result['msg'].' ]', -1); } } ?> \ No newline at end of file diff --git a/config/shopxo.php b/config/shopxo.php index fbf611d6b..c9628e328 100755 --- a/config/shopxo.php +++ b/config/shopxo.php @@ -25,6 +25,9 @@ if(substr($cdn_public_host, -1) != DS) $cdn_public_host .= DS; } +// 连接商店是否采用https +$store_http = (MyFileConfig('common_is_https_connect_store') == 1) ? 'https://' : 'http://'; + // 配置信息 return [ // 开发模式 @@ -101,32 +104,32 @@ return [ // 应用商店基础地址 - 'website_url' => 'https://shopxo.net/', - 'store_url' => 'https://store.shopxo.net/', - 'store_payment_url' => 'https://store.shopxo.net/', - 'store_theme_url' => 'https://store.shopxo.net/', - 'store_regster_url' => 'https://store.shopxo.net/regster.html', + 'website_url' => $store_http.'shopxo.net/', + 'store_url' => $store_http.'store.shopxo.net/', + 'store_payment_url' => $store_http.'store.shopxo.net/', + 'store_theme_url' => $store_http.'store.shopxo.net/', + 'store_regster_url' => $store_http.'store.shopxo.net/regster.html', // 插件在线下载地址 - 'store_download_url' => 'https://store.shopxo.net/index.php?s=store-package-onine.html', + 'store_download_url' => $store_http.'store.shopxo.net/index.php?s=store-package-onine.html', // 远程系统更新接口 - 'store_system_upgrade_url' => 'https://store.shopxo.net/api.php?s=plugins/index&pluginsname=store&pluginscontrol=index&pluginsaction=systemsupgradeurl', + 'store_system_upgrade_url' => $store_http.'store.shopxo.net/api.php?s=plugins/index&pluginsname=store&pluginscontrol=index&pluginsaction=systemsupgradeurl', // 远程插件更新接口 - 'store_plugins_upgrade_url' => 'https://store.shopxo.net/api.php?s=plugins/index&pluginsname=store&pluginscontrol=index&pluginsaction=pluginsupgradeurl', + 'store_plugins_upgrade_url' => $store_http.'store.shopxo.net/api.php?s=plugins/index&pluginsname=store&pluginscontrol=index&pluginsaction=pluginsupgradeurl', // 远程信息接口 - 'store_site_info_url' => 'https://store.shopxo.net/api.php?s=plugins/index&pluginsname=store&pluginscontrol=index&pluginsaction=siteinfo', + 'store_site_info_url' => $store_http.'store.shopxo.net/api.php?s=plugins/index&pluginsname=store&pluginscontrol=index&pluginsaction=siteinfo', // 远程检查更新接口 - 'store_inspect_upgrade_url' => 'https://store.shopxo.net/api.php?s=plugins/index&pluginsname=store&pluginscontrol=index&pluginsaction=inspectupgrade', + 'store_inspect_upgrade_url' => $store_http.'store.shopxo.net/api.php?s=plugins/index&pluginsname=store&pluginscontrol=index&pluginsaction=inspectupgrade', // 远程插件安全合法校验接口 - 'store_plugins_legal_check_url' => 'https://store.shopxo.net/api.php?s=plugins/index&pluginsname=store&pluginscontrol=index&pluginsaction=pluginslegalcheck', + 'store_plugins_legal_check_url' => $store_http.'store.shopxo.net/api.php?s=plugins/index&pluginsname=store&pluginscontrol=index&pluginsaction=pluginslegalcheck', // 远程插件更新信息接口 - 'store_plugins_upgrade_info_url' => 'https://store.shopxo.net/api.php?s=plugins/index&pluginsname=store&pluginscontrol=index&pluginsaction=pluginsupgradeinfo', + 'store_plugins_upgrade_info_url' => $store_http.'store.shopxo.net/api.php?s=plugins/index&pluginsname=store&pluginscontrol=index&pluginsaction=pluginsupgradeinfo', // 支付业务类型,支付插件根据业务类型自动生成支付入口文件