search
Homephp教程php手册php多城市切换

php多城市切换

Jun 06, 2016 pm 07:39 PM
phpcontentswitchCitydetailed

无详细内容 PHP MyBlog ?php/**///??è?ip/*include_once('./qqwry.php');$QQWry=new QQWry; function get_real_ip(){$ip=false;if(!empty($_SERVER["HTTP_CLIENT_IP"])){$ip = $_SERVER["HTTP_CLIENT_IP"];}if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {

PHP MyBlog
<?php

/*



*/

//??è?ip
/*include_once('./qqwry.php');
$QQWry=new QQWry; 

function get_real_ip(){
$ip=false;
if(!empty($_SERVER["HTTP_CLIENT_IP"])){
$ip = $_SERVER["HTTP_CLIENT_IP"];
}
if (!empty($_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;
}

function is_ip($str) {
    $ip = explode(".", $str);
    if (count($ip)<4 || count($ip)>4) return 0;
    foreach($ip as $ip_addr) {
        if ( !is_numeric($ip_addr) ) return 0;
        if ( $ip_addr<0 || $ip_addr>255 ) return 0;
    }
    return 1;
}


$ip=$_SERVER['REMOTE_ADDR']; 
$ifErr=$QQWry->QQWry($ip); 
$city = $QQWry->Country.$QQWry->Local;

//echo $city;*/


if (strpos($city,'玄武区')!==false){
	$city = "玄武区";
}
else if(strpos($city,'仙林')!==false){
	$city = "仙林";
}
else if(strpos($city,'秦淮区')!==false){
	$city = "秦淮区";
}
else if(strpos($city,'江宁')!==false){
	$city = "江宁";
}
else if(strpos($city,'鼓楼')!==false){
	$city = "鼓楼";
}
else{
	$city = "栖霞";
}




if (isset($_GET['chengshi'])) { //ê×?è?ì2aê?·???μ?á? GET ′?μYμ?êy?Y    
setcookie("cookie_city",$_GET['chengshi'],time()+3600*24);
$city = $_GET['chengshi']; 
} 
else if (isset($_COOKIE["cookie_city"])) { //?ì2aê?·?′??úê?3?Cookie   
$city = $_COOKIE["cookie_city"]; //??ê?Cookie±£′?μ?êy?Y 
} 
else {   
setcookie("cookie_city",$city,time()+3600*24); //′?3?ê??ˉ′?±?á? 
$_COOKIE["cookie_city"] = $city;
} 




?>



<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8"/>
<LINK href="css/css.css" type=text/css rel=stylesheet>
<SCRIPT src="js/jquery-1.4.2.min.js" type=text/javascript></SCRIPT>
<title>城市切换</title>
</head>

<BODY>

<DIV class=selCity id=allCity style="DISPLAY: none">
<DIV class=area>
<TABLE>
  <TBODY>
  <TR>
    <TD><A class=cur href="show.html">玄武区</A></TD>
    <TD><A href="show1.html">仙林</A></TD>
    <TD><A href="show2.html">秦淮区</A></TD>
    <TD><A href="show3.html">鼓楼</A></TD>
    <TD><A href="show4.html">江宁</A></TD>
    <TD><A href="show5.html">栖霞区</A></TD>
  </TR>
  </TBODY></TABLE>
<DIV class=none><A id=foldin href="javascript:;">全部</A></DIV></DIV></DIV>
<DIV class=header>
	<DIV class=area>
		<DIV class=r>
			<DIV class="topCtiy clear">
				<UL>
				
				<LI class=i1><A href="index.php">全部小区</A></LI>
				
				  <LI class=i1>
				  <?php 
				  echo $city; 
				  ?>
				  </LI>
				  <LI class=i2 id=changeCity>切换城市</LI>
				</UL>
			</DIV>
		</DIV>
	</DIV>
</DIV>
<SCRIPT type=text/javascript>
jQuery(function(){
	$("#changeCity").click(function(a){
		$("#allCity").slideDown(300);
		a.stopPropagation();
		$(this).blur();
	});
	$("#allCity").click(function(a){
		a.stopPropagation()
	});
	$(document).click(function(a){
		a.button!=2 && $("#allCity").slideUp(300)
	});
	$("#foldin").click(function(){
		$("#allCity").slideUp(300)
	});
});

</SCRIPT>

</body>
</html>


Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.