mirror of
https://github.com/optim-enterprises-bv/control-pane.git
synced 2025-10-29 09:02:21 +00:00
vnc: HTTP_HOST is preferred
This commit is contained in:
@@ -15,12 +15,34 @@ function runVNC($jname)
|
||||
$remote_ip=$_SERVER['REMOTE_ADDR'];
|
||||
|
||||
CBSD::run("vm_vncwss jname=%s permit=%s", array($jname,$remote_ip));
|
||||
|
||||
if(isset($_SERVER['SERVER_NAME']) && !empty(trim($_SERVER['SERVER_NAME']))){
|
||||
$nodeip=$_SERVER['SERVER_NAME'];
|
||||
} else {
|
||||
$nodeip=$_SERVER['SERVER_ADDR'];
|
||||
}
|
||||
|
||||
// HTTP_HOST is preferred for href
|
||||
if (isset($_SERVER['HTTP_HOST']) && !empty(trim($_SERVER['HTTP_HOST']))){
|
||||
$nodeip=$_SERVER['HTTP_HOST'];
|
||||
}
|
||||
|
||||
if (filter_var($nodeip, FILTER_VALIDATE_IP)) {
|
||||
$is_ip4=true;
|
||||
} else {
|
||||
$is_ip4=false;
|
||||
}
|
||||
|
||||
if ($is_ip4 == false) {
|
||||
if (filter_var($nodeip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
||||
$is_ip6=true;
|
||||
} else {
|
||||
$is_ip6=false;
|
||||
}
|
||||
}
|
||||
|
||||
// HTTP_HOST is IP, try to check SERVER_NAME
|
||||
if (($is_ip4==true)||($is_ip6==true)) {
|
||||
if(isset($_SERVER['SERVER_NAME']) && !empty(trim($_SERVER['SERVER_NAME']))){
|
||||
$nodeip=$_SERVER['SERVER_NAME'];
|
||||
} else {
|
||||
$nodeip=$_SERVER['SERVER_ADDR'];
|
||||
}
|
||||
}
|
||||
|
||||
// handle when 'server_name _;' - use IP instead
|
||||
if (strcmp($nodeip, "_") == 0) {
|
||||
|
||||
Reference in New Issue
Block a user