-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
52 lines (37 loc) · 1.29 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/*
* MyPac
* Dynamic Proxy auto-config (PAC) manager
* https://github.com/hamidsamak/mypac
*/
header('Content-Type: application/x-ns-proxy-autoconfig');
header('Content-Disposition: inline; filename="mypac.pac"');
$ips = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'ips.txt');
$ips = explode("\n", $ips);
$ips = array_map('trim', $ips);
$ips = array_filter($ips);
$ip_allowed = count($ips) > 0 && in_array($_SERVER['REMOTE_ADDR'], $ips) === false ? false : true;
?>
function FindProxyForURL(url, host) {
<?php if ($ip_allowed === false) { ?>return "DIRECT";<?php } ?>
var servers = [<?php
$servers = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'servers.txt');
$servers = explode("\n", $servers);
$servers = array_map('trim', $servers);
$servers = array_filter($servers);
if (count($servers) > 0)
print '"' . implode('", "', $servers) . '"';
?>];
var domains = [<?php
$domains = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'domains.txt');
$domains = explode("\n", $domains);
$domains = array_map('trim', $domains);
$domains = array_filter($domains);
if (count($domains) > 0)
print '"' . implode('", "', $domains) . '"';
?>];
for (var i = 0; i < domains.length; i++)
if (shExpMatch(host, domains[i]))
return servers.join(", ");
return "DIRECT";
}