$v) { // Safety checks if($k == 'browserRestrictFiles' && !is_array($v)) continue; if($k == 'consoleResolutions' && !is_array($v)) continue; if($k == 'browserRestrictFolders' && !is_array($v)) continue; $this->$k = $v; } /* User config.php does not exist. Send warning */ } else { $this->warnDefault = true; } // Ignore any server settings if we have servers // in the servers array if(isset($this->servers) && is_array($this->servers) && count($this->servers) && is_array($this->servers[0])) { unset($this->location); unset($this->user); unset($this->pass); } // Set to selected server based on browser cookie if(isset($_COOKIE['vboxServer']) && isset($this->servers) && is_array($this->servers) && count($this->servers)) { foreach($this->servers as $s) { if($s['name'] == $_COOKIE['vboxServer']) { foreach($s as $k=>$v) $this->$k = $v; break; } } // If servers is not an array, set to empty array } elseif(!isset($this->servers) || !is_array($this->servers)) { $this->servers = array(); } // We still have no server set, use the first one from // the servers array if(empty($this->location) && count($this->servers)) { foreach($this->servers[0] as $k=>$v) $this->$k = $v; } // Make sure name is set if(!isset($this->name) || !$this->name) { $this->name = parse_url($this->location); $this->name = $this->name['host']; } // Key used to uniquely identify this server in this // phpvirtualbox installation $this->setKey(); // legacy rdpHost setting if(!empty($this->rdpHost) && empty($this->consoleHost)) $this->consoleHost = $this->rdpHost; // Ensure authlib is set if(empty($this->authLib)) $this->authLib = 'Builtin'; // include interface include_once(dirname(__FILE__).'/authinterface.php'); include_once(dirname(__FILE__).'/auth/'.str_replace(array('.','/','\\'),'',$this->authLib).'.php'); // Check for session functionality if(!function_exists('session_start')) $this->noAuth = true; $alib = "phpvbAuth{$this->authLib}"; $this->auth = new $alib(@$this->authConfig); $this->authCapabilities = $this->auth->capabilities; /* Sanity checks */ if(!@$this->nicMax) $this->nicMax = 4; $this->previewUpdateInterval = max(3, @$this->previewUpdateInterval); error_reporting($ep); } /** * Set VirtualBox server to use * @param string $server server from config.php $servers array */ function setServer($server) { // do nothing if we are already using this server if($server == $this->name) return; foreach($this->servers as $s) { if($s['name'] == $server) { foreach($s as $k=>$v) $this->$k = $v; $this->setKey(); break; } } } /** * Generate a key for current server settings and populate $this->key */ function setKey() { $this->key = md5($this->location); } /** * Return the name of the server marked as the authentication master * @return string name of server marked as authMaster */ function getServerAuthMaster() { foreach($this->servers as $s) { if($s['authMaster']) { return $s['name']; } } return @$this->servers[0]['name']; } }