1
1
# [ PHP] Ultra Small Proxy 2
2
- ### PHP: 7.0 +
2
+ ### PHP: 7.2.5 +
3
3
4
- Current version: ** 2.0 ** | 2022-02 -23
4
+ Current version: ** 2.1 ** | 2022-04 -23
5
5
6
6
Ultra Small Proxy is a light-weight proxy written in PHP.
7
7
8
- ## Key Features:
8
+ ** Install with composer:**
9
+ ```
10
+ composer require szczyglis/php-ultra-small-proxy
11
+ ```
12
+
13
+ ## Features:
9
14
10
15
- Proxy server written in PHP
11
16
- Easy usage and integration
12
- - Standalone and external usage (it is only one PHP file)
13
17
- Simple and light-weight
14
18
- Sessions support
15
19
- 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
20
24
- GET and POST connections
21
25
- Forms submiting support
22
26
- POST variables redirecting
23
27
- Toolbar with address bar, configuration and debugger
24
28
- 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
27
31
28
32
## Requirements:
29
33
30
- - PHP 7.0+
31
- - CURL extension
32
- - DOM XML extension
34
+ - PHP 7.2.5+ with CURL and XML extensions
35
+ - Composer
36
+
33
37
34
38
## Usage example:
35
- ```
39
+ ``` php
36
40
<?php
37
41
38
- /* include classes */
39
- include __DIR__.'/UltraSmallProxy.php';
42
+ require __DIR__ . '/vendor/autoload.php';
40
43
41
- /* instantiate config */
42
- $config = new UltraSmallProxyConfig() ;
44
+ use Szczyglis\UltraSmallProxy\UltraSmallProxy;
45
+ use Szczyglis\UltraSmallProxy\Config ;
43
46
44
- /* instantiate proxy with config */
45
- $proxy = new UltraSmallProxy($config);
47
+ $config = new Config();
46
48
47
- /* specify start page and load it! */
48
- $output = $proxy->load('https://github.com');
49
+ $proxy = new UltraSmallProxy($config);
49
50
50
- /* render output */
51
- echo $output;
51
+ echo $proxy->load('https://github.com'); // <-- specify start page here
52
52
53
53
```
54
54
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.
60
60

61
61
62
62
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.:
64
64
```
65
65
<?php
66
66
$output = $proxy- >load('http://localhost/loopback.php');
67
67
```
68
68
69
69
## Repository contents:
70
70
71
- - ` UltraSmallProxy.php ` - proxy class
71
+ - ` src/ ` - proxy classes
72
+
72
73
- ` index.php ` - usage example
74
+
73
75
- ` loopback.php ` - loopback for test features like session support, form vars sending, and cookies redirecting
74
76
75
77
76
78
## Basic usage:
77
79
78
- ```
79
- $config = new UltraSmallProxyConfig();
80
+ ``` php
81
+ use Szczyglis\UltraSmallProxy\UltraSmallProxy;
82
+ use Szczyglis\UltraSmallProxy\Config;
83
+
84
+ $config = new Config();
80
85
$proxy = new UltraSmallProxy($config);
81
86
82
87
echo $proxy->load('https://github.com');
83
88
```
84
89
85
90
## Configuration:
86
91
87
- ```
92
+ ``` php
88
93
$output = $proxy->load('https://github.com', $force = false);
89
94
```
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 `
91
96
92
97
93
98
## Config values:
94
99
95
- Before page load:
100
+ ** Before page load:**
96
101
97
- ` $config->set('init', bool); ` - auto-init ` true|false ` , default: ` true `
102
+ ** $config->set('init', true) ** - ` boolean ` , auto-init ` true|false ` , default: ` true `
98
103
99
- ` $config->set('source', 'string'); ` - input source ` domain|ip ` , default: ` domain `
104
+ ** $config->set('source', 'domain') ** - ` string ` , input source ` domain|ip ` , default: ` domain `
100
105
101
- ` $config->set('raw', bool); ` - raw download ` true|false ` , default: ` false `
106
+ ** $config->set('raw', false) ** - ` boolean ` , raw download ` true|false ` , default: ` false `
102
107
103
- ` $config->set('toolbar', bool); ` - attach toolbar ` true|false ` , default: ` true `
108
+ ** $config->set('toolbar', true) ** - ` boolean ` , attach toolbar ` true|false ` , default: ` true `
104
109
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;) `
106
111
107
- ` $config->set('timeout', int); ` - curl timeout, default: ` 120 `
112
+ ** $config->set('timeout', 120) ** - ` int ` , curl timeout, default: ` 120 `
108
113
109
- ` $config->set('max_redirects', int); ` - curl max redirects, default: ` 10 `
114
+ ** $config->set('max_redirects', 10) ** - ` int ` , curl max redirects, default: ` 10 `
110
115
111
- ` $config->set('cookies_dir', 'string'); ` - cookies directory, default: ` ./cookies `
116
+ ** $config->set('cookies_dir', './cookies') ** - ` string ` , cookies directory, default: ` ./cookies `
112
117
113
- ` $config->set('cache_dir', 'string'); ` - cache directory, default: ` ./cache `
118
+ ** $config->set('cache_dir', './cache') ** - ` string ` , cache directory, default: ` ./cache `
114
119
115
- ` $config->set('method', 'string'); ` - request method ` GET|POST `
120
+ ** $config->set('method', 'GET') ** - ` string ` , request method ` GET|POST `
116
121
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 `
118
123
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 `
120
125
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 `
122
127
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 `
124
129
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 `
126
131
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 `
128
133
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 `
130
135
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 `
132
137
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 `
134
139
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 `
136
141
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 `
138
143
139
- ` $config->set('htaccess_user', 'string'); ` - HTTP AUTH user
144
+ ** $config->set('htaccess_user', 'user') ** - ` string ` , HTTP AUTH user
140
145
141
- ` $config->set('htaccess_pass', 'string'); ` - HTTP AUTH password
146
+ ** $config->set('htaccess_pass', 'pass') ** - ` string ` , HTTP AUTH password
142
147
143
148
144
149
## Public methods:
145
150
146
- After page load:
151
+ ** After page load:**
147
152
148
- ` $siteCookies = $proxy->cookie->getSiteCookies() ` - returns cookies[ ] received from proxied site
153
+ ** $siteCookies = $proxy->cookie->getSiteCookies()** - returns cookies[ ] received from proxied site
149
154
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
151
156
152
- ` $status = $proxy->http->getStatus() ` - returns connection status[ ]
157
+ ** $status = $proxy->http->getStatus()** - returns connection status[ ]
153
158
154
- ` $headers = $proxy->http->getHeaders() ` - returns received headers[ ]
159
+ ** $headers = $proxy->http->getHeaders()** - returns received headers[ ]
155
160
156
- ` $sid = $proxy->getSid() ` - returns proxied PHPSESSID if exists
161
+ ** $sid = $proxy->getSid()** - returns proxied PHPSESSID if exists
157
162
158
- ` $errors = $proxy->getErrors() ` - returns error messages[ ] if occured
163
+ ** $errors = $proxy->getErrors()** - returns error messages[ ] if occured
159
164
160
165
161
- Other:
166
+ ** Others: **
162
167
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 `
164
169
165
170
---
171
+
172
+ ### Changelog
173
+
174
+ - ` 2.1 ` -- package was added to packagist (2022-04-23)
166
175
167
176
### Ultra Small Proxy is free to use but if you liked then you can donate project via BTC:
168
177
@@ -172,10 +181,12 @@ or by PayPal:
172
181
** [ https://www.paypal.me/szczyglinski ] ( https://www.paypal.me/szczyglinski ) **
173
182
174
183
175
- Enjoy!
184
+ ** Enjoy!**
176
185
177
186
MIT License | 2022 Marcin 'szczyglis' Szczygliński
178
187
179
188
https://github.com/szczyglis-dev/php-ultra-small-proxy
180
189
190
+ https://szczyglis.dev
191
+
181
192
Contact: szczyglis@protonmail.com
0 commit comments