Skip to content

Commit feecc86

Browse files
committed
Updated to v2.1
1 parent b992bf7 commit feecc86

14 files changed

+2503
-2371
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/.idea/*
44

55
!/cookies/index.html
6-
!/cache/index.html
6+
!/cache/index.html
7+
/vendor/

README.md

Lines changed: 75 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
# [PHP] Ultra Small Proxy 2
2-
### PHP: 7.0+
2+
### PHP: 7.2.5+
33

4-
Current version: **2.0** | 2022-02-23
4+
Current version: **2.1** | 2022-04-23
55

66
Ultra Small Proxy is a light-weight proxy written in PHP.
77

8-
## Key Features:
8+
**Install with composer:**
9+
```
10+
composer require szczyglis/php-ultra-small-proxy
11+
```
12+
13+
## Features:
914

1015
- Proxy server written in PHP
1116
- Easy usage and integration
12-
- Standalone and external usage (it is only one PHP file)
1317
- Simple and light-weight
1418
- Sessions support
1519
- Sending and receiving cookies
16-
- Sending and receiving HTTP headers **(NEW in 2.0+)**
17-
- Cache and assets storage **(NEW in 2.0+)**
18-
- Domain and IP/host connection support **(NEW in 2.0+)**
19-
- HTTP Basic Auth support **(NEW in 2.0+)**
20+
- Sending and receiving HTTP headers
21+
- Cache and assets storage
22+
- Domain and IP/host connection support
23+
- HTTP Basic Auth support
2024
- GET and POST connections
2125
- Forms submiting support
2226
- POST variables redirecting
2327
- Toolbar with address bar, configuration and debugger
2428
- URLs rewriting/proxying at runtime (links, images, css, javascript, etc.)
25-
- 2 different methods for URLs rewriting: Regex (with preg_replace) and DOM XML (with libxml / DOMDocument)
26-
- PHP 7.0+ supported
29+
- 2 different methods for URLs rewriting: Regex (with preg_replace) and XML (with libxml/DOM)
30+
- PHP 7.2.5+ supported
2731

2832
## Requirements:
2933

30-
- PHP 7.0+
31-
- CURL extension
32-
- DOM XML extension
34+
- PHP 7.2.5+ with CURL and XML extensions
35+
- Composer
36+
3337

3438
## Usage example:
35-
```
39+
```php
3640
<?php
3741

38-
/* include classes */
39-
include __DIR__.'/UltraSmallProxy.php';
42+
require __DIR__ . '/vendor/autoload.php';
4043

41-
/* instantiate config */
42-
$config = new UltraSmallProxyConfig();
44+
use Szczyglis\UltraSmallProxy\UltraSmallProxy;
45+
use Szczyglis\UltraSmallProxy\Config;
4346

44-
/* instantiate proxy with config */
45-
$proxy = new UltraSmallProxy($config);
47+
$config = new Config();
4648

47-
/* specify start page and load it! */
48-
$output = $proxy->load('https://github.com');
49+
$proxy = new UltraSmallProxy($config);
4950

50-
/* render output */
51-
echo $output;
51+
echo $proxy->load('https://github.com'); // <-- specify start page here
5252

5353
```
5454
Make sure to have write permissions to `./cookies` and `./cache` directories.
@@ -60,109 +60,118 @@ Make sure to have write permissions to `./cookies` and `./cache` directories.
6060
![proxy](https://user-images.githubusercontent.com/61396542/155353063-fde84995-6e43-46c4-8a1c-b8b4772e6dfc.png)
6161

6262

63-
Open `loopback.php`if you want to test proxy features like sessions support, POST vars redirecting, form submiting and more, e.g.:
63+
Open `loopback.php` if you want to test proxy features like sessions support, POST vars redirecting, form submiting and more, e.g.:
6464
```
6565
<?php
6666
$output = $proxy->load('http://localhost/loopback.php');
6767
```
6868

6969
## Repository contents:
7070

71-
- `UltraSmallProxy.php` - proxy class
71+
- `src/` - proxy classes
72+
7273
- `index.php` - usage example
74+
7375
- `loopback.php` - loopback for test features like session support, form vars sending, and cookies redirecting
7476

7577

7678
## Basic usage:
7779

78-
```
79-
$config = new UltraSmallProxyConfig();
80+
```php
81+
use Szczyglis\UltraSmallProxy\UltraSmallProxy;
82+
use Szczyglis\UltraSmallProxy\Config;
83+
84+
$config = new Config();
8085
$proxy = new UltraSmallProxy($config);
8186

8287
echo $proxy->load('https://github.com');
8388
```
8489

