├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── config.php ├── index.php ├── plugins ├── TestPlugin.php └── UrlFormPlugin.php ├── setup.txt └── templates ├── main.php └── url_form.php /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/* 2 | /storage/* 3 | composer.lock 4 | .htaccess 5 | .idea 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | ![](https://img.shields.io/packagist/dt/Athlon1600/php-proxy-app.svg) ![](https://img.shields.io/github/last-commit/Athlon1600/php-proxy-app.svg) ![](https://img.shields.io/github/license/Athlon1600/php-proxy-app.svg) 5 | 6 |
7 | 8 | 9 | # php-proxy-app 10 | 11 | Web Proxy Application built on [**php-proxy library**](https://github.com/Athlon1600/php-proxy) ready to be installed on your server 12 | 13 | ![alt text](http://i.imgur.com/KrtU5KE.png?1 "This is how PHP-Proxy looks when installed") 14 | 15 | ## To Do List 16 | 17 | As of **March 25**, 2018: 18 | 19 | * Plugin for facebook.com 20 | * Plugin for dailymotion.com 21 | * Better support/documentation for Plugin Development 22 | * Better Javascript support 23 | 24 | ## Web-Proxy vs Proxy Server 25 | 26 | Keep in mind that sites/pages that are too script-heavy or with too many "dynamic parts", may not work with this proxy script. 27 | That is a known limitation of web proxies. For such sites, you should use an actual proxy server to route your browser's HTTP requests through: 28 | 29 | https://www.proxynova.com/proxy-software/ 30 | 31 | 32 | ## Installation 33 | 34 | Keep in mind that this is a **project** and not a library. Installing this via *require* would do you not good. 35 | A project such as this, should be installed straight into the public directory of your web server. 36 | 37 | ```bash 38 | composer create-project athlon1600/php-proxy-app:dev-master /var/www/ 39 | ``` 40 | 41 | If you do not have composer or trying to host this application on either a **shared hosting**, or a VPS hosting with limited permissions (dreamhost.com), then download a pre-installed version of this app as a ZIP archive from [**www.php-proxy.com**](https://www.php-proxy.com/). 42 | 43 | **Direct Link:** 44 | https://www.php-proxy.com/download/php-proxy.zip 45 | 46 | ## Keep it up-to-date 47 | 48 | Application itself rarely will change, vast majority of changes will be done to its requirement packages like php-proxy. Simply call this command once in a while to make sure your proxy is always using the latest versions. 49 | 50 | ``` 51 | composer update 52 | ``` 53 | 54 | #### config.php 55 | 56 | This file will be loaded into the global Config class. 57 | 58 | #### /templates/ 59 | 60 | This should have been named "views", but for historic purposes we keep it named as templates for now. 61 | 62 | #### /plugins/ 63 | 64 | PHP-Proxy provides many of its own native plugins, but users are free to write their own custom plugins, which could then be automatically loaded from this very folder. See /plugins/TestPlugin.php for an example. 65 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "athlon1600/php-proxy-app", 3 | "type": "project", 4 | "license": "MIT", 5 | "description": "Web proxy application project powered by PHP-Proxy library", 6 | "keywords": ["php proxy application", "php proxy web", "proxy script", "php web proxy", "web proxy"], 7 | "homepage": "https://www.php-proxy.com/", 8 | "require": { 9 | "athlon1600/php-proxy": "^5.0.1", 10 | "athlon1600/php-proxy-plugin-bundle": "dev-master" 11 | }, 12 | "scripts": { 13 | "post-create-project-cmd": [ 14 | "php -f setup.txt" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | '', 56 | // CURLOPT_CONNECTTIMEOUT => 5 57 | ); 58 | 59 | //$config['replace_title'] = 'Google Search'; 60 | 61 | //$config['error_redirect'] = "https://unblockvideos.com/#error={error_msg}"; 62 | //$config['index_redirect'] = 'https://unblockvideos.com/'; 63 | 64 | // $config['replace_icon'] = 'icon_url'; 65 | 66 | // this better be here other Config::load fails 67 | return $config; 68 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | Proxy::VERSION)); 67 | } 68 | 69 | exit; 70 | } 71 | 72 | // decode q parameter to get the real URL 73 | $url = url_decrypt($_GET['q']); 74 | 75 | $proxy = new Proxy(); 76 | 77 | // load plugins 78 | foreach (Config::get('plugins', array()) as $plugin) { 79 | 80 | $plugin_class = $plugin . 'Plugin'; 81 | 82 | if (file_exists('./plugins/' . $plugin_class . '.php')) { 83 | 84 | // use user plugin from /plugins/ 85 | require_once('./plugins/' . $plugin_class . '.php'); 86 | 87 | } elseif (class_exists('\\Proxy\\Plugin\\' . $plugin_class)) { 88 | 89 | // does the native plugin from php-proxy package with such name exist? 90 | $plugin_class = '\\Proxy\\Plugin\\' . $plugin_class; 91 | } 92 | 93 | // otherwise plugin_class better be loaded already through composer.json and match namespace exactly \\Vendor\\Plugin\\SuperPlugin 94 | // $proxy->getEventDispatcher()->addSubscriber(new $plugin_class()); 95 | 96 | $proxy->addSubscriber(new $plugin_class()); 97 | } 98 | 99 | try { 100 | 101 | // request sent to index.php 102 | $request = Request::createFromGlobals(); 103 | 104 | // remove all GET parameters such as ?q= 105 | $request->get->clear(); 106 | 107 | // forward it to some other URL 108 | $response = $proxy->forward($request, $url); 109 | 110 | // if that was a streaming response, then everything was already sent and script will be killed before it even reaches this line 111 | $response->send(); 112 | 113 | } catch (Exception $ex) { 114 | 115 | // if the site is on server2.proxy.com then you may wish to redirect it back to proxy.com 116 | if (Config::get("error_redirect")) { 117 | 118 | $url = render_string(Config::get("error_redirect"), array( 119 | 'error_msg' => rawurlencode($ex->getMessage()) 120 | )); 121 | 122 | // Cannot modify header information - headers already sent 123 | header("HTTP/1.1 302 Found"); 124 | header("Location: {$url}"); 125 | 126 | } else { 127 | 128 | echo render_template("./templates/main.php", array( 129 | 'url' => $url, 130 | 'error_msg' => $ex->getMessage(), 131 | 'version' => Proxy::VERSION 132 | )); 133 | 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /plugins/TestPlugin.php: -------------------------------------------------------------------------------- 1 | getUri(); 16 | 17 | // we attach url_form only if this is a html response 18 | if (!is_html($response->headers->get('content-type'))) { 19 | return; 20 | } 21 | 22 | // this path would be relative to index.php that included it? 23 | $url_form = render_template("./templates/url_form.php", array( 24 | 'url' => $url 25 | )); 26 | 27 | $output = $response->getContent(); 28 | 29 | // remove favicon if so 30 | if (Config::get('replace_icon')) { 31 | 32 | $output = preg_replace_callback('/]+rel=".*?(?:shortcut|icon).*?"[^>]+>/', function ($matches) { 33 | return ""; 34 | }, $output); 35 | } 36 | 37 | // does the html page contain tag, if so insert our form right after tag starts 38 | $output = preg_replace('@@is', '$0' . PHP_EOL . $url_form, $output, 1, $count); 39 | 40 | // tag was not found, just put the form at the top of the page 41 | if ($count == 0) { 42 | $output = $url_form . $output; 43 | } 44 | 45 | $response->setContent($output); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /setup.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /templates/main.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PHP-Proxy 6 | 7 | 8 | 9 | 10 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
52 | 53 |
54 |

PHP-Proxy

55 |
56 | 57 | 58 | 59 |
60 |

61 |
62 | 63 | 64 | 65 |
66 | 67 | 68 | 69 |
70 | 71 | 72 |
73 | 74 | 77 | 78 | 79 | 80 |
81 | 82 |
83 | 84 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /templates/url_form.php: -------------------------------------------------------------------------------- 1 | 2 | 40 | 41 | 59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 | 67 | 68 | 69 |
70 | 71 |
72 | 73 |
74 | 75 | 78 | --------------------------------------------------------------------------------