PHP determines whether a city can be switched to another city or redirect code based on the IP address. It is quite easy to get the IP address first. The following describes two codes for getting the IP address first. you need to use the QQIP
1#include 2#include 3#include 4 using namespacestd;5 #defineFILENAME "E:\\fushi\\test.txt"6 7 intMain ()8 {9 /*Ten Create a new file and write a file One FILE *FP; A Char f_name[30]; - Char Choise,in_char; - the printf ("\n\t Please enter the
Writing or reading data into a file is basically divided into three steps: 1. open a file (if any) 2. write Read File 3. close this file l open the file before opening the file, we need to know the path of the file and whether the file exists. Use
Get IP AddressCopy codeThe Code is as follows:Function GetIP (){If ($ _ SERVER ["HTTP_X_FORWARDED_FOR"])$ Ip = $ _ SERVER ["HTTP_X_FORWARDED_FOR"];Else if ($ _ SERVER ["HTTP_CLIENT_IP"])$ Ip = $ _ SERVER ["HTTP_CLIENT_IP"];Else if ($ _ SERVER
The following code judges the user's City Based on the IP address. php judges that the source code of the IP address is completely open.
The following code judges the user's City Based on the IP address. php judges that the source code of the IP
In the previous PHP Tutorial, I introduced how to use PHP to write files in file read/write operations, next, we will share with you the php file reading function of the application instance of the PHP file reading function, which involves more php
PhpIP retrieval City API (pure IP database)
/**
* Obtain the city name pure IP database based on the IP address
* Edit: bbs.it-home.org
*/
Function convertip ($ ip ){
// IP data file path
Php mail sending class (smtp or mail function)
This article introduces a class for sending email. you can use the smtp and mail functions to send emails. For more information, see.Php implements mail sending in two ways: smtp mode and mail
: This article describes how to copy files in PHP. For more information about PHP tutorials, see. Use fread fwrite fclose
1.
$ InputDir = "D:/ccc.txt"; $ outputDir = "D:/ddd.txt"; // whether the output directory if (! File_exists ($ outputDir) {$
File directory:
Iplocation-----Qqwry----------QQWry.Dat-----ipCity.class.php
ipCity.class.php File Code:Copy the Code code as follows:
Class IpCity {
/*** Obtain the corresponding city according to the IP address* @param type $userip User IP
To test, you need to download an IP database, and then save the php code I sent to the php file, and put the javascript code in the html file, to add more cities, you only need to copy elseif in javascript code several times to download an IP
File directory:
Iplocation-----Qqwry----------QQWry.Dat-----ipCity.class.php
ipCity.class.php File Code:Copy the Code code as follows:
Class IpCity {
/*** Obtain the corresponding city according to the IP address* @param type $userip User IP
Get IP Address
Copy CodeThe code is as follows:
function GetIP () {
if ($_server["http_x_forwarded_for"])
$ip = $_server["Http_x_forwarded_for"];
else if ($_server["HTTP_CLIENT_IP"])
$ip = $_server["Http_client_ip"];
else if ($_server["REMOTE_ADDR"
/**
* Get city name based on IP address pure IP database
* edit:bbs.it-home.org
*/
function Convertip ($IP) {
IP Data File path
$dat _path = ' QQWry.Dat ';
Check IP Address
if (!filter_var ($ip,
(
Article Category "C/C ++", but there are only basic instructions, for fear of forgetting in the future. Take a look at the relative details of this article and leave a memo)
C language file operation functions
Category: C/C13.1c language file1.
Void clearerr (File * stream); The feof function indicates the error flag used by clearerr () to clear the file stream specified by the stream parameter.Int fclose (File * stream ); Related functions close, fflush, fopen, and setbuf indicate that
Discuz 5.0 is not using their own IP data, but the use of pure IP data format, access to the pure IP database a little bit of trouble, its storage format is very special and interesting, specific format analysis refer to the following two links,
Use Fread fwrite fclose
1.
$inputDir = "D:/ccc.txt"; $outputDir = "d:/ddd.txt";//whether there is an output directory if (!file_exists ($outputDir)) {$dirs =fopen ($outputDir, ' W '); fclose ($dirs);} $handle =fopen ($inputDir, ' R '); $cfclose
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.