/** edit_post()
 		Actually saves the data.
 	*/
 public function edit_post()
 {
     // Find
     $Host = $this->obj;
     $HostManager = $this->getClass('HostManager');
     $Inventory = $Host->get('inventory');
     // Hook
     $this->HookManager->processEvent('HOST_EDIT_POST', array('Host' => &$Host));
     // POST
     try {
         // Tabs
         switch ($_REQUEST['tab']) {
             case 'host-general':
                 // Error checking
                 if (empty($_REQUEST['mac'])) {
                     throw new Exception('MAC Address is required');
                 }
                 if ($Host->get('name') != $_REQUEST['host'] && $HostManager->exists($_REQUEST['host'])) {
                     throw new Exception('Hostname Exists already');
                 }
                 if ($Host->get('name') != $_REQUEST['host'] && !$this->getClass('HostManager')->isHostnameSafe($_REQUEST['host'])) {
                     throw new Exception(_('Please enter a valid hostname'));
                 }
                 // Variables
                 $mac = new MACAddress($_REQUEST['mac']);
                 // Task variable.
                 $Task = $Host->get('task');
                 // Error checking
                 if (!$mac->isValid()) {
                     throw new Exception(_('MAC Address is not valid'));
                 }
                 if (!$_REQUEST['image'] && $Task && $Task->isValid() || $_REQUEST['image'] && $_REQUEST['image'] != $Host->get('imageID') && $Task && $Task->isValid()) {
                     throw new Exception('Cannot unset image.<br />Host is currently in a tasking.');
                 }
                 // Define new Image object with data provided
                 $Host->set('name', $_REQUEST['host'])->set('description', $_REQUEST['description'])->set('imageID', $_REQUEST['image'])->set('kernel', $_REQUEST['kern'])->set('kernelArgs', $_REQUEST['args'])->set('kernelDevice', $_REQUEST['dev'])->set('productKey', base64_encode($_REQUEST['key']));
                 if (strtolower($Host->get('mac')->__toString()) != strtolower($mac->__toString())) {
                     $Host->set('mac', strtolower($mac->__toString()));
                 }
                 $MyMACs = $AddMe = array();
                 foreach ((array) $_REQUEST['additionalMACs'] as $MAC) {
                     $MAC = !$MAC instanceof MACAddress ? $this->getClass('MACAddress', $MAC) : $MAC;
                     if ($MAC && $MAC->isValid()) {
                         $AddMe[] = strtolower($MAC->__toString());
                     }
                 }
                 foreach ((array) $Host->get('additionalMACs') as $MyMAC) {
                     if ($MyMAC instanceof MACAddress && $MyMAC->isValid()) {
                         $MyMACs[] = strtolower($MyMAC->__toString());
                     }
                 }
                 if (isset($_REQUEST['primaryMAC'])) {
                     $AddMe[] = strtolower($mac->__toString());
                     $Host->removeAddMAC($_REQUEST['primaryMAC'])->set('mac', strtolower($_REQUEST['primaryMAC']));
                 }
                 $AddMe = array_diff((array) $AddMe, (array) $MyMACs);
                 if (count($AddMe)) {
                     $Host->addAddMAC($AddMe);
                 }
                 if (isset($_REQUEST['additionalMACsRM'])) {
                     $Host->removeAddMAC($_REQUEST['additionalMACsRM']);
                 }
                 break;
             case 'host-grouprel':
                 if (isset($_REQUEST['addGroups'])) {
                     $Host->addGroup($_REQUEST['group']);
                 }
                 if (isset($_REQUEST['remgroups'])) {
                     $Host->removeGroup(array_unique($_REQUEST['groupdel']));
                 }
                 break;
             case 'host-active-directory':
                 $useAD = isset($_REQUEST['domain']);
                 $domain = trim($_REQUEST['domainname']);
                 $ou = trim($_REQUEST['ou']);
                 $user = trim($_REQUEST['domainuser']);
                 $pass = trim($_REQUEST['domainpassword']);
                 $Host->setAD($useAD, $domain, $ou, $user, $pass, true);
                 break;
             case 'host-printers':
                 $PrinterManager = $this->getClass('PrinterAssociationManager');
                 // Set printer level for Host
                 if (isset($_REQUEST['level'])) {
                     $Host->set('printerLevel', $_REQUEST['level']);
                 }
                 // Add
                 if (isset($_REQUEST['updateprinters'])) {
                     $Host->addPrinter($_REQUEST['printer']);
                     // Set Default
                     foreach ($_REQUEST['printerid'] as $printerid) {
                         $Printer = new Printer($printerid);
                         $Host->updateDefault($_REQUEST['default'], isset($_REQUEST['default']));
                     }
                 }
                 // Remove
                 if (isset($_REQUEST['printdel'])) {
                     $Host->removePrinter($_REQUEST['printerRemove']);
                 }
                 break;
             case 'host-snapins':
                 // Add
                 if (!isset($_REQUEST['snapinRemove'])) {
                     $Host->addSnapin($_REQUEST['snapin']);
                 }
                 // Remove
                 if (isset($_REQUEST['snaprem'])) {
                     $Host->removeSnapin($_REQUEST['snapinRemove']);
                 }
                 break;
             case 'host-service':
                 // be set to the default values within the system.
                 $x = is_numeric($_REQUEST['x']) ? $_REQUEST['x'] : $this->FOGCore->getSetting('FOG_SERVICE_DISPLAYMANAGER_X');
                 $y = is_numeric($_REQUEST['y']) ? $_REQUEST['y'] : $this->FOGCore->getSetting('FOG_SERVICE_DISPLAYMANAGER_Y');
                 $r = is_numeric($_REQUEST['r']) ? $_REQUEST['r'] : $this->FOGCore->getSetting('FOG_SERVICE_DISPLAYMANAGER_R');
                 $tme = is_numeric($_REQUEST['tme']) ? $_REQUEST['tme'] : $this->FOGCore->getSetting('FOG_SERVICE_AUTOLOGOFF_MIN');
                 if (isset($_REQUEST['updatestatus'])) {
                     $modOn = $_REQUEST['modules'];
                     $modOff = $this->getClass('ModuleManager')->find(array('id' => $modOn), '', '', '', '', '', true, 'id');
                     $Host->addModule($modOn);
                     $Host->removeModule($modOff);
                 }
                 if (isset($_REQUEST['updatedisplay'])) {
                     $Host->setDisp($x, $y, $r);
                 }
                 if (isset($_REQUEST['updatealo'])) {
                     $Host->setAlo($tme);
                 }
                 break;
             case 'host-hardware-inventory':
                 $pu = trim($_REQUEST['pu']);
                 $other1 = trim($_REQUEST['other1']);
                 $other2 = trim($_REQUEST['other2']);
                 if ($_REQUEST["update"] == "1") {
                     $Inventory->set('primaryUser', trim($_REQUEST['pu']))->set('other1', trim($_REQUEST['other1']))->set('other2', trim($_REQUEST['other2']))->save();
                 }
                 break;
             case 'host-login-history':
                 $this->FOGCore->redirect("?node=host&sub=edit&id=" . $Host->get('id') . "&dte=" . $_REQUEST['dte'] . "#" . $this->REQUEST['tab']);
                 break;
             case 'host-virus-history':
                 if (isset($_REQUEST["delvid"])) {
                     $Virus = new Virus($_REQUEST['delvid']);
                     $Virus->destroy();
                 }
                 if (isset($_REQUEST['delvid']) && $_REQUEST['delvid'] == 'all') {
                     $Host->clearAVRecordsForHost();
                     $this->FOGCore->redirect('?node=host&sub=edit&id=' . $Host->get('id') . '#' . $this->REQUEST['tab']);
                 }
                 break;
         }
         // Save to database
         if ($Host->save()) {
             $Host->setAD();
             if ($_REQUEST['tab'] == 'host-general') {
                 $Host->ignore($_REQUEST['igimage'], $_REQUEST['igclient']);
             }
             // Hook
             $this->HookManager->processEvent('HOST_EDIT_SUCCESS', array('Host' => &$Host));
             // Log History event
             $this->FOGCore->logHistory('Host updated: ID: ' . $Host->get('id') . ', Name: ' . $Host->get('name') . ', Tab: ' . $this->REQUEST['tab']);
             // Set session message
             $this->FOGCore->setMessage('Host updated!');
             // Redirect to new entry
             $this->FOGCore->redirect(sprintf('?node=%s&sub=edit&%s=%s#%s', $this->REQUEST['node'], $this->id, $Host->get('id'), $this->REQUEST['tab']));
         } else {
             throw new Exception('Host update failed');
         }
     } catch (Exception $e) {
         // Hook
         $this->HookManager->processEvent('HOST_EDIT_FAIL', array('Host' => &$Host));
         // Log History event
         $this->FOGCore->logHistory('Host update failed: Name: ' . $_REQUEST['name'] . ', Tab: ' . $this->REQUEST['tab'] . ', Error: ' . $e->getMessage());
         // Set session message
         $this->FOGCore->setMessage($e->getMessage());
         // Redirect
         $this->FOGCore->redirect('?node=host&sub=edit&id=' . $Host->get('id') . '#' . $this->REQUEST['tab']);
     }
 }
 /** parseMacList() function takes the string of the MAC addresses sent
  *     it then tests if they are each valid macs and returns just the mac's.
  * @param $stringlist the list of MACs to check.  Each mac is broken by a | character.
  * @return $MAClist, returns the list of valid MACs
  */
 public function parseMacList($stringlist, $image = false, $client = false)
 {
     $MACs = $this->getClass('MACAddressAssociationManager')->find(array('mac' => (array) explode('|', $stringlist)));
     if (count($MACs)) {
         foreach ($MACs as $MAC) {
             if ($MAC && $MAC->isValid()) {
                 if ($image && !$MAC->get('imageIgnore')) {
                     $MAC = new MACAddress($MAC);
                 } else {
                     if ($client && !$MAC->get('clientIgnore')) {
                         $MAC = new MACAddress($MAC);
                     }
                 }
                 if (!$image && !$client && !$MAC->get('pending')) {
                     $MAC = new MACAddress($MAC);
                 }
                 if ($MAC instanceof MACAddress) {
                     $MAClist[] = strtolower($MAC);
                 }
             }
         }
     }
     $MACs = explode('|', $stringlist);
     foreach ((array) $MACs as $MAC) {
         $MAC = new MACAddress($MAC);
         if ($MAC && $MAC->isValid()) {
             $MAClist[] = strtolower($MAC);
         }
     }
     $Ignore = explode(',', $this->getClass('FOGCore')->getSetting('FOG_QUICKREG_PENDING_MAC_FILTER'));
     if (count($ignore)) {
         foreach ((array) $Ignore as $ignore) {
             $matches = preg_grep("#{$ignore}#i", $MACs);
             if (count($matches)) {
                 $NewMatches = array_merge((array) $NewMatches, $matches);
                 unset($matches);
             }
         }
     }
     if (!count($MAClist)) {
         return false;
     }
     return array_unique(array_diff((array) $MAClist, (array) $NewMatches));
 }
