PHP-引荐来源重定向脚本 [英] PHP - Referer redirect script

查看:103
本文介绍了PHP-引荐来源重定向脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,在搜索答案时,我发现某些网站允许您在引荐来源为google.com的情况下阅读它们提供的信息.但是,如果您直接链接到该信息,将无法使用.

Often, when searching for answers, I have found that certain websites will allow you to read the information they offer if the referer is, for example, google.com. Yet, if you link directly to the information, it will be unavailable.

我正在寻找的是最小的PHP脚本,它将设置我选择的引荐来源和目的地,例如:

What I am looking for is the smallest PHP script that will set a referer of my choice, and a destination, like so:

http://example.com/ref_red.php?referer=http://google.com/&end=http://example.net/

注意:

  • ref_red.php 是我的示例中脚本的名称.
  • 引荐 end 应该接受 http https ftp . /li>
  • 引荐来源结束可以包含任何类型的URI,就像 http://end.com 或复杂程度如下: 例如http://example.com/some/rr/print.pl?document=rr.
  • ref_red.php is the name of the script on my example.
  • referer and end should accept http, https, ftp.
  • referer and end can contain an URI of any type, as simple as http://end.com or as complicated as: http://example.com/some/rr/print.pl?document=rr, for example.

注意::我在答复中建议添加此内容.该脚本本身不是完整的代理. 只有初始的HTTP请求会被代理(而不是后续的请求,如图像等)是出于设置引荐来源的唯一目的.

NOTE: As recommended on a reply, I am adding this. The script isn't a full proxy per se. Only initial HTTP request would be proxied (not subsequent requests like images,etc) for the sole purpose of setting the referer.

推荐答案

此功能应为您提供一个起点 它将使用指定的引荐来源网址

this function should give you a starting point it will fetch any http url with the specified referrer

处理查询参数应该很简单,所以我将把这部分留给您做

handling the query parms should be pretty trivial, so i will leave that part for you to do

<?php

    echo geturl('http://some-url', 'http://referring-url');

    function geturl($url, $referer) { 

        $headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg,text/html,application/xhtml+xml'; 
        $headers[] = 'Connection: Keep-Alive'; 
        $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'; 
        $useragent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)'; 

        $process = curl_init($url); 
        curl_setopt($process, CURLOPT_HTTPHEADER, $headers); 
        curl_setopt($process, CURLOPT_HEADER, 0); 
        curl_setopt($process, CURLOPT_USERAGENT, $useragent);
        curl_setopt($process, CURLOPT_REFERER, $referer);
        curl_setopt($process, CURLOPT_TIMEOUT, 30); 
        curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1); 

        $return = curl_exec($process); 
        curl_close($process); 

        return $return; 
    } 

?>

这篇关于PHP-引荐来源重定向脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