Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Imperial CMS jump to different pages according to ip?

2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

How does Imperial CMS jump to different pages according to ip? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

The code is as follows:

After the client IP address is obtained by the above method, the convertip function is passed into the real address. The code of the convertip ($ip) function is as follows:

The code is as follows:

/ / function: IP address gets the real address function / / Parameter: $ip-IP address / / = = function convertip ($ip) {/ / IP data file path $dat_path = 'QQWry.dat';// check IP address if (! ereg ("^ ([0-9] {1 ip 3}.) {3} [0-9] {1 @ 3} $", $ip)) {return' IP Address Error' } / / Open the IP data file if (! $fd = @ fopen ($dat_path, 'rb')) {return' IP date file not exists or access denied';} / / decompose the IP to get the shaping number $ip = explode ('.', $ip); $ipNum = $ip [0] * 16777216 + $ip [1] * 65536 + $ip [2] * 256 + $ip [3]; / / get the IP data index start and end location $DataBegin = fread ($fd, 4) $DataEnd = fread ($fd, 4); $ipbegin = implode (', unpack ('DataBegin, $DataBegin)); if ($ipbegin)

< 0) $ipbegin += pow(2, 32);$ipend = implode('', unpack('L', $DataEnd));if($ipend < 0) $ipend += pow(2, 32);$ipAllNum = ($ipend - $ipbegin) / 7 + 1;$BeginNum = 0;$EndNum = $ipAllNum;//使用二分查找法从索引记录中搜索匹配的IP记录while($ip1num>

$ipNum | | $ip2num $ipNum) {$EndNum = $Middle;continue;} / / after fetching the previous index, take the next index $DataSeek = fread ($fd, 3); if (strlen ($DataSeek)

< 3) {fclose($fd);return 'System Error';}$DataSeek = implode('', unpack('L', $DataSeek.chr(0)));fseek($fd, $DataSeek);$ipData2 = fread($fd, 4);if(strlen($ipData2) < 4) {fclose($fd);return 'System Error';}$ip2num = implode('', unpack('L', $ipData2));if($ip2num < 0) $ip2num += pow(2, 32);//没找到提示未知if($ip2num < $ipNum) {if($Middle == $BeginNum) {fclose($fd);return 'Unknown';}$BeginNum = $Middle;}}//下面的代码读晕了,没读明白,有兴趣的慢慢读$ipFlag = fread($fd, 1);if($ipFlag == chr(1)) {$ipSeek = fread($fd, 3);if(strlen($ipSeek) < 3) {fclose($fd);return 'System Error';}$ipSeek = implode('', unpack('L', $ipSeek.chr(0)));fseek($fd, $ipSeek);$ipFlag = fread($fd, 1);}if($ipFlag == chr(2)) {$AddrSeek = fread($fd, 3);if(strlen($AddrSeek) < 3) {fclose($fd);return 'System Error';}$ipFlag = fread($fd, 1);if($ipFlag == chr(2)) {$AddrSeek2 = fread($fd, 3);if(strlen($AddrSeek2) < 3) {fclose($fd);return 'System Error';}$AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0)));fseek($fd, $AddrSeek2);} else {fseek($fd, -1, SEEK_CUR);}while(($char = fread($fd, 1)) != chr(0))$ipAddr2 .= $char;$AddrSeek = implode('', unpack('L', $AddrSeek.chr(0)));fseek($fd, $AddrSeek);while(($char = fread($fd, 1)) != chr(0))$ipAddr1 .= $char;} else {fseek($fd, -1, SEEK_CUR);while(($char = fread($fd, 1)) != chr(0))$ipAddr1 .= $char;$ipFlag = fread($fd, 1);if($ipFlag == chr(2)) {$AddrSeek2 = fread($fd, 3);if(strlen($AddrSeek2) < 3) {fclose($fd);return 'System Error';}$AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0)));fseek($fd, $AddrSeek2);} else {fseek($fd, -1, SEEK_CUR);}while(($char = fread($fd, 1)) != chr(0)){$ipAddr2 .= $char;}}fclose($fd);//最后做相应的替换操作后返回结果if(preg_match('/http/i', $ipAddr2)) {$ipAddr2 = '';}$ipaddr = "$ipAddr1 $ipAddr2";$ipaddr = preg_replace('/CZ88.Net/is', '', $ipaddr);$ipaddr = preg_replace('/^s*/is', '', $ipaddr);$ipaddr = preg_replace('/s*$/is', '', $ipaddr);if(preg_match('/http/i', $ipaddr) || $ipaddr == '') {$ipaddr = 'Unknown';}return $ipaddr;}?>

When using it, use the convertip function to obtain the real address based on the IP address, and then use the following js code to achieve the jump function:

The code is as follows:

Var sf='';// the sf variable here can save the real address obtained by the PHP function if (sf.indexOf ("Hong Kong") > = 0) {_ window.location.href= "http://www.****.com/? Hong Kong";} else if (sf.indexOf ("Guangdong") > = 0) {_ window.location.href= "http://www.****.com/? Guangdong";} Thank you for reading! After reading the above, do you have a general idea of how Imperial CMS can jump to different pages according to ip? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report