The school's news system requires some news to only open the campus IP browsing, and then rewrite a code to implement this function, the result is that, as long as the allowed IP access to ip.txt This file can be included, while supporting Class C
PHP: a summary of some practical user-defined functions and a summary of php user-defined functions. PHP: a summary of some practical user-defined functions, and a summary of php user-defined functions. I will share it with you for your reference.
The problem of getting the Internet IP address of the local machine is the same as that in the previous post.
Various methods to obtain the local Internet ip address, a variety of return: 1.
Most of them are caused by ipv6. However, the computer
1.REMOTE_ADDR: Browse the current page of the user's computer's IP address 2. Http_x_forwarded_for: Browse the current page of the user's computer Gateway 3. HTTP_CLIENT_IP: IP for Client
Use $_server["REMOTE_ADDR" in PHP to obtain the IP address of
"Summary" PHP common small function "probability, milliseconds, IP"
/** * Probability calculation * @param array (' A ' =>0.5, ' B ' =>0.2) * @return string (key of array, eg. ' A ' or ' B ') */function random ($ps) { $arr = array (); $key =
How PHP obtains the client's IP and the local province
For specific implementation code. Thank you..
------Solution--------------------
Provides several IP address APIs
Sina's IP address query interface:
Cause:
My colleague's friend's sister wants to participate in any voting activity and wants me to help brush the ticket. I agreed with my research attitude. I would like to share with you the ideas on ticket swiping.
Thoughts:
First, websites
1. generate random string functions
CopyCode The Code is as follows: function random ($ length ){
$ Hash = @#@#;
$ Chars =@# abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz @#;
$ Max = strlen ($ chars)-1;
Mt_srand (double) microtime
It mainly determines whether the client uses a proxy. Pay attention to the judgment order and first determine whether the client uses the proxy http_x_forwarded_for.
Function get_onlineip (){
$ Onlineip = '';If (getenv ('HTTP _ client_ip ') &
I have written several functions, and the IP blacklist is recorded in the library. for ease of understanding, I changed it to a class to write the IP blacklist. 192.168.1.1 single IP address
192.168.1. * proxy 192.168.1.1-192.168.1-255
192.158.1.2-20
Summary of differences between phpHTTP_X_FORWARDED_FOR, HTTP_VIA, and REMOTE_ADDR. This article introduces the differences between HTTP_X_FORWARDED_FOR, HTTP_VIA, and REMOTE_ADDR in php when obtaining the real IP address of a user. i. no proxy
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.