I made an IP judge city to jump, put in the public file on the presence of non-stop access to jump

Source: Internet
Author: User
Tags comparison table fread unpack
I made an IP judgment city for a two-level domain jump, File for ipaddress.php, put the file in the public file inside the open URL will appear nonstop access to jump, now there is any way to achieve this jump but do not have this endless access to the problem, I have the idea of using cookies, but do not know what to do, which elders help busy.


Reply to discussion (solution)

Is your so-called public file included in a lot of other documents?

Is your so-called public file included in a lot of other documents?


class files, configuration files, public function files, paging function files and the like, walking in a init.php, this init.php is a public file, each page will be called to

Put your code out.
Do not know how you write, how to know how to change?

 $useripNum | |        $userip 2num< $useripNum) {$Middle = Intval (($EndNum + $BeginNum)/2);        Offset pointer to index position read 4 bytes fseek ($FD, $useripbegin + 7 * $Middle);        $useripData 1 = fread ($FD, 4);            if (strlen ($useripData 1) < 4) {fclose ($FD);        Return ' File Error ';        }//Extracted Data conversion growth shaping, if the data is negative, plus 2 of the power of 32 $userip 1num = Implode (", Unpack (' L ', $useripData 1));        if ($userip 1num < 0) $userip 1num + = POW (2, 32);            Extract the number of long integers greater than our IP address then modify the end position to the next loop if ($userip 1num > $useripNum) {$EndNum = $Middle;        Continue        }//Take down an index after the previous index $DataSeek = Fread ($FD, 3);            if (strlen ($DataSeek) < 3) {fclose ($FD);        Return ' File Error ';        } $DataSeek = Implode (' ', Unpack (' L ', $DataSeek. chr (0)));        Fseek ($FD, $DataSeek);        $useripData 2 = fread ($FD, 4);            if (strlen ($useripData 2) < 4) {fclose ($FD);      Return ' File Error ';  } $userip 2num = Implode (' ', Unpack (' L ', $useripData 2));        if ($userip 2num < 0) $userip 2num + = POW (2, 32);                Could not find IP address corresponding to city if ($userip 2num < $useripNum) {if ($Middle = = $BeginNum) {fclose ($FD);            Return ' No Data ';        } $BeginNum = $Middle;    }} $useripFlag = Fread ($FD, 1);        if ($useripFlag = = Chr (1)) {$useripSeek = Fread ($FD, 3);            if (strlen ($useripSeek) < 3) {fclose ($FD);        Return ' System Error ';        } $useripSeek = Implode (' ', Unpack (' L ', $useripSeek. chr (0)));        Fseek ($FD, $useripSeek);    $useripFlag = Fread ($FD, 1);        } if ($useripFlag = = Chr (2)) {$AddrSeek = Fread ($FD, 3);            if (strlen ($AddrSeek) < 3) {fclose ($FD);        Return ' System Error ';        } $useripFlag = Fread ($FD, 1);            if ($useripFlag = = Chr (2)) {$AddrSeek 2 = fread ($FD, 3); if (strlen ($AddrSeek 2) < 3) {fclose ($FD);            Return ' System Error ';            } $AddrSeek 2 = Implode ("', Unpack (' L ', $AddrSeek 2.chr (0)));        Fseek ($FD, $AddrSeek 2);        } else {fseek ($FD,-1, seek_cur);        } while ($char = Fread ($FD, 1))! = Chr (0)) $useripAddr 2. = $char;        $AddrSeek = Implode (', Unpack (' L ', $AddrSeek. chr (0)));        Fseek ($FD, $AddrSeek);    while ($char = Fread ($FD, 1))! = Chr (0)) $useripAddr 1. = $char;        } else {fseek ($FD,-1, seek_cur);        while ($char = Fread ($FD, 1))! = Chr (0)) $useripAddr 1. = $char;        $useripFlag = Fread ($FD, 1);            if ($useripFlag = = Chr (2)) {$AddrSeek 2 = fread ($FD, 3);                if (strlen ($AddrSeek 2) < 3) {fclose ($FD);            Return ' System Error ';            } $AddrSeek 2 = Implode ("', Unpack (' L ', $AddrSeek 2.chr (0)));        Fseek ($FD, $AddrSeek 2);         } else {   Fseek ($FD,-1, seek_cur);        } while ($char = Fread ($FD, 1))! = Chr (0)) {$useripAddr 2. = $char;    }} fclose ($FD);    Returns the city result of the IP address if (preg_match ('/http/i ', $useripAddr 2)) {$useripAddr 2 = ';    } $useripaddr = "$useripAddr 1 $useripAddr 2";    $USERIPADDR = preg_replace ('/cz88.net/is ', ' ', $useripaddr);    $USERIPADDR = preg_replace ('/^s*/is ', ' ', $useripaddr);    $USERIPADDR = preg_replace ('/s*$/is ', ' ', $useripaddr);    if (Preg_match ('/http/i ', $useripaddr) | | $useripaddr = = ') {$useripaddr = ' No Data '; } return $useripaddr;}? > This is ipaddress.php page require (Root_path. ' include/config.php '); require (Root_path. ' include/smarty/smarty.class.php '); require (Root_path. ' include/mysql.class.php '); require (Root_path. ' include/action.class.php '); require (Root_path. ' include/check.class.php '); require (Root_path. ' include/page.class.php '); require (Root_path.   ' include/ipaddress.php '); This is the IP switch city. This is part of the public call file

Site has only one index.php page

, no matter what city is, always jump.
So where the hell do you want to go?

, no matter what city is, always jump.
So where the hell do you want to go?


Here I explain, this I have not added dynamic program, the default open is directly http://www.0971my.com, if in Xining, Open is also http://www.0971my.com, if it is other cities to jump to level two domain name

Now that you open the http://www.js0971.com/by default,
So in Xining, there's no need to jump.
if (City.indexof ("Xining City") >=0) {
Window.location.href= "http://www.js0971.com/";
}else{
Window.location.href= "http://bj.0971my.com/"; Not xining City need to jump
}

Now that you open the http://www.js0971.com/by default,
So in Xining, there's no need to jump.
if (City.indexof ("Xining City") >=0) {
Window.location.href= "http://www.js0971.com/";
}else{
Window.location.href= "http://bj.0971my.com/"; Not xining City need to jump
}


Now the problem is, as long as the opening of this URL is constantly in the access to jump, is the execution of the above code, now the question is how I know that the IP has been visited, directly open the city's domain name, not always jump

Do you want to comment out or not execute?
Do you judge in Bj.0971my.com also whether Xining city?

Do you want to comment out or not execute?
Do you judge in Bj.0971my.com also whether Xining city?


Moderator did not understand what I mean, the two-level domain name below is also the site, only the city is different, with a index.php page, so that will appear nonstop jump.

Different level two domain name, the discrimination condition also is different, you have written dead, of course not.

Different level two domain name, the discrimination condition also is different, you have written dead, of course not.


I didn't write to death.
This sentence I just put an example, the specific procedures I have not written into the inside, just test it out of the problem, mainly is the URL opened the first access is this index.php page and is the only page, the difference is different cities show different things. Now I have to solve is how to achieve this, how to do not appear in my above problems.

Is that people 58, different cities open different content, but are a index.php, or someone else to resolve to other folders, this I do not know.

Mark a city with a cookie or session, for example: Enter IP judgment jump for 0 o'clock and modify the tag city>0

In fact, you do not need this JS code
Since you are based on the user's IP jump corresponding to the two-level domain name, then you should have a city (region) and a two-level domain name of the table
When the city (region) from the IP name, from this table to jump on the two-level domain name can be (the header function), of course, and $_server[' http_host ') compared, it is no longer jump

In fact, you do not need this JS code
Since you are based on the user's IP jump corresponding to the two-level domain name, then you should have a city (region) and a two-level domain name of the table
When the city (region) from the IP name, from this table to jump on the two-level domain name can be (the header function), of course, and $_server[' http_host ') compared, it is no longer jump


City (region) and two-level domain name comparison Table I already have this, this is the code I judged below IPAddress:
 
  Query ("SELECT * from". $db->table (' area '). "Where title is like '% '. $city." % ' "), $row = $db->fetch_array ($sql), if (! $row) {header (" location:http//www.0971my.com ");} else{if ($row [' title ']== ' xining City ') {  header ("location:http://www.0971my.com");} else{  Header ("Location:". $row [' DNS ']. "");}? >

If you jump with the header (), it will be directly the result http://www.0971my.com/http//www.0971my.com

After the address is given a flag, for example, Transf=1, the page first accepts request[""]==1, do not perform judgment.
How can you say you're dead?

After the address is given a flag, for example, Transf=1, the page first accepts request[""]==1, do not perform judgment.
How can you say you're dead?


In this case click on the other page, that transf=1 is not lost, this is not necessary session or cookies?

Very simple, primary domain www.xxx.com
Sub-station domain name, bj.xxx.com, xa.xxx.com, gz.xxx.com ....

From the WWW request, according to the IP jump to the station, the station code does not need to jump, simply judge the domain name and then use the header () to jump on the good.

In fact, you do not need this JS code
Since you are based on the user's IP jump corresponding to the two-level domain name, then you should have a city (region) and a two-level domain name of the table
When the city (region) from the IP name, from this table to jump on the two-level domain name can be (the header function), of course, and $_server[' http_host ') compared, it is no longer jump


Moderator you said this how to judge it, hope to tell, thank you!

Very simple, primary domain www.xxx.com
Sub-station domain name, bj.xxx.com, xa.xxx.com, gz.xxx.com ....

From the WWW request, according to the IP jump to the station, the station code does not need to jump, simply judge the domain name and then use the header () to jump on the good.


The brain is a little short-circuited, do not know your that specific how to operate?

Thank you, everyone. I've got it, but there's still one more question. Considering that, is to select the city manually, is the cookie here a cross-domain access?

You are targeting a level two domain name, specifying the 4 parameters of the Setcookie

You are targeting a level two domain name, specifying the 4 parameters of the Setcookie


Thank you moderator answer, Setcookie parameters I have written, this question I will in another question inside put forward, hope moderator go to see, thank you!
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.