Home > CMS Tutorial > DEDECMS > body text

How to display the visitor's IP address on the DreamWeaver homepage

藏色散人
Release: 2020-01-04 09:49:38
Original
3199 people have browsed it

How to display the visitor's IP address on the DreamWeaver homepage

How to display the visitor’s IP address on the Dreamweaver homepage?

Insert the php code on the homepage of DEDECMS to display the visitor's IP address

Recommended learning: DDEECMS

Put it where needed The following code

{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[&#39;REMOTE_ADDR&#39;]);  
}  
echo "YOUR IP "." ". get_real_ip(); 
{/dede:php}
Copy after login

The above is the detailed content of How to display the visitor's IP address on the DreamWeaver homepage. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template