Example #3
0
 public function ignore($imageIgnore, $clientIgnore)
 {
     $MyMACs = $this->getMyMacs();
     foreach ((array) $imageIgnore as $igMAC) {
         $igMACs[] = strtolower($igMAC);
     }
     foreach ((array) $clientIgnore as $cgMAC) {
         $cgMACs[] = strtolower($cgMAC);
     }
     foreach ((array) $MyMACs as $MAC) {
         $ignore = current((array) $this->getClass('MACAddressAssociationManager')->find(array('mac' => $MAC, 'hostID' => $this->get('id'))));
         $ME = new MACAddress($ignore);
         if ($ME->isValid()) {
             $mac = strtolower($MAC);
             $ignore->set('imageIgnore', in_array($mac, (array) $igMACs))->save();
             $ignore->set('clientIgnore', in_array($mac, (array) $cgMACs))->save();
         }
     }
 }
Example #4
0
function vps_edit_params()
{
    $sock = new sockets();
    $LXCBridged = $sock->GET_INFO("LXCBridged");
    $LXCInterface = $sock->GET_INFO("LXCInterface");
    if (!is_numeric($LXCBridged)) {
        $LXCBridged = 0;
    }
    $page = CurrentPageName();
    $users = new usersMenus();
    $tpl = new templates();
    $q = new mysql();
    if ($users->AsVirtualBoxManager) {
        $AsVirtualBoxManager = 1;
    } else {
        $AsVirtualBoxManager = 0;
    }
    $sql = "SELECT * FROM lxc_machines WHERE ID={$_GET["ID"]}";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    $button_text = "{apply}";
    if ($_GET["ID"] == 0) {
        $button_text = "{add}";
    }
    $machine_name = $ligne["machine_name"];
    $hostname = $ligne["hostname"];
    $rootpwd = $ligne["rootpwd"];
    $ChangeMac = $ligne["ChangeMac"];
    if ($ligne["MacAddr"] == null) {
        $mc = new MACAddress();
        $mc->separator = ":";
        $ligne["MacAddr"] = $mc->_generateMAC2();
    }
    $MacAddr = explode(":", $ligne["MacAddr"]);
    $templates = unserialize(base64_decode($sock->getFrameWork("lxc.php?lxc-templates=yes")));
    $UsePhys = $ligne["UsePhys"];
    $PhysNic = $ligne["PhysNic"];
    $uid = $ligne["uid"];
    $net = new networking();
    $interfaces = $net->Local_interfaces(true);
    while (list($iet, $iet2) = each($interfaces)) {
        $sql = "SELECT PhysNic FROM lxc_machines WHERE ID!={$_GET["ID"]} AND PhysNic='{$iet}'";
        if ($iet == $LXCInterface) {
            continue;
        }
        if ($iet == "eth0") {
            continue;
        }
        if ($iet == "br5") {
            continue;
        }
        $lignePhysNic = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        if ($lignePhysNic["PhysNic"] != null) {
            continue;
        }
        $interfacesR[$iet] = $iet;
    }
    $interfacesR[$PhysNic] = $PhysNic;
    $interfacesR[null] = "{select}";
    $physCardTable = "\n\t\t<tr>\n\t\t\t<td class=legend>{UsePhysCard}:</td>\n\t\t\t<td>" . Field_checkbox("UsePhys", 1, $UsePhys, "ChangeMacCheck()") . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend>{nic}:</td>\n\t\t\t<td>" . Field_array_Hash($interfacesR, "PhysNic", $PhysNic, "style:font-size:14px;padding:3px") . "</td>\n\t\t</tr>\t\t\n\t\t\n\t\t";
    //AA:86:D7:23:0E:51
    $macaddrtable = "\n\t\t<table>\n\t\t<tr>\n\t\t\t<td class=legend>{change_mac_address}:</td>\n\t\t\t<td>" . Field_checkbox("ChangeMac", 1, $ChangeMac, "ChangeMacCheck()") . "</td>\n\t\t</tr>\n\t\t</tr>\n\t\t</table>\n\t\t\t\n\t\t<table style='width:1%'>\n\t\t<tr>\n\t\t<td>\n\t\t\t<td>" . Field_text("MAC1", $MacAddr[0], "font-size:14px;padding:3px;width:26px") . "</td>\n\t\t\t<td style='font-size:14px'>:</td>\n\t\t\t<td>" . Field_text("MAC2", $MacAddr[1], "font-size:14px;padding:3px;width:26px") . "</td>\n\t\t\t<td style='font-size:14px'>:</td>\n\t\t\t<td>" . Field_text("MAC3", $MacAddr[2], "font-size:14px;padding:3px;width:26px") . "</td>\n\t\t\t<td style='font-size:14px'>:</td>\n\t\t\t<td>" . Field_text("MAC4", $MacAddr[3], "font-size:14px;padding:3px;width:26px") . "</td>\n\t\t\t<td style='font-size:14px'>:</td>\n\t\t\t<td>" . Field_text("MAC5", $MacAddr[4], "font-size:14px;padding:3px;width:26px") . "</td>\n\t\t\t<td style='font-size:14px'>:</td>\n\t\t\t<td>" . Field_text("MAC6", $MacAddr[5], "font-size:14px;padding:3px;width:26px") . "</td>\n\t\t\t\n\t\t</tr>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t</table>";
    while (list($filename, $arraytpl) = each($templates)) {
        $TPLR[$filename] = "{$arraytpl["TYPE"]} {$arraytpl["PROC"]} - v{$arraytpl["VERSION"]}";
    }
    $TPLR[null] = "{select}";
    $field_template = Field_array_Hash($TPLR, 'lxc_template', $ligne["template"], "CheckTemplate()", null, 0, "font-size:13px;padding:3px");
    if ($_GET["ID"] == 0) {
        $template = "\n\t\t\t<tr>\n\t\t\t\t<td class=legend>{template}:</td>\n\t\t\t\t<td>{$field_template}</td>\n\t\t\t</tr>";
    }
    $ipaddr = "\n<tr>\n\t<td class=legend>{ipaddr}:</td>\n\t<td>" . Field_text("ipaddr", $ligne["ipaddr"], "font-size:14px;padding:3px;width:120px") . "</td>\n</tr>";
    if ($LXCBridged == 0) {
        $sql = "SELECT nic,ID,ipaddr FROM nics_virtuals WHERE org='LXC-INTERFACES' ORDER BY ID";
        $results = $q->QUERY_SQL($sql, "artica_backup");
        while ($ligne3 = mysql_fetch_array($results, MYSQL_ASSOC)) {
            $sql = "SELECT VirtualInterface FROM lxc_machines WHERE VirtualInterface='{$ligne3["nic"]}:{$ligne3["ID"]}'";
            $ligne2 = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
            if ($ligne["VirtualInterface"] != null) {
                continue;
            }
            $Interfaces["{$ligne3["nic"]}:{$ligne3["ID"]}"] = "{$ligne3["nic"]}:{$ligne3["ID"]} ({$ligne3["ipaddr"]})";
        }
        if (count($Interfaces) > 0) {
            $ipaddr = "<tr>\n\t\t<td class=legend>{ipaddr}:</td>\n\t\t<td colspan=2>" . Field_array_Hash($Interfaces, "VirtualInterface", $ligne["VirtualInterface"], "style:font-size:14px;padding:3px") . "</td>\n\t</tr>";
        } else {
            if (preg_match("#(.+?):(.+)#", $ligne["VirtualInterface"], $re)) {
                $sql = "SELECT nic,ID,ipaddr FROM nics_virtuals WHERE ID='{$re[2]}'";
                $ligne2 = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
            }
            $ipaddr = "<tr>\n\t\t<td class=legend>{ipaddr}:</td>\n\t\t<td colspan=2>" . Field_hidden("VirtualInterface", $ligne["VirtualInterface"]) . "<span style='font-size:14px'>{$ligne["VirtualInterface"]} ({$ligne2["ipaddr"]})</span></td>\n\t\t\n\t</tr>";
        }
    }
    $BrowseUser = "******"javascript:Loadjs('MembersBrowse.php?field-user=lxc-member&OnlyUsers=yes');\" value='{browse}...'>";
    if ($AsVirtualBoxManager == 0) {
        $BrowseUser = "******";
    }
    $html = "\n<div id='lxc_host_{$_GET["ID"]}'>\n<table style='width:100%' class=form>\n{$template}\n<tr>\n\t<td class=legend>{member}:</td>\n\t<td>" . Field_text("lxc-member", $uid, "font-size:14px;padding:3px;width:210px") . "</td>\n\t<td>{$BrowseUser}</td>\n</tr>\n<tr>\n\t<td class=legend>{computer_name}:</td>\n\t<td colspan=2>" . Field_text("machine_name", $machine_name, "font-size:14px;padding:3px;width:210px") . "</td>\n\t\n</tr>\n<tr>\n\t<td class=legend>{hostname}:</td>\n\t<td colspan=2>" . Field_text("hostname", $hostname, "font-size:14px;padding:3px;width:210px") . "</td>\n\t\n</tr>\n{$ipaddr}\n{$physCardTable}\n<tr>\n\t<td class=legend>{ComputerMacAddress}:</td>\n\t<td colspan=2>{$macaddrtable}</td>\n</tr>\n<tr>\n\t<td class=legend>{rootpwd}:</td>\n\t<td colspan=2>" . Field_password("rootpwd", $rootpwd, "font-size:14px;padding:3px;width:210px") . "</td>\n</tr>\n\n\n\n\n<tr>\n\t<td colspan=3 align='right'><hr>" . button($button_text, "SaveVPSServerSingle{$_GET["ID"]}()") . "</td>\n</tR>\n</table>\n\n\n\n<hr>\n<div style='font-size:16px'>{start_options}</div>\n<div class=explain>{lxc_start_options_text}</div>\n<table style='width:100%' class=form>\n<tr>\n\t<td class=legend>{autostart}:</td>\n\t<td>" . Field_checkbox("autostart", 1, $ligne["autostart"]) . "</td>\n\t<td width=1%>" . help_icon("{lxc_autostart_explain}") . "</td>\n</tr>\n<tr>\n\t<td class=legend>{enable_service}:</td>\n\t<td>" . Field_checkbox("enabledvps", 1, $ligne["enabled"]) . "</td>\n\t<td width=1%>&nbsp;</td>\n</tr>\n<tr>\n\t<td colspan=2 align='right'><hr>" . button($button_text, "SaveVPSServerSingle{$_GET["ID"]}()") . "</td>\n</tR>\n</table>\n\n\n<script>\nvar x_SaveVPSServerSingle{$_GET["ID"]}= function (obj) {\n\t\tvar results=trim(obj.responseText);\n\t\tif(results.length>0){alert(results);}\n\t\tvar ID={$_GET["ID"]};\n\t\tif(ID==0){YahooWinHide();}else{RefreshTab('main_config_vps{$_GET["ID"]}');}\n\t\tRefreshTab('main_config_vpssrv');\n\t}\t\t\n\n\n\tfunction SaveVPSServerSingle{$_GET["ID"]}(){\n\t\t\tCheckTemplate();\n\t\t\tvar XHR = new XHRConnection();\t\n\t\t\tvar ID={$_GET["ID"]};\n\t\t\tif(ID==0){\n\t\t\t\tvar tpl=document.getElementById('lxc_template').value;\n\t\t\t\tif(tpl.length==0){return;}\n\t\t\t\tXHR.appendData('template',tpl);\n\t\t\t}\n\t\t\tvar rootpwd=document.getElementById('rootpwd').value;\n\t\t\tXHR.appendData('form-vps-edit','yes');\n\t\t\tXHR.appendData('machine_name',document.getElementById('machine_name').value);\n\t\t\tif(document.getElementById('ipaddr')){\n\t\t\t\tXHR.appendData('ipaddr',document.getElementById('ipaddr').value);\n\t\t\t}\n\t\t\t\n\t\t\tif(document.getElementById('VirtualInterface')){\n\t\t\t\tXHR.appendData('VirtualInterface',document.getElementById('VirtualInterface').value);\n\t\t\t}\t\t\t\n\t\t\t\n\t\t\tif(document.getElementById('ChangeMac').checked){XHR.appendData('ChangeMac',1);}else{XHR.appendData('ChangeMac',0);}\n\t\t\tif(document.getElementById('UsePhys').checked){XHR.appendData('UsePhys',1);}else{XHR.appendData('UsePhys',0);}\n\t\t\t\n\t\t\t\n\t\t\tvar mcaddr=document.getElementById('MAC1').value+':'+document.getElementById('MAC2').value+':'+document.getElementById('MAC3').value+':';\n\t\t\tmcaddr=mcaddr+document.getElementById('MAC4').value+':'+document.getElementById('MAC5').value+':'+document.getElementById('MAC6').value\n\t\t\t\n\t\t\tXHR.appendData('MacAddr',mcaddr);\n\t\t\tXHR.appendData('rootpwd',rootpwd);\n\t\t\tXHR.appendData('hostname',document.getElementById('hostname').value);\n\t\t\tXHR.appendData('PhysNic',document.getElementById('PhysNic').value);\n\t\t\tXHR.appendData('member',document.getElementById('lxc-member').value);\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tif(document.getElementById('autostart').checked){XHR.appendData('autostart',1);}else{XHR.appendData('autostart',0);}\n\t\t\tif(document.getElementById('enabledvps').checked){XHR.appendData('enabled',1);}else{XHR.appendData('enabled',0);}\n\t\t\tXHR.appendData('ID','{$_GET["ID"]}');\n\t\t\tdocument.getElementById('lxc_host_{$_GET["ID"]}').innerHTML='<center style=\"width:100%\"><img src=img/wait_verybig.gif></center>';   \n\t\t\tXHR.sendAndLoad('{$page}', 'GET',x_SaveVPSServerSingle{$_GET["ID"]});\t\t\n\t}\n\n\tfunction CheckTemplate(){\n\t\tvar ID={$_GET["ID"]};\n\t\tChangeMacCheck();\n\t\tif(ID>0){CheckTemplateRights();return;}\n\t\tdocument.getElementById('machine_name').disabled=true;\n\t\tif(document.getElementById('ipaddr')){document.getElementById('ipaddr').disabled=true;}\n\t\tif(document.getElementById('VirtualInterface')){document.getElementById('VirtualInterface').disabled=true;}\n\t\tdocument.getElementById('rootpwd').disabled=true;\n\t\tdocument.getElementById('hostname').disabled=true;\n\t\tdocument.getElementById('autostart').disabled=true;\n\t\tdocument.getElementById('enabledvps').disabled=true;\n\t\tvar tpl=document.getElementById('lxc_template').value;\n\t\tif(tpl.length==0){\n\t\t\tCheckTemplateRights();\n\t\t\treturn;\n\t\t}\n\t\tif(document.getElementById('ipaddr')){document.getElementById('ipaddr').disabled=false;}\n\t\tif(document.getElementById('VirtualInterface')){document.getElementById('VirtualInterface').disabled=false;}\n\t\tdocument.getElementById('rootpwd').disabled=false;\n\t\tdocument.getElementById('hostname').disabled=false;\n\t\tdocument.getElementById('autostart').disabled=false;\n\t\tdocument.getElementById('enabledvps').disabled=false;\n\t\tdocument.getElementById('machine_name').disabled=false;\n\t\tdocument.getElementById('lxc_template').disabled=false;\t\n\t\tCheckTemplateRights();\n\t\t\n\t\n\t}\n\t\n\tfunction CheckTemplateRights(){\n\t\tvar AsVirtualBoxManager={$AsVirtualBoxManager};\n\t\tif(document.getElementById('ipaddr')){document.getElementById('ipaddr').disabled=true;}\n\t\tdocument.getElementById('lxc-member').disabled=true;\n\t\tdocument.getElementById('UsePhys').disabled=true;\n\t\tdocument.getElementById('ChangeMac').disabled=true;\n\t\tif(AsVirtualBoxManager==0){return;}\n\t\tif(document.getElementById('ipaddr')){document.getElementById('ipaddr').disabled=false;}\n\t\tdocument.getElementById('lxc-member').disabled=false;\n\t\tdocument.getElementById('UsePhys').disabled=false;\n\t\tdocument.getElementById('ChangeMac').false;\n\t}\n\t\n\t\n\t\tfunction ChangeMacCheck(){\n\t\t\tif(!document.getElementById('UsePhys').checked){\n\t\t\t\tdocument.getElementById('PhysNic').disabled=true;\n\t\t\t}else{\n\t\t\t\tdocument.getElementById('PhysNic').disabled=false;\n\t\t\t}\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\tdocument.getElementById('MAC1').disabled=true;\n\t\t\tdocument.getElementById('MAC2').disabled=true;\n\t\t\tdocument.getElementById('MAC3').disabled=true;\n\t\t\tdocument.getElementById('MAC4').disabled=true;\n\t\t\tdocument.getElementById('MAC5').disabled=true;\n\t\t\tdocument.getElementById('MAC6').disabled=true;\n\t\t\tif(!document.getElementById('ChangeMac').checked){return;}\n\t\t\tdocument.getElementById('MAC1').disabled=false;\n\t\t\tdocument.getElementById('MAC2').disabled=false;\n\t\t\tdocument.getElementById('MAC3').disabled=false;\n\t\t\tdocument.getElementById('MAC4').disabled=false;\n\t\t\tdocument.getElementById('MAC5').disabled=false;\n\t\t\tdocument.getElementById('MAC6').disabled=false;\t\t\t\n\t\t\t\n\t\t\n\t\t}\t\n\t\n\tCheckTemplate();\n\n</script>\n\n";
    echo $tpl->_ENGINE_parse_body($html);
}
 /** getmacman() get the mac manager information
  * @return void
  */
 public function getmacman()
 {
     try {
         if (!$_SESSION['AllowAJAXTasks']) {
             throw new Exception(_('FOG Session Invalid'));
         }
         $prefix = $_REQUEST['prefix'];
         if (!$prefix && strlen($prefix) >= 8) {
             throw new Exception(_('Unknown'));
         }
         if (!$this->FOGCore->getMACLookupCount() > 0) {
             throw new Exception('<a href="?node=about&sub=mac-list">' . _('Load MAC Vendors') . '</a>');
         }
         $MAC = new MACAddress($prefix);
         if ($MAC && $MAC->isValid()) {
             $Data = '<small>' . ($mac == 'n/a' ? _('Unknown') : $this->FOGCore->getMACManufacturer($MAC->getMACPrefix())) . '</small>';
         }
     } catch (Exception $e) {
         $Data = $e->getMessage();
     }
     print $Data;
 }