项目
在 GitHub 查看
Athlon1600/php-proxy
关于
使用 PHP 编写的 Web 代理脚本,旨在作为 Glype 的替代方案。
系统与基础设施实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文
php-proxy
Proxy script built on PHP, Symfony and cURL. This library borrows ideas from Glype, Jenssegers proxy, and Guzzle.
PHP-Proxy Web Application
If you're looking for a project version of this script that functions as a Web Application similar to Glype, then visit php-proxy-app
See this php-proxy in action: proxy.unblockvideos.com
Installation
Install it using Composer:
composer require athlon1600/php-proxy
Example
require('vendor/autoload.php');
use Proxy\Http\Request;
use Proxy\Proxy;
$request = Request::createFromGlobals();
$proxy = new Proxy();
$proxy->getEventDispatcher()->addListener('request.before_send', function($event){
$event['request']->headers->set('X-Forwarded-For', 'php-proxy');
});
$proxy->getEventDispatcher()->addListener('request.sent', function($event){
if($event['response']->getStatusCode() != 200){
die("Bad status code!");
}
});
$proxy->getEventDispatcher()->addListener('request.complete', function($event){
$content = $event['response']->getContent();
$content .= '<!-- via php-proxy -->';
$event['response']->setContent($content);
});
$response = $proxy->forward($request, "http://www.yahoo.com");
// send the response back to the client
$response->send();
Plugin Example
namespace Proxy\Plugin;
use Proxy\Plugin\AbstractPlugin;
use Proxy\Event\ProxyEvent;
use Proxy\Html;
class MultiSiteMatchPlugin extends AbstractPlugin {
// Matches multiple domain names (abc.com, abc.de, abc.pl) using regex (you MUST use / character)
protected $url_pattern = '/^abc\.(com|de|pl)$/is';
// Matches a single domain name
//protected $url_pattern = 'abc.com';
public function onCompleted(ProxyEvent $event){
$response = $event['response'];
$html = $response->getContent();
// do your stuff here...
$response->setContent($html);
}
}
Notice that you must use the / character for regexes on $url_pattern
探索相关项目
加载中…