This article describes in detail the PHP anti-leeching $ _ SERVER [& amp; quot] and its usage.
| We will introduce a php code to prevent leeching. it mainly uses $ _ SERVER ["HTTP_REFERER"]. if you have any need, refer to this document.
The code is as follows:
Http://bbs.it-home.org */session_start (); if (! Isset ($ _ SESSION ['id']) or! Isset ($ _ SESSION ['member']) {echo ""; // verify session exit ();} $ ref = $ _ SERVER ['http _ referer']; if ($ ref = '') {echo 'Sorry, access from address bar is not allowed';} else {$ url = parse_url ($ ref ); if ($ url [host]! = '1970. 0.0.1 '& $ url [host]! = 'Localhost') {echo 'leeching not allowed '; exit () ;}}?>
Description of "HTTP_REFERER": The URL of the previous page linked to the current page. Not all user proxies (browsers) will set this variable, and some can also manually modify HTTP_REFERER. Therefore, this variable is not always true and correct.
Summary: HTTP_REFERER environment variables are available only on the page opened by clicking a hyperlink (that is), and other variables such as window. open (), window. location =..., window. showModelessDialog () and other open windows do not have the HTTP_REFERER environment variable. |
The above is an example of PHP's use to prevent leeching $ _ SERVER ["HTTP_REFERER"]. For more information, see The PHP Chinese website (www.php1.cn )!