Example #1
0
     } elseif (isset($_POST['type'])) {
         $type = $_POST['type'];
     } else {
         // TODO
         exit(100);
     }
     if (isset($_GET['port'])) {
         $port = $_GET['port'];
     } elseif (isset($_POST['port'])) {
         $port = $_POST['port'];
     } else {
         // TODO
         exit(100);
     }
     $server = new server($deviceId);
     $osM = new osManager($deviceId);
     if ($osM->getId($type, $port) == 0) {
         $osM->create($type, $port);
     }
     // TODO - add result
     echo '<script>location.reload();</script>';
     break;
 case 'osCreateForm':
     if (isset($_GET['deviceId'])) {
         $deviceId = $_GET['deviceId'];
     } elseif (isset($_POST['deviceId'])) {
         $deviceId = $_POST['deviceId'];
     } else {
         // TODO
         exit(100);
     }
<?php

// Parse the data
$itemCount = 0;
while (is_object($items = $item_DATA->getElementsByTagName("SERVERS")->item($itemCount))) {
    foreach ($items->childNodes as $item) {
        $hostname = $item->getElementsByTagName("NAME")->item(0)->nodeValue;
        $serverStatus = $item->getElementsByTagName("CONNECT_STATUS")->item(0)->nodeValue;
        $serverCode = $item->getElementsByTagName("CONNECT_CODE")->item(0)->nodeValue;
        //
        $devM = new deviceManager();
        $dev = new device($devM->getId('server', $hostname));
        $server = new server($dev->id);
        $osM = new osManager($dev->id);
        $osItemCount = 0;
        while (is_object($osItems = $item->getElementsByTagName("OSES")->item($osItemCount))) {
            foreach ($osItems->childNodes as $osItem) {
                $osName = $osItem->getElementsByTagName("NAME")->item(0)->nodeValue;
                $osPort = $osItem->getElementsByTagName("PORT")->item(0)->nodeValue;
                $osStatus = $osItem->getElementsByTagName("CONNECT_STATUS")->item(0)->nodeValue;
                $osCode = $osItem->getElementsByTagName("CONNECT_CODE")->item(0)->nodeValue;
                if ($osM->getId($osName, $osPort) == 0) {
                    $osM->create($osName, $osPort);
                }
            }
            $osItemCount++;
        }
    }
    $itemCount++;
}
<?php

// Parse the data
$itemCount = 0;
while (is_object($items = $item_DATA->getElementsByTagName("SERVERS")->item($itemCount))) {
    foreach ($items->childNodes as $item) {
        $hostname = $item->getElementsByTagName("NAME")->item(0)->nodeValue;
        $devM = new deviceManager();
        $dev = new device($devM->getId('server', $hostname));
        $server = new server($dev->id);
        $osM = new osManager($dev->id);
        $osItemCount = 0;
        while (is_object($osItems = $item->getElementsByTagName("OSES")->item($osItemCount))) {
            foreach ($osItems->childNodes as $osItem) {
                $osType = $osItem->getElementsByTagName("TYPE")->item(0)->nodeValue;
                $osPort = $osItem->getElementsByTagName("PORT")->item(0)->nodeValue;
                if ($osM->getId($osType, $osPort) == 0) {
                    $osM->create($osType, $osPort);
                }
                $os = new os($osM->getId($osType, $osPort));
                $cpuM = new cpuManager($os->id);
                $diskM = new diskManager($os->id);
                $fsM = new fsManager($os->id);
                $serviceM = new serviceManager($os->id);
                $dbInstanceM = new dbInstanceManager($os->id);
                if (isset($osItem->getElementsByTagName("NAME")->item(0)->nodeValue)) {
                    $osName = $osItem->getElementsByTagName("NAME")->item(0)->nodeValue;
                } else {
                    $osName = '';
                }
                if (isset($osItem->getElementsByTagName("VERSION")->item(0)->nodeValue)) {