{"id":30866,"date":"2024-11-25T13:05:42","date_gmt":"2024-11-25T05:05:42","guid":{"rendered":"https:\/\/fwq.ai\/blog\/30866\/"},"modified":"2024-11-25T13:05:42","modified_gmt":"2024-11-25T05:05:42","slug":"%e7%bb%87%e6%a2%a6%e9%a6%96%e9%a1%b5%e5%a6%82%e4%bd%95%e6%98%be%e7%a4%ba%e8%ae%bf%e9%97%ae%e8%80%85ip%e5%9c%b0%e5%9d%80","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/30866\/","title":{"rendered":"\u7ec7\u68a6\u9996\u9875\u5982\u4f55\u663e\u793a\u8bbf\u95ee\u8005ip\u5730\u5740"},"content":{"rendered":"<p style=\"text-align: center\"><strong><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/5e0fef227eb6f416.jpg\" class=\"aligncenter\" title=\"\u7ec7\u68a6\u9996\u9875\u5982\u4f55\u663e\u793a\u8bbf\u95ee\u8005ip\u5730\u5740\u63d2\u56fe\" alt=\"\u7ec7\u68a6\u9996\u9875\u5982\u4f55\u663e\u793a\u8bbf\u95ee\u8005ip\u5730\u5740\u63d2\u56fe\" \/><\/strong><\/p>\n<p><strong>\u7ec7\u68a6\u9996\u9875\u5982\u4f55\u663e\u793a\u8bbf\u95ee\u8005ip\u5730\u5740\uff1f<\/strong><\/p>\n<p>\u7ec7\u68a6DEDECMS\u9996\u9875\u63d2\u5165php\u4ee3\u7801\u663e\u793a\u8bbf\u95ee\u8005ip\u5730\u5740<\/p>\n<p>\u63a8\u8350\u5b66\u4e60\uff1a<\/p>\n<p>\u5728\u9700\u8981\u7684\u4f4d\u7f6e\u653e\u4ee5\u4e0b\u4ee3\u7801<\/p>\n<pre>{dede:php}&nbsp;\n$user_IP&nbsp;=&nbsp;($_SERVER[\"HTTP_VIA\"])&nbsp;?&nbsp;$_SERVER[\"HTTP_X_FORWARDED_FOR\"]&nbsp;:&nbsp;$_SERVER[\"REMOTE_ADDR\"];&nbsp;&nbsp;\n$user_IP&nbsp;=&nbsp;($user_IP)&nbsp;?&nbsp;$user_IP&nbsp;:&nbsp;$_SERVER[\"REMOTE_ADDR\"];&nbsp;&nbsp;\nfunction&nbsp;get_real_ip(){&nbsp;&nbsp;\n$ip=false;&nbsp;&nbsp;\nif(!emptyempty($_SERVER[\"HTTP_CLIENT_IP\"])){&nbsp;&nbsp;\n$ip&nbsp;=&nbsp;$_SERVER[\"HTTP_CLIENT_IP\"];&nbsp;&nbsp;\n}&nbsp;&nbsp;\nif&nbsp;(!emptyempty($_SERVER['HTTP_X_FORWARDED_FOR']))&nbsp;{&nbsp;&nbsp;\n$ips&nbsp;=&nbsp;explode&nbsp;(\",&nbsp;\",&nbsp;$_SERVER['HTTP_X_FORWARDED_FOR']);&nbsp;&nbsp;\nif&nbsp;($ip)&nbsp;{&nbsp;array_unshift($ips,&nbsp;$ip);&nbsp;$ip&nbsp;=&nbsp;FALSE;&nbsp;}&nbsp;&nbsp;\nfor&nbsp;($i&nbsp;=&nbsp;0;&nbsp;$i&nbsp;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u7ec7\u68a6\u9996\u9875\u5982\u4f55\u663e\u793a\u8bbf\u95ee\u8005ip\u5730\u5740\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ec7\u68a6\u9996\u9875\u5982\u4f55\u663e\u793a\u8bbf\u95ee\u8005ip\u5730\u5740\uff1f \u7ec7\u68a6DEDECMS\u9996\u9875\u63d2\u5165php\u4ee3\u7801\u663e\u793a\u8bbf\u95ee\u8005ip\u5730\u5740 \u63a8\u8350\u5b66\u4e60\uff1a \u5728\u9700\u8981\u7684\u4f4d\u7f6e\u653e\u4ee5\u4e0b\u4ee3\u7801 {dede:php}&nbsp; $user_IP&nbsp;=&nbsp;($_SERVER[&#8220;HTTP_VIA&#8221;])&nbsp;?&nbsp;$_SERVER[&#8220;HTTP_X_FORWARDED_FOR&#8221;]&nbsp;:&nbsp;$_SERVER[&#8220;REMOTE_ADDR&#8221;];&nbsp;&nbsp; $user_IP&nbsp;=&nbsp;($user_IP)&nbsp;?&nbsp;$user_IP&nbsp;:&nbsp;$_SERVER[&#8220;REMOTE_ADDR&#8221;];&nbsp;&nbsp; function&nbsp;get_real_ip(){&nbsp;&nbsp; $ip=false;&nbsp;&nbsp; if(!emptyempty($_SERVER[&#8220;HTTP_CLIENT_IP&#8221;])){&nbsp;&nbsp; $ip&nbsp;=&nbsp;$_SERVER[&#8220;HTTP_CLIENT_IP&#8221;];&nbsp;&nbsp; }&nbsp;&nbsp; if&nbsp;(!emptyempty($_SERVER[&#8216;HTTP_X_FORWARDED_FOR&#8217;]))&nbsp;{&nbsp;&nbsp; $ips&nbsp;=&nbsp;explode&nbsp;(&#8220;,&nbsp;&#8220;,&nbsp;$_SERVER[&#8216;HTTP_X_FORWARDED_FOR&#8217;]);&nbsp;&nbsp; if&nbsp;($ip)&nbsp;{&nbsp;array_unshift($ips,&nbsp;$ip);&nbsp;$ip&nbsp;=&nbsp;FALSE;&nbsp;}&nbsp;&nbsp; for&nbsp;($i&nbsp;=&nbsp;0;&nbsp;$i&nbsp; \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u5c31\u662f\u7ec7\u68a6\u9996\u9875\u5982\u4f55\u663e\u793a\u8bbf\u95ee\u8005ip\u5730\u5740\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-30866","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=30866"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30866\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=30866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=30866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=30866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}