{"id":387,"date":"2020-12-28T14:56:42","date_gmt":"2020-12-28T06:56:42","guid":{"rendered":"https:\/\/wp.dj47.top\/?p=387"},"modified":"2021-10-20T16:11:04","modified_gmt":"2021-10-20T08:11:04","slug":"php%e8%8e%b7%e5%8f%96%e5%ae%a2%e6%88%b7%e7%ab%af%e7%9c%9f%e5%ae%9eip%e5%9c%b0%e5%9d%80%e7%9a%84%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.djlog.cn\/?p=387","title":{"rendered":"PHP\u83b7\u53d6\u5ba2\u6237\u7aef\u771f\u5b9eIP\u5730\u5740\u7684\u65b9\u6cd5"},"content":{"rendered":"<p style=\"box-sizing: border-box; margin: 0px 0px 10px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff;\"><span style=\"box-sizing: border-box; font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', \u5fae\u8f6f\u96c5\u9ed1, Tahoma, Arial, sans-serif; font-size: 16px;\">php\u83b7\u53d6\u5ba2\u6237\u7aefIP\u5730\u5740\u6709\u56db\u79cd\u65b9\u6cd5\uff0c\u8fd9\u4e94\u79cd\u65b9\u6cd5\u5206\u522b\u4e3a<\/span><\/p>\n<p style=\"box-sizing: border-box; margin: 0px 0px 10px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff;\"><strong><span style=\"box-sizing: border-box; font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', \u5fae\u8f6f\u96c5\u9ed1, Tahoma, Arial, sans-serif; font-size: 16px;\"><span style=\"color: #000000; font-family: 'Microsoft YaHei';\">REMOTE_ADDR<\/span><br style=\"color: #000000; font-family: 'Microsoft YaHei'; box-sizing: border-box;\" \/><span style=\"color: #000000; font-family: 'Microsoft YaHei';\">HTTP_CLIENT_IP<\/span><br style=\"color: #000000; font-family: 'Microsoft YaHei'; box-sizing: border-box;\" \/><span style=\"color: #000000; font-family: 'Microsoft YaHei';\">HTTP_X_FORWARDED_FOR<\/span><br style=\"color: #000000; font-family: 'Microsoft YaHei'; box-sizing: border-box;\" \/><span style=\"color: #000000; font-family: 'Microsoft YaHei';\">HTTP_VIA<\/span><\/span><\/strong><\/p>\n<p style=\"box-sizing: border-box; margin: 0px 0px 10px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff;\"><span style=\"box-sizing: border-box; font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', \u5fae\u8f6f\u96c5\u9ed1, Tahoma, Arial, sans-serif; font-size: 16px;\">REMOTE_ADDR \u662f\u4f60\u7684\u5ba2\u6237\u7aef\u8ddf\u4f60\u7684\u670d\u52a1\u5668\u201c\u63e1\u624b\u201d\u65f6\u5019\u7684IP\u3002\u5982\u679c\u4f7f\u7528\u4e86\u201c\u533f\u540d\u4ee3\u7406\u201d\uff0cREMOTE_ADDR\u5c06\u663e\u793a\u4ee3\u7406\u670d\u52a1\u5668\u7684IP\u3002<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>HTTP_CLIENT_IP \u662f\u4ee3\u7406\u670d\u52a1\u5668\u53d1\u9001\u7684HTTP\u5934\u3002\u5982\u679c\u662f\u201c\u8d85\u7ea7\u533f\u540d\u4ee3\u7406\u201d\uff0c\u5219\u8fd4\u56denone\u503c\u3002\u540c\u6837\uff0cREMOTE_ADDR\u4e5f\u4f1a\u88ab\u66ff\u6362\u4e3a\u8fd9\u4e2a\u4ee3\u7406\u670d\u52a1\u5668\u7684IP\u3002<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>$_SERVER[&#8216;REMOTE_ADDR&#8217;]; \/\/\u8bbf\u95ee\u7aef\uff08\u6709\u53ef\u80fd\u662f\u7528\u6237\uff0c\u6709\u53ef\u80fd\u662f\u4ee3\u7406\u7684\uff09IP<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>$_SERVER[&#8216;HTTP_CLIENT_IP&#8217;]; \/\/\u4ee3\u7406\u7aef\u7684\uff08\u6709\u53ef\u80fd\u5b58\u5728\uff0c\u53ef\u4f2a\u9020\uff09<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>$_SERVER[&#8216;HTTP_X_FORWARDED_FOR&#8217;]; \/\/\u7528\u6237\u662f\u5728\u54ea\u4e2aIP\u4f7f\u7528\u7684\u4ee3\u7406\uff08\u6709\u53ef\u80fd\u5b58\u5728\uff0c\u4e5f\u53ef\u4ee5\u4f2a\u9020\uff09<\/span><\/p>\n<p style=\"box-sizing: border-box; margin: 0px 0px 10px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff;\">\n<p style=\"box-sizing: border-box; margin: 0px 0px 10px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff;\"><span style=\"box-sizing: border-box; font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', \u5fae\u8f6f\u96c5\u9ed1, Tahoma, Arial, sans-serif; font-size: 16px;\">\u4e09\u4e2a\u503c\u533a\u522b\u5982\u4e0b\uff1a<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/><br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>\u4e00\u3001\u6ca1\u6709\u4f7f\u7528\u4ee3\u7406\u670d\u52a1\u5668\u7684\u60c5\u51b5\uff1a<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>REMOTE_ADDR = \u60a8\u7684 IP<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>HTTP_VIA = \u6ca1\u6570\u503c\u6216\u4e0d\u663e\u793a<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>HTTP_X_FORWARDED_FOR = \u6ca1\u6570\u503c\u6216\u4e0d\u663e\u793a<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/><br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>\u4e8c\u3001\u4f7f\u7528\u900f\u660e\u4ee3\u7406\u670d\u52a1\u5668\u7684\u60c5\u51b5\uff1aTransparent Proxies<\/span><\/p>\n<p style=\"box-sizing: border-box; margin: 0px 0px 10px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff;\"><span style=\"box-sizing: border-box; font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', \u5fae\u8f6f\u96c5\u9ed1, Tahoma, Arial, sans-serif; font-size: 16px;\">REMOTE_ADDR = \u6700\u540e\u4e00\u4e2a\u4ee3\u7406\u670d\u52a1\u5668 IP<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>HTTP_VIA = \u4ee3\u7406\u670d\u52a1\u5668 IP<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>HTTP_X_FORWARDED_FOR = \u60a8\u7684\u771f\u5b9e IP \uff0c\u7ecf\u8fc7\u591a\u4e2a\u4ee3\u7406\u670d\u52a1\u5668\u65f6\uff0c\u8fd9\u4e2a\u503c\u7c7b\u4f3c\u5982\u4e0b\uff1a203.98.182.163, 203.98.182.163, 203.129.72.215\u3002<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>\u8fd9\u7c7b\u4ee3\u7406\u670d\u52a1\u5668\u8fd8\u662f\u5c06\u60a8\u7684\u4fe1\u606f\u8f6c\u53d1\u7ed9\u60a8\u7684\u8bbf\u95ee\u5bf9\u8c61\uff0c\u65e0\u6cd5\u8fbe\u5230\u9690\u85cf\u771f\u5b9e\u8eab\u4efd\u7684\u76ee\u7684\u3002<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/><br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>\u4e09\u3001\u4f7f\u7528\u666e\u901a\u533f\u540d\u4ee3\u7406\u670d\u52a1\u5668\u7684\u60c5\u51b5\uff1aAnonymous Proxies<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>REMOTE_ADDR = \u6700\u540e\u4e00\u4e2a\u4ee3\u7406\u670d\u52a1\u5668 IP<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>HTTP_VIA = \u4ee3\u7406\u670d\u52a1\u5668 IP<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>HTTP_X_FORWARDED_FOR = \u4ee3\u7406\u670d\u52a1\u5668 IP \uff0c\u7ecf\u8fc7\u591a\u4e2a\u4ee3\u7406\u670d\u52a1\u5668\u65f6\uff0c\u8fd9\u4e2a\u503c\u7c7b\u4f3c\u5982\u4e0b\uff1a203.98.182.163, 203.98.182.163, 203.129.72.215\u3002<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>\u9690\u85cf\u4e86\u60a8\u7684\u771f\u5b9eIP\uff0c\u4f46\u662f\u5411\u8bbf\u95ee\u5bf9\u8c61\u900f\u9732\u4e86\u60a8\u662f\u4f7f\u7528\u4ee3\u7406\u670d\u52a1\u5668\u8bbf\u95ee\u4ed6\u4eec\u7684\u3002<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/><br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>\u56db\u3001\u4f7f\u7528\u6b3a\u9a97\u6027\u4ee3\u7406\u670d\u52a1\u5668\u7684\u60c5\u51b5\uff1aDistorting Proxies<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>REMOTE_ADDR = \u4ee3\u7406\u670d\u52a1\u5668 IP<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>HTTP_VIA = \u4ee3\u7406\u670d\u52a1\u5668 IP<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>HTTP_X_FORWARDED_FOR = \u968f\u673a\u7684 IP \uff0c\u7ecf\u8fc7\u591a\u4e2a\u4ee3\u7406\u670d\u52a1\u5668\u65f6\uff0c\u8fd9\u4e2a\u503c\u7c7b\u4f3c\u5982\u4e0b\uff1a203.98.182.163, 203.98.182.163, 203.129.72.215\u3002<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>\u544a\u8bc9\u4e86\u8bbf\u95ee\u5bf9\u8c61\u60a8\u4f7f\u7528\u4e86\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u4f46\u7f16\u9020\u4e86\u4e00\u4e2a\u865a\u5047\u7684\u968f\u673aIP\u4ee3\u66ff\u60a8\u7684\u771f\u5b9eIP\u6b3a\u9a97\u5b83\u3002<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/><br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>\u4e94\u3001\u4f7f\u7528\u9ad8\u533f\u540d\u4ee3\u7406\u670d\u52a1\u5668\u7684\u60c5\u51b5\uff1aHigh Anonymity Proxies (Elite proxies)<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>REMOTE_ADDR = \u4ee3\u7406\u670d\u52a1\u5668 IP<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>HTTP_VIA = \u6ca1\u6570\u503c\u6216\u4e0d\u663e\u793a<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>HTTP_X_FORWARDED_FOR = \u6ca1\u6570\u503c\u6216\u4e0d\u663e\u793a \uff0c\u7ecf\u8fc7\u591a\u4e2a\u4ee3\u7406\u670d\u52a1\u5668\u65f6\uff0c\u8fd9\u4e2a\u503c\u7c7b\u4f3c\u5982\u4e0b\uff1a203.98.182.163, 203.98.182.163, 203.129.72.215\u3002<br style=\"box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px; background-color: #eeeeee;\" \/>\u5b8c\u5168\u7528\u4ee3\u7406\u670d\u52a1\u5668\u7684\u4fe1\u606f\u66ff\u4ee3\u4e86\u60a8\u7684\u6240\u6709\u4fe1\u606f\uff0c\u5c31\u8c61\u60a8\u5c31\u662f\u5b8c\u5168\u4f7f\u7528\u90a3\u53f0\u4ee3\u7406\u670d\u52a1\u5668\u76f4\u63a5\u8bbf\u95ee\u5bf9\u8c61\u3002<\/span><\/p>\n<p style=\"box-sizing: border-box; margin: 0px 0px 10px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff;\"><span style=\"box-sizing: border-box; font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', \u5fae\u8f6f\u96c5\u9ed1, Tahoma, Arial, sans-serif; font-size: 16px;\">\u00a0<\/span><\/p>\n<p style=\"box-sizing: border-box; margin: 0px 0px 10px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff;\"><span style=\"box-sizing: border-box; font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', \u5fae\u8f6f\u96c5\u9ed1, Tahoma, Arial, sans-serif; color: #ff0000; font-size: 16px;\">\u516d\u3001\u83b7\u53d6\u5ba2\u6237\u7aef\u771f\u5b9e\u7684IP\u5730\u5740\u5b9e\u4f8b\uff1a<\/span><\/p>\n<pre class=\"language-javascript\"><code>function get_real_ip() {\r\n\t$ip=FALSE;\r\n\t\/\/\u5ba2\u6237\u7aefIP \u6216 NONE\r\n\tif(!empty($_SERVER[\"HTTP_CLIENT_IP\"])) {\r\n\t\t$ip = $_SERVER[\"HTTP_CLIENT_IP\"];\r\n\t}\r\n\t\/\/\u591a\u91cd\u4ee3\u7406\u670d\u52a1\u5668\u4e0b\u7684\u5ba2\u6237\u7aef\u771f\u5b9eIP\u5730\u5740\uff08\u53ef\u80fd\u4f2a\u9020\uff09,\u5982\u679c\u6ca1\u6709\u4f7f\u7528\u4ee3\u7406\uff0c\u6b64\u5b57\u6bb5\u4e3a\u7a7a\r\n\tif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {\r\n\t\t$ips = explode (\", \", $_SERVER['HTTP_X_FORWARDED_FOR']);\r\n\t\tif ($ip) {\r\n\t\t\tarray_unshift($ips, $ip);\r\n\t\t\t$ip = FALSE;\r\n\t\t}\r\n\t\tfor ($i = 0; $i &lt; count($ips); $i++) {\r\n\t\t\tif (!eregi (\"^(10\u2502172.16\u2502192.168).\", $ips[$i])) {\r\n\t\t\t\t$ip = $ips[$i];\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\/\/\u5ba2\u6237\u7aefIP \u6216 (\u6700\u540e\u4e00\u4e2a)\u4ee3\u7406\u670d\u52a1\u5668 IP\r\n\treturn ($ip ? $ip : $_SERVER['REMOTE_ADDR']);\r\n}<\/code><\/pre>\n<p style=\"box-sizing: border-box; margin: 0px 0px 10px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff;\"><span style=\"box-sizing: border-box; font-size: 16px;\">\u8f6c\u8f7d\u5730\u5740\uff1a<a href=\"https:\/\/www.php.cn\/php-weizijiaocheng-406174.html\">https:\/\/www.php.cn\/php-weizijiaocheng-406174.html<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>php\u83b7\u53d6\u5ba2\u6237\u7aefIP\u5730\u5740\u6709\u56db\u79cd\u65b9\u6cd5\uff0c\u8fd9\u4e94\u79cd\u65b9\u6cd5\u5206\u522b\u4e3a REMOTE_ADDRHTTP_CLIENT_IPHTT [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"class_list":["post-387","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts\/387","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=387"}],"version-history":[{"count":0,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts\/387\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}