|
@@ -25,106 +25,55 @@ use think\Cache;
|
|
|
class Index extends BaseViewController
|
|
|
{
|
|
|
|
|
|
- private $version = '1.032112';
|
|
|
+ private $version = '1.0';
|
|
|
|
|
|
public function index(Request $request){
|
|
|
$domain = $request->domain();
|
|
|
- $reids = \think\facade\Cache::store('redis');
|
|
|
+ $redis = \think\facade\Cache::store('redis');
|
|
|
$keyDomain = md5($domain . $this->version);
|
|
|
- $content = $reids->get($keyDomain);
|
|
|
+ $content = $redis->get($keyDomain);
|
|
|
if(!empty($content)){
|
|
|
return $content;
|
|
|
} else {
|
|
|
- $siteUrl = config('app')['SITE_URL'];
|
|
|
- if (strpos($domain, $siteUrl) !== false) {
|
|
|
- preg_match("#[http|https]://(.*?)\.#i", $domain, $match);
|
|
|
- $siteModel = (new Site)->where('sub_domain', $match[1])->find();
|
|
|
- } else {
|
|
|
- $domain = str_replace('http://', '', $domain);
|
|
|
- $domain = str_replace('https://', '', $domain);
|
|
|
- $siteModel = (new Site)->where('domain', $domain)->find();
|
|
|
- }
|
|
|
-
|
|
|
- $sys = Sys::where("id", 1)->find();
|
|
|
- // $siteModel = (new Site)->whereRaw("1=1")->find();
|
|
|
- if (empty($siteModel)) {
|
|
|
- return '抱歉,找不到站点,请联系客服电话:' . $sys['custom_tel'] . ',客服QQ:' . $sys['custom_qq'] . '!';
|
|
|
- }
|
|
|
- if (!empty($siteModel['is_close'])) {
|
|
|
- return '站点关闭了,请联系客服电话:' . $sys['custom_tel'] . ',客服QQ:' . $sys['custom_qq'] . '!';
|
|
|
- }
|
|
|
$strBody = '';
|
|
|
- $txt = file_get_contents(app()->getRootPath() . 'public/tpl/index.html');
|
|
|
+ $txt = file_get_contents(app()->getRootPath() . 'public/index.html');
|
|
|
preg_match('/\<link(.*?)<\/body>/is', $txt, $match);
|
|
|
if (!empty($match[0])) {
|
|
|
$strBody = $match[0];
|
|
|
}
|
|
|
|
|
|
- //生成icon图标
|
|
|
- $iconImg = '';
|
|
|
- $iconStr = '';
|
|
|
- $iconAr = empty($siteModel['icon']) ? [] : json_decode($siteModel['icon'], true);
|
|
|
- if (
|
|
|
- (empty($iconAr) || $iconAr['icon_img'] != $siteModel['icon_img']) &&
|
|
|
- !empty($siteModel['icon_img'])
|
|
|
- ) {
|
|
|
- $icon = new Icon;
|
|
|
- $iconData = $icon->mkIcon($siteModel['icon_img'], 'public/favicon/');
|
|
|
- if (!empty($iconData)) {
|
|
|
- (new Site)->where('sassid', $siteModel['sassid'])->save([
|
|
|
- 'icon_data' => json_encode(['icon_img' => $siteModel['icon_img'], 'img' => $iconData['img']])
|
|
|
- ]);
|
|
|
- $iconImg = $iconData['img'];
|
|
|
- }
|
|
|
- } else {
|
|
|
- $iconImg = empty($iconAr['img']) ? '' : $iconAr['img'];
|
|
|
- }
|
|
|
- if (!empty($iconImg)) {
|
|
|
- $iconStr = '<link rel="bookmark" type="image/x-icon" href="https://www.babalipin.com/' . $iconImg . '" />';
|
|
|
- $iconStr .= '<link rel="shortcut icon" type="image/x-icon" href="https://www.babalipin.com/' . $iconImg . '" />';
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $str = '<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>' . $siteModel['sys_seo_title'] . '</title>
|
|
|
- <meta name="keywords" content="' . $siteModel['sys_seo_keyword'] . '">
|
|
|
- <meta name="description" content="' . $siteModel['sys_seo_description'] . '">
|
|
|
- ' . $iconStr . '
|
|
|
- <script>
|
|
|
- var secret_key = "' . $siteModel['secret_key'] . '";
|
|
|
- var global_site = {
|
|
|
- "seo_title" : "' . $siteModel['sys_seo_title'] . '",//seo 标题
|
|
|
- "seo_keyword" : "' . $siteModel['sys_seo_keyword'] . '",//SEO key
|
|
|
- "seo_description" : "' . $siteModel['sys_seo_description'] . '",//SEO内容
|
|
|
- "record" : "' . $siteModel['record'] . '",//备案号
|
|
|
- "custom_qq" : "' . $siteModel['custom_qq'] . '",//客服QQ
|
|
|
- "custom_tel" : "' . $siteModel['custom_tel'] . '",//客服电话
|
|
|
- "weixin_logo" : "' . $siteModel['weixin_logo'] . '",//微信lOGO
|
|
|
- };</script>' . $strBody . '<script>// dataset 方法兼容 IE 浏览器。ie10及以下不支持dataset
|
|
|
- if (window.HTMLElement) {
|
|
|
- if (Object.getOwnPropertyNames(HTMLElement.prototype).indexOf(\'dataset\') === -1) {
|
|
|
- Object.defineProperty(HTMLElement.prototype, \'dataset\', {
|
|
|
- get: function () {
|
|
|
- var attributes = this.attributes // 获取节点的所有属性
|
|
|
- var name = []
|
|
|
- var value = [] // 定义两个数组保存属性名和属性值
|
|
|
- var obj = {} // 定义一个空对象
|
|
|
- for (var i = 0; i < attributes.length; i++) { // 遍历节点的所有属性
|
|
|
- if (attributes[i].nodeName.slice(0, 5) === \'data-\') { // 如果属性名的前面5个字符符合"data-"
|
|
|
- // 取出属性名的"data-"的后面的字符串放入name数组中
|
|
|
- name.push(attributes[i].nodeName.slice(5));
|
|
|
- // 取出对应的属性值放入value数组中
|
|
|
- value.push(attributes[i].nodeValue);
|
|
|
+ $str = '<!DOCTYPE html><html><head>
|
|
|
+ <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
|
+ <title>直播产品库</title>
|
|
|
+ <meta name="keywords" content="直播产品库">
|
|
|
+ <meta name="description" content="直播产品库">
|
|
|
+ <link rel="bookmark" type="image/x-icon" href="https://www.boofly.cn/favicon.ico" />
|
|
|
+ <link rel="shortcut icon" type="image/x-icon" href="https://www.boofly.cn/favicon.ico" />'. $strBody . '<script>
|
|
|
+ if (window.HTMLElement) {
|
|
|
+ if (Object.getOwnPropertyNames(HTMLElement.prototype).indexOf(\'dataset\') === -1) {
|
|
|
+ Object.defineProperty(HTMLElement.prototype, \'dataset\', {
|
|
|
+ get: function () {
|
|
|
+ var attributes = this.attributes // 获取节点的所有属性
|
|
|
+ var name = []
|
|
|
+ var value = [] // 定义两个数组保存属性名和属性值
|
|
|
+ var obj = {} // 定义一个空对象
|
|
|
+ for (var i = 0; i < attributes.length; i++) { // 遍历节点的所有属性
|
|
|
+ if (attributes[i].nodeName.slice(0, 5) === \'data-\') { // 如果属性名的前面5个字符符合"data-"
|
|
|
+ // 取出属性名的"data-"的后面的字符串放入name数组中
|
|
|
+ name.push(attributes[i].nodeName.slice(5));
|
|
|
+ // 取出对应的属性值放入value数组中
|
|
|
+ value.push(attributes[i].nodeValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (var j = 0; j < name.length; j++) { // 遍历name和value数组
|
|
|
+ obj[name[j]] = value[j]; // 将属性名和属性值保存到obj中
|
|
|
+ }
|
|
|
+ return obj // 返回对象
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
- }
|
|
|
- for (var j = 0; j < name.length; j++) { // 遍历name和value数组
|
|
|
- obj[name[j]] = value[j]; // 将属性名和属性值保存到obj中
|
|
|
- }
|
|
|
- return obj // 返回对象
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }</script>' . $siteModel['js_script'] . '</html>';
|
|
|
- $reids->set($keyDomain,$str,60 * 60 * 3);
|
|
|
+ }</script></html>';
|
|
|
+ $redis->set($keyDomain, $str, 60 * 60 * 3);
|
|
|
}
|
|
|
echo $str;
|
|
|
}
|