Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of displaying the visitor's ip address on the home page of dream weaving

Shulou Source: shulou.com Published: 2022-06-02 05:08:00 10月05日 Update

This article will explain in detail the method of displaying the IP address of the visitor on the home page of Dream Weaving. Xiaobian thinks it is quite practical, so share it with you as a reference. I hope you can gain something after reading this article.

How does the home page show visitors ip address?

Home page insert php code show visitor ip address

Recommended Learning: Weaving Dreams CMS

Put the following code where you want it

{dede:php} $user_IP = ($_SERVER["HTTP_VIA"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : $_SERVER["REMOTE_ADDR"]; $user_IP = ($user_IP) ? $user_IP : $_SERVER["REMOTE_ADDR"]; function get_real_ip(){ $ip=false; if(! emptyempty($_SERVER["HTTP_CLIENT_IP"])){ $ip = $_SERVER["HTTP_CLIENT_IP"]; } if (! emptyempty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']); if ($ip) { array_unshift($ips, $ip); $ip = FALSE; } for ($i = 0; $i < count($ips); $i++) { if (! eregi ("^(10│172.16│192.168). ", $ips[$i])) { $ip = $ips[$i]; break; } } } return ($ip ? $ip : $_SERVER['REMOTE_ADDR']); } echo "YOUR IP ". " ". get_real_ip(); {/dede:php} About the method of displaying the IP address of the visitor on the home page of Dream Weaving, I hope the above content can be of some help to everyone and can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

Tags: Address visitor home page method code more article good practical location content article knowledge reference learning help recommendation related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Linux Huawei Apple MariaDB