Browse Source

Merge branch 'master' of https://git.dashgame.com/919693957/Tools

gsgundam 5 years ago
parent
commit
5c4e04cda5
3 changed files with 132 additions and 63 deletions
  1. 54 2
      application/common.php
  2. 12 2
      application/index/controller/Base.php
  3. 66 59
      application/index/view/base/footer.html

+ 54 - 2
application/common.php

@@ -11,7 +11,7 @@
 
 // 应用公共文件
 
-
+header('Content-Type:text/html;Charset=utf-8');
 /**
  * 保存后台用户行为
  * @param string $remark 日志备注
@@ -32,4 +32,56 @@ function insert_admin_log($remark)
             'create_time' => time(),
         ]);
 
-}
+}
+
+
+
+/**
+ * 获取用户真实 IP
+ */
+function getIP()
+{
+    static $realip;
+    if (isset($_SERVER)){
+        if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
+            $realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
+        } else if (isset($_SERVER["HTTP_CLIENT_IP"])) {
+            $realip = $_SERVER["HTTP_CLIENT_IP"];
+        } else {
+            $realip = $_SERVER["REMOTE_ADDR"];
+        }
+    } else {
+        if (getenv("HTTP_X_FORWARDED_FOR")){
+            $realip = getenv("HTTP_X_FORWARDED_FOR");
+        } else if (getenv("HTTP_CLIENT_IP")) {
+            $realip = getenv("HTTP_CLIENT_IP");
+        } else {
+            $realip = getenv("REMOTE_ADDR");
+        }
+    }
+    return $realip;
+}
+
+
+
+
+//获取城市所在天气情况
+function tianqi($chengshi)
+{
+    $url = 'http://wthrcdn.etouch.cn/weather_mini?city='.urlencode($chengshi);
+    $html = file_get_contents($url);
+    $jsondata = gzdecode($html);
+    $data=json_decode($jsondata,true);
+    $arr=array();
+    $arr['chengshi']=$data['data']['city'];
+    $dangtian=$data['data']['forecast'][0];
+    $arr['gaowen']= str_replace("高温 ",null,$dangtian['high']);
+    $arr['diwen']= str_replace("低温 ",null,$dangtian['low']);
+    $arr['tianqi']=$dangtian['type'];
+    $arr['fengxiang'] = $dangtian['fengxiang'];
+    $arr['time'] =date("Y-m-d H:i:s");
+    return $arr;
+
+
+}
+

+ 12 - 2
application/index/controller/Base.php

@@ -32,12 +32,22 @@ class Base extends Controller
         }
         //end---------------------------------------------------------
 
-
-
+ 		$getip = getIp();//获取ip
+        // $getip = "218.70.26.255"; //重庆IP地址
+        if($getip == ''||$getip=='127.0.0.1'){
+            $getip="210.51.167.169";//默认为北京ip地址
+        }
+        $content = json_decode(file_get_contents("https://api.seniverse.com/v3/weather/now.json?key=S3OSd1xyPevThEbnB&location=$getip"),true); 
+        $city=array();
+        $city['name'] = $content['results'][0]['location']['name'];//获取城市
+        $tq = tianqi($city['name']);//获取当前城市天气
         $this->assign([
                 'data'=>$data,
                 'tags'=>$tags,
                 'good'=>$good,
+                'getip'=>$getip,//ip
+                'city'=>$city,//城市
+                'tq'=>$tq,//天气
             ]);
  		
     	return view();

+ 66 - 59
application/index/view/base/footer.html

@@ -1,61 +1,68 @@
 <footer class="footer">
-<div class="footer-main">
-<div class="container">
-<div class="row items">
-<div class="col-12 item">
-<div class="footer-item">
-<h4 class="footer-item-title">友情链接</h4>
-<nav class="footer-nav">
-
-<ul class="footer-mnu">
-	<li class="col-md-auto col-12 item">
-		<a href="http://www.dashgame.com" class="hover-link" data-title="赞助商" target="_blank"><span>极风游科技</span></a>
-	</li> 
-
-</ul>
-
-</nav>
-</div>
-</div>
-<div class="col-12 item">
-<div class="footer-item">
-<h4 class="footer-item-title">欢迎</h4>
-<div class="footer-contacts">你来自:,
-访问IP:125.84.60.87 </div>
-<div class="footer-contacts">当前天气为:,
-温度:℃, 风向:,
-更新时间: </div>
-</div>
-</div>
-</div>
-</div>
-</div>
-<div class="footer-bottom">
-<div class="container">
-<div class="row justify-content-between items">
-<div class="col-md-auto col-12 item">
-<nav class="footer-links">
-<ul>
-<li>
-<script type="text/javascript" src="__IBOXS__/js/index.js"></script>
-<script type="text/javascript">
-    function xsjhitokoto() {
-        document.write("");
-    }
-
-</script>
-<script>xsjhitokoto()</script>
-</li>
-</ul>
-</nav>
-</div>
-<div class="col-md-auto col-12 item">
-	<div class="copyright"> Copyright © 2019 <span style="color:#666;">Designed by <a href="https://www.dashgame.com" target="_blank">DashGame</a></span>
-<br><a href="http://www.miitbeian.gov.cn" title="备案" target="_blank">渝ICP备14004903号</a>
-</div>
-</div>
-<span style="display: none"></span>
-</div>
-</div>
-</div>
+    <div class="">
+        <div class="footer-main container">
+            <div class="row items">
+                <div class="col-12 item">
+                    <div class="footer-item">
+                        <h4 class="footer-item-title">友情链接</h4>
+                        <nav class="footer-nav">
+
+                            <ul class="footer-mnu">
+                                <li class="col-md-auto col-12 item">
+                                    <a href="http://www.dashgame.com" class="hover-link" data-title="赞助商"
+                                       target="_blank"><span>极风游科技</span></a>
+                                </li>
+
+                            </ul>
+
+                        </nav>
+                    </div>
+                </div>
+
+                <div class="footer-item">
+                    <div class="col-12">
+                        <h4 class="footer-item-title">欢迎</h4>
+                        <div class="footer-contacts">你来自:{$tq['chengshi']},
+                            访问IP:{$getip}
+                        </div>
+                        <div class="footer-contacts">当前天气为:{$tq['tianqi']},
+                            温度:{$tq['diwen']}~{$tq['gaowen']}, 风向:{$tq['fengxiang']},
+                            更新时间:{$tq['time']}
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+
+		<div class="footer-bottom">
+			<div class="container">
+				<div class="row justify-content-between items">
+					<div class="col-md-auto col-12 item">
+						<nav class="footer-links">
+							<ul>
+								<li>
+									<script type="text/javascript" src="__IBOXS__/js/index.js"></script>
+									<script type="text/javascript">
+										function xsjhitokoto() {
+											document.write("");
+										}
+
+									</script>
+									<script>xsjhitokoto()</script>
+								</li>
+							</ul>
+						</nav>
+					</div>
+					<div class="col-md-auto col-12 item">
+						<div class="copyright"> Copyright © 2019 <span style="color:#666;">Powered by Mosheng</span>
+							<br><a href="http://www.miitbeian.gov.cn" title="备案" target="_blank">渝ICP备14004903号</a>
+						</div>
+					</div>
+					<span style="display: none"></span>
+				</div>
+			</div>
+		</div>
+    </div>
+
+
 </footer>