Perfect compatibility of the major browsers to obtain Http_referer methods to summarize _javascript skills

Source: Internet
Author: User

Later checked some relevant data, found in IE through window.location.href or is not able to get http_referer, really do not understand IE browser, a lot of browsers run very good things, it is not supported, finally there is no way, PHP can only forge the source Http_referer method or use JS to forge.

IE can be identified by the Http_referer commit is triggered by the click of the event or form form submitted by the request, the following is based on the online data summarized a method:

<script>
function Referurl (URL) {
var isie= (document.all)? True:false;
if (Isie) {
var Linka = document.createelement (' a ');
Linka.href=url;
Document.body.appendChild (Linka);
Linka.click ();
}
else window.location = URL;

var url= "http://www.jb51.net";
Referurl (URL);
</script>

This method first uses document.all to determine whether the current browser is IE, if it is a link, and then automatically execute the onclick event, if not the words will use JS jump. So you can get http_referer in the process page.

This method is tested via IE, Firefox, Safari, and Chrome

2. PHP uses curl to forge IP and routing http referrer

referer.php

<?php
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, "http://mydomain.com/ip.php");
curl_setopt ($ch, Curlopt_httpheader, Array (' x-forwarded-for:8.8.8.8 ', ' client-ip:8.8.8.8 ')); Construct IP
curl_setopt ($ch, Curlopt_referer, "http://www.jb51.net/");  Tectonic antecedents
curl_setopt ($ch, Curlopt_header, 1);
$out = curl_exec ($ch);
Curl_close ($ch);

Echo $out;

ip.php

<?php
function Getclientip () {
if (!empty ($_server["Http_client_ip"))
$ip = $_server["Http_ Client_ip "];
else if (!empty ($_server["http_x_forwarded_for"]))
$ip = $_server["Http_x_forwarded_for"];
else if (!empty ($_server["REMOTE_ADDR"]))
$ip = $_server["REMOTE_ADDR"];
else
$ip = "err";
return $ip;
}
echo "IP:". Getclientip (). "<br>";
echo "Referer:". $_server["Http_referer"];

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.