Skip to content

Commit a3026d8

Browse files
committed
Added v.1.1
0 parents  commit a3026d8

File tree

6 files changed

+1128
-0
lines changed

6 files changed

+1128
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
temp/
2+
cookies/
3+
.idea/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 szczyglis-dev
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.

README.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# [PHP] Ultra Small Proxy
2+
### PHP 5.6+ / PHP 7
3+
4+
Current version: 1.1
5+
6+
Ultra Small Proxy is a light-weight proxy written in PHP.
7+
8+
## Features:
9+
10+
- Proxy server written in PHP
11+
- Easy usage and integration
12+
- Standalone and external usage (it is only one PHP class)
13+
- Simple and light-weight
14+
- Sessions support
15+
- Sending and receiving cookies
16+
- GET and POST connections
17+
- Forms submiting support
18+
- POST variables redirecting
19+
- Toolbar with address bar and connection debugger
20+
- URLs rewriting at runtime (links, images, css, javascript, etc.)
21+
- 2 different methods for URLs rewriting: Regex (via preg_replace) and DOM XML (via libxml & DOMDocument)
22+
- PHP 5 and PHP 7 supported
23+
24+
25+
## Usage example:
26+
```
27+
<?php
28+
29+
/* include class */
30+
include __DIR__.'/UltraSmallProxy.php';
31+
32+
/* instantiate proxy */
33+
$proxy = new UltraSmallProxy();
34+
35+
/* specify start page and load it! */
36+
$output = $proxy->load('https://github.com');
37+
38+
/* render output */
39+
echo $output;
40+
41+
```
42+
Make sure to have write permissions to `./cookies` directory.
43+
44+
## Screenshot:
45+
46+
![proxy_github](https://user-images.githubusercontent.com/61396542/75244037-4c66bb00-57cb-11ea-82ee-c51c7736653b.png)
47+
48+
49+
Open `loopback.php`if you want to test proxy features like sessions support, POST vars redirecting, form submiting and more, e.g.:
50+
```
51+
<?php
52+
$output = $proxy->load('http://localhost/loopback.php');
53+
```
54+
55+
## Repository contents:
56+
57+
- `UltraSmallProxy.php` - proxy class
58+
- `index.php` - usage example
59+
- `loopback.php` - loopback for test features like session support, form vars sending, and cookies redirecting
60+
61+
62+
## Options:
63+
64+
```
65+
$proxy = new UltraSmallProxy($init = true, $rewriteMode = 'regex', $attachToolbar = true);
66+
```
67+
`$init` - autostarts listening for URLs in QUERY STRING, set to `false` if you want to disable this feature, default: `true`
68+
69+
`$rewriteMode` - method used to URLs rewriting, possible values: `regex` (rewriting by regular expressions), `dom` (rewriting by DOM XML), `null` (disable rewriting), default: `regex`
70+
71+
`$attachToolbar` - appends toolbar DIV, CSS and JS to output when `true`, set to `false` if you want to disable this feature, default: `true`
72+
73+
74+
```
75+
$output = $proxy->load('https://github.com', $force = false);
76+
```
77+
`$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`
78+
79+
80+
## Public methods:
81+
82+
Before page load:
83+
84+
`$proxy->setUserAgent($agent)` - sets custom User Agent, defaul: `Mozilla/4.0 (compatible;)`
85+
86+
`$proxy->setRewriteMode($rewriteMode)` - sets URLs rewrite mode: `regex`|`dom`|`null`
87+
88+
`$proxy->setMethod($method)` - sets request method: `GET`|`POST`
89+
90+
`$proxy->setCookiesDir($path)` - sets directory for proxied cookies storage, default: `cookies`
91+
92+
93+
94+
After page load:
95+
96+
`$siteCookies = $proxy->getSiteCookies()` - returns cookies[] received from proxied site
97+
98+
`$localCookies = $proxy->getLocalCookies()` - returns cookies[] stored localy and sended to proxied site
99+
100+
`$status = $proxy->getStatus()` - returns connection status[]
101+
102+
`$sid = $proxy->getSid()` - returns proxied PHPSESSID if exists
103+
104+
`$isError = $proxy->isError()` - returns `true` if any error occured, `false` if not
105+
106+
`$isCurlError = $proxy->isCurlError()` - returns `true` if curl error occured, `false` if not
107+
108+
`$errorMessages = $proxy->getErrorMessages()` - returns error messages[] if occured
109+
110+
111+
112+
Other:
113+
114+
`$parsed = $proxy->parse($html)` - parse/rewrite URLs in custom html content with selected `$rewriteMode`
115+
116+
117+
118+
119+
### Ultra Small Proxy is free to use but if you liked then you can donate project via BTC:
120+
121+
**1LK9tDPBuBFXCKUThFWXNvdcdJ4gzx1Diz**
122+
123+
or by PayPal:
124+
**[https://www.paypal.me/szczyglinski](https://www.paypal.me/szczyglinski)**
125+
126+
127+
Enjoy!
128+
129+
130+
MIT License | 2020 Marcin 'szczyglis' Szczygliński
131+
132+
https://github.com/szczyglis-dev/php-ultra-small-proxy
133+
134+
Contact: szczyglis ("12 Monkeys" movie is awesome) protonmail.com

0 commit comments

Comments
 (0)