8590
## Configuration:
8691

87-
```
92+
```php
8893
$output = $proxy->load('https://github.com', $force = false);
8994
```
90-
`$force` - if set to `false` then URLs given from QUERY STRING are always overwriting URLs passed here, set to `true` if you want to reverse this behaviour, default: `false`
95+
boolean `$force` - if set to `false` then URLs given from QUERY STRING are always overwriting URLs passed here, set to `true` if you want to reverse this behaviour, default: `false`
9196

9297

9398
## Config values:
9499

95-
Before page load:
100+
**Before page load:**
96101

97-
`$config->set('init', bool);`- auto-init `true|false`, default: `true`
102+
**$config->set('init', true)** - `boolean`, auto-init `true|false`, default: `true`
98103

99-
`$config->set('source', 'string');` - input source `domain|ip`, default: `domain`
104+
**$config->set('source', 'domain')** - `string`, input source `domain|ip`, default: `domain`
100105

101-
`$config->set('raw', bool);` - raw download `true|false`, default: `false`
106+
**$config->set('raw', false)** - `boolean`, raw download `true|false`, default: `false`
102107

103-
`$config->set('toolbar', bool);` - attach toolbar `true|false`, default: `true`
108+
**$config->set('toolbar', true)** - `boolean`, attach toolbar `true|false`, default: `true`
104109

105-
`$config->set('user_agent', 'string');` - user agent, default: `Mozilla/4.0 (compatible;)`
110+
**$config->set('user_agent', 'Mozilla/4.0 (compatible;)')** - `string`, user agent, default: `Mozilla/4.0 (compatible;)`
106111

107-
`$config->set('timeout', int);` - curl timeout, default: `120`
112+
**$config->set('timeout', 120)** - `int`, curl timeout, default: `120`
108113

109-
`$config->set('max_redirects', int);` - curl max redirects, default: `10`
114+
**$config->set('max_redirects', 10)** - `int`, curl max redirects, default: `10`
110115

111-
`$config->set('cookies_dir', 'string');` - cookies directory, default: `./cookies`
116+
**$config->set('cookies_dir', './cookies')** - `string`, cookies directory, default: `./cookies`
112117

113-
`$config->set('cache_dir', 'string');` - cache directory, default: `./cache`
118+
**$config->set('cache_dir', './cache')** - `string`, cache directory, default: `./cache`
114119

115-
`$config->set('method', 'string');` - request method `GET|POST`
120+
**$config->set('method', 'GET')** - `string`, request method `GET|POST`
116121

117-
`$config->set('rewrite', 'string');` - rewrite method `REGEX,REGEX2,REGEX3,DOM`, default: `REGEX2`
122+
**$config->set('rewrite', 'REGEX2')** - `string`, rewrite method `REGEX,REGEX2,REGEX3,DOM`, default: `REGEX2`
118123

119-
`$config->set('rewrite_url', bool);` - enable URL rewriting `true|false`, default: `true`
124+
**$config->set('rewrite_url', true)** - `boolean`, enable URL rewriting `true|false`, default: `true`
120125

121-
`$config->set('rewrite_img', bool);` - enable IMG rewriting `true|false`, default: `true`
126+
**$config->set('rewrite_img', true)** - `boolean`, enable IMG rewriting `true|false`, default: `true`
122127

123-
`$config->set('rewrite_js', bool);` - enable JS rewriting `true|false`, default: `true`
128+
**$config->set('rewrite_js', true)** - `boolean`, enable JS rewriting `true|false`, default: `true`
124129

125-
`$config->set('rewrite_form', bool);` - enable FORM ACTION rewriting `true|false`, default: `true`
130+
**$config->set('rewrite_form', true)** - `boolean`, enable FORM ACTION rewriting `true|false`, default: `true`
126131

127-
`$config->set('rewrite_css', bool);` - enable CSS rewriting `true|false`, default: `true`
132+
**$config->set('rewrite_css', true)** - `boolean`, enable CSS rewriting `true|false`, default: `true`
128133

129-
`$config->set('rewrite_video', bool);` - enable VIDEO rewriting `true|false`, default: `true`
134+
**$config->set('rewrite_video', true)** - `boolean`, enable VIDEO rewriting `true|false`, default: `true`
130135

131-
`$config->set('rewrite_ip', bool);` - enable domain to IP+Host resolve `true|false`, default: `true`
136+
**$config->set('rewrite_ip', true)** - `boolean`, enable domain to IP+Host resolve `true|false`, default: `true`
132137

133-
`$config->set('assets', 'string');` - assets proxying mode `REDIRECT|CURL`, default: `REDIRECT`
138+
**$config->set('assets', 'REDIRECT')** - `string`, assets proxying mode `REDIRECT|CURL`, default: `REDIRECT`
134139

135-
`$config->set('is_cfg', bool);` - show options `true|false`, default: `false`
140+
**$config->set('is_cfg', false)** - `boolean`, show options `true|false`, default: `false`
136141

137-
`$config->set('is_dbg', bool);` - show debug `true|false`, default: `false`
142+
**$config->set('is_dbg', false)** - `boolean`, show debug `true|false`, default: `false`
138143

139-
`$config->set('htaccess_user', 'string');` - HTTP AUTH user
144+
**$config->set('htaccess_user', 'user')** - `string`, HTTP AUTH user
140145

141-
`$config->set('htaccess_pass', 'string');` - HTTP AUTH password
146+
**$config->set('htaccess_pass', 'pass')** - `string`, HTTP AUTH password
142147

143148

144149
## Public methods:
145150

146-
After page load:
151+
**After page load:**
147152

148-
`$siteCookies = $proxy->cookie->getSiteCookies()` - returns cookies[] received from proxied site
153+
**$siteCookies = $proxy->cookie->getSiteCookies()** - returns cookies[] received from proxied site
149154

150-
`$localCookies = $proxy->cookie->getLocalCookies()` - returns cookies[] stored localy and sended to proxied site
155+
**$localCookies = $proxy->cookie->getLocalCookies()** - returns cookies[] stored localy and sended to proxied site
151156

152-
`$status = $proxy->http->getStatus()` - returns connection status[]
157+
**$status = $proxy->http->getStatus()** - returns connection status[]
153158

154-
`$headers = $proxy->http->getHeaders()` - returns received headers[]
159+
**$headers = $proxy->http->getHeaders()** - returns received headers[]
155160

156-
`$sid = $proxy->getSid()` - returns proxied PHPSESSID if exists
161+
**$sid = $proxy->getSid()** - returns proxied PHPSESSID if exists
157162

158-
`$errors = $proxy->getErrors()` - returns error messages[] if occured
163+
**$errors = $proxy->getErrors()** - returns error messages[] if occured
159164

160165

161-
Other:
166+
**Others:**
162167

163-
`$parsed = $proxy->render($html)` - parse/rewrite URLs in custom html content with selected `$rewriteMode`
168+
$parsed = $proxy->render($html) - parse/rewrite URLs in custom html content with selected `$rewriteMode`
164169

165170
---
171+
172+
### Changelog
173+
174+
- `2.1` -- package was added to packagist (2022-04-23)
166175

167176
### Ultra Small Proxy is free to use but if you liked then you can donate project via BTC:
168177

@@ -172,10 +181,12 @@ or by PayPal:
172181
**[https://www.paypal.me/szczyglinski](https://www.paypal.me/szczyglinski)**
173182

174183

175-
Enjoy!
184+
**Enjoy!**
176185

177186
MIT License | 2022 Marcin 'szczyglis' Szczygliński
178187

179188
https://github.com/szczyglis-dev/php-ultra-small-proxy
180189

190+
https://szczyglis.dev
191+
181192
Contact: szczyglis@protonmail.com

0 commit comments

Comments
 (0)