mirror of
https://github.com/unraid/webgui.git
synced 2026-04-26 04:11:12 -05:00
Remove special handling for file_get_contents(), use libcurl instead
This commit is contained in:
@@ -21,6 +21,22 @@ if (!isset($_SESSION['locale'])) $_SESSION['locale'] = _var($_POST,'#locale');
|
||||
|
||||
require_once "$docroot/webGui/include/Translations.php";
|
||||
|
||||
function download_url($url) {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 12);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 45);
|
||||
curl_setopt($ch, CURLOPT_ENCODING, "");
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_REFERER, "");
|
||||
curl_setopt($ch, CURLOPT_FAILONERROR, true);
|
||||
$out = curl_exec($ch) ?: false;
|
||||
curl_close($ch);
|
||||
return $out;
|
||||
}
|
||||
|
||||
$dockerd = is_file('/var/run/dockerd.pid') && is_dir('/proc/'.file_get_contents('/var/run/dockerd.pid'));
|
||||
$etc = '/etc/wireguard';
|
||||
$validIP4 = "(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})";
|
||||
@@ -425,13 +441,10 @@ case 'public':
|
||||
$ip = _var($_POST,'#ip');
|
||||
$v4 = _var($_POST,'#prot')!='6';
|
||||
$v6 = _var($_POST,'#prot')!='';
|
||||
$wanip4url = 'https://wanip4.unraid.net';
|
||||
$wanip6url = 'https://wanip6.unraid.net';
|
||||
$contextOptions['http']['timeout'] = 12;
|
||||
$int_ipv4 = $v4 ? (preg_match("/^$validIP4$/",$ip) ? $ip : (@dns_get_record($ip,DNS_A)[0]['ip'] ?: '')) : '';
|
||||
$ext_ipv4 = $v4 ? (@file_get_contents($wanip4url,false,getProxyStreamContext($wanip4url,$contextOptions)) ?: '') : '';
|
||||
$ext_ipv4 = $v4 ? (download_url('https://wanip4.unraid.net') ?: '') : '';
|
||||
$int_ipv6 = $v6 ? (preg_match("/^$validIP6$/",$ip) ? $ip : (@dns_get_record($ip,DNS_AAAA)[0]['ipv6'] ?: '')) : '';
|
||||
$ext_ipv6 = $v6 ? (@file_get_contents($wanip6url,false,getProxyStreamContext($wanip6url,$contextOptions)) ?: '') : '';
|
||||
$ext_ipv6 = $v6 ? (download_url('https://wanip6.unraid.net') ?: '') : '';
|
||||
echo "$int_ipv4;$ext_ipv4;$int_ipv6;$ext_ipv6";
|
||||
break;
|
||||
case 'addtunnel':
|
||||
|
||||
Reference in New Issue
Block a user