function dvdParam($key) { if (isset($_REQUEST[$key])) { if (strlen($_REQUEST[$key]) > 0) { return Repository::getDvd($_REQUEST[$key]); } return new DVD(); } return NULL; }
public function __get($name) { switch ($name) { // booleans case 'bioslogofadein': case 'bioslogofadeout': case 'acpi': case 'ioapic': case 'pae': case 'hpet': case 'rtcuseutc': case 'hwvirtex': // case 'hwvirtexexcl': // case 'hwvirtexexcl': case 'nestedpaging': case 'largepages': case 'pagefusion': case 'vtxvpid': case 'synthcpu': case 'accelerate2dvideo': case 'accelerate3d': case 'usb': case 'usbehci': case 'vrde': return $this->get($name, 'off') == 'on'; // integers // integers case 'cpus': case 'memory': case 'vram': case 'bioslogodisplaytime': case 'biossystemtimeoffset': return intval($this->get($name, '0')); // storage controllers // storage controllers case 'storage0': case 'storage1': case 'storage2': case 'storage3': case 'storage4': case 'storage5': case 'storage6': case 'storage7': $i = substr($name, 7); if (!$this->has('storagecontrollername' . $i)) { break; } $name = $this->get('storagecontrollername' . $i, ''); $ports = intval($this->get('storagecontrollerportcount' . $i, '0')); $maxdevices = intval($this->get('storagecontrollermaxdeviceperport' . $i, '0')); $devices = array(); for ($j = 0; $j < $ports; $j++) { for ($k = 0; $k < $maxdevices; $k++) { $slot = $name . '-' . $j . '-' . $k; if (!$this->has($slot)) { continue; } if ($this->endsWith($slot, '.vdi') || $this->endsWith($slot, '.vmdk')) { $devices[$j][$k] = Repository::getHdd($this->get($slot)); } else { if ($this->get($slot) == 'emptydrive') { $devices[$j][$k] = new DVD(); } else { $devices[$j][$k] = Repository::getDvd($this->get($slot)); } } } } return array('name' => $name, 'type' => $this->get('storagecontrollertype' . $i, 'none'), 'instance' => intval($this->get('storagecontrollerinstance' . $i, '0')), 'ports' => array('count' => $ports, 'min' => intval($this->get('storagecontrollerminportcount' . $i, '0')), 'max' => intval($this->get('storagecontrollermaxportcount' . $i, '0')), 'maxdevices' => $maxdevices), 'devices' => $devices); // fdd controllers // fdd controllers case 'fd0': case 'fd1': $slot = 'FLOPPY-0-0'; switch ($name) { case 'fd0': $slot = 'FLOPPY-0-0'; break; case 'fd1': $slot = 'FLOPPY-0-1'; break; } if (!$this->has($slot)) { break; } if ($this->get($slot) == 'emptydrive') { return new FDD(); } return Repository::getFdd($this->get($slot)); // ide controllers // ide controllers case 'ide0': case 'ide1': case 'ide2': case 'ide3': $slot = 'IDE-0-0'; switch ($name) { case 'ide0': $slot = 'IDE-0-0'; break; case 'ide1': $slot = 'IDE-0-1'; break; case 'ide2': $slot = 'IDE-1-0'; break; case 'ide3': $slot = 'IDE-1-1'; break; } if (!$this->has($slot)) { break; } if ($this->endsWith($slot, '.vdi') || $this->endsWith($slot, '.vmdk')) { return Repository::getHdd($this->get($slot)); } if ($this->get($slot) == 'emptydrive') { return new DVD(); } return Repository::getDvd($this->get($slot)); // sata controllers // sata controllers case 'sata0': case 'sata1': case 'sata2': case 'sata3': case 'sata4': case 'sata5': case 'sata6': case 'sata7': case 'sata8': case 'sata9': case 'sata10': case 'sata11': case 'sata12': case 'sata13': case 'sata14': case 'sata15': case 'sata16': case 'sata17': case 'sata18': case 'sata19': case 'sata20': case 'sata21': case 'sata22': case 'sata23': case 'sata24': case 'sata25': case 'sata26': case 'sata27': case 'sata28': case 'sata29': $i = substr($name, 4); $slot = 'SATA-' . $i . '-0'; if (!$this->has($slot)) { break; } if ($this->endsWith($slot, '.vdi') || $this->endsWith($slot, '.vmdk')) { return Repository::getHdd($this->get($slot)); } if ($this->get($slot) == 'emptydrive') { return new DVD(); } return Repository::getDvd($this->get($slot)); // network adapters // network adapters case 'nic0': case 'nic1': case 'nic2': case 'nic3': case 'nic4': case 'nic5': case 'nic6': case 'nic7': $i = substr($name, 3) + 1; switch ($this->get('nic' . $i, 'none')) { case 'nat': return array('type' => 'nat', 'driver' => $this->get('nictype' . $i, ''), 'mac' => $this->get('macaddress' . $i, '000000000000'), 'mactext' => self::formatMAC($this->get('macaddress' . $i, '000000000000')), 'connected' => $this->get('cableconnected' . $i, 'off') == 'on', 'ip' => $this->get('/VirtualBox/GuestInfo/Net/' . ($i - 1) . '/V4/IP')); case 'bridged': return array('type' => 'bridged', 'driver' => $this->get('nictype' . $i, ''), 'mac' => $this->get('macaddress' . $i, '000000000000'), 'mactext' => self::formatMAC($this->get('macaddress' . $i, '000000000000')), 'adapter' => $this->get('bridgeadapter' . $i, 'eth0'), 'connected' => $this->get('cableconnected' . $i, 'off') == 'on', 'ip' => $this->get('/VirtualBox/GuestInfo/Net/' . ($i - 1) . '/V4/IP')); case 'intnet': return array('type' => 'intnet', 'driver' => $this->get('nictype' . $i, ''), 'mac' => $this->get('macaddress' . $i, '000000000000'), 'mactext' => self::formatMAC($this->get('macaddress' . $i, '000000000000')), 'net' => $this->get('intnet' . $i, 'intnet'), 'connected' => $this->get('cableconnected' . $i, 'off') == 'on', 'ip' => $this->get('/VirtualBox/GuestInfo/Net/' . ($i - 1) . '/V4/IP')); case 'hostonly': return array('type' => 'hostonly', 'driver' => $this->get('nictype' . $i, ''), 'mac' => $this->get('macaddress' . $i, '000000000000'), 'mactext' => self::formatMAC($this->get('macaddress' . $i, '000000000000')), 'adapter' => $this->get('hostonlyadapter' . $i, 'vboxnet0'), 'connected' => $this->get('cableconnected' . $i, 'off') == 'on', 'ip' => $this->get('/VirtualBox/GuestInfo/Net/' . ($i - 1) . '/V4/IP')); } return array('type' => 'none', 'connected' => 'off'); // network configuration // network configuration case 'net0': case 'net1': case 'net2': case 'net3': case 'net4': case 'net5': case 'net6': case 'net7': $i = substr($name, 3); return array('ip' => $this->get('/VirtualBox/GuestInfo/Net/' . $i . '/V4/IP', '0.0.0.0'), 'broadcast' => $this->get('/VirtualBox/GuestInfo/Net/' . $i . '/V4/Broadcast', '0.0.0.0'), 'netmask' => $this->get('/VirtualBox/GuestInfo/Net/' . $i . '/V4/Netmask', '255.255.255.255'), 'status' => $this->get('/VirtualBox/GuestInfo/Net/' . $i . '/Status', 'Down') == 'Up'); // vrde // vrde case 'vrdeaddress': return $this->get('vrde.TCP/Address', '127.0.0.1'); case 'vrdeport': return $this->get('vrde.TCP/Ports', rand(1025, 65534)); // system // system case 'ready': return $this->get('/cem/ready', 'false') == 'true'; case 'product': return $this->get('/VirtualBox/GuestInfo/OS/Product'); case 'additions': return $this->get('/VirtualBox/GuestAdd/Version') . '-' . $this->get('/VirtualBox/GuestAdd/Revision'); case 'os': return Repository::getOs($this->get('ostype')); } return parent::__get($name); }