|
@@ -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;
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|