if ($status == __("Updated")) {
                $status = updatecdu($template, $status);
                $status = updatesensor($template, $status);
            }
            if ($status == __("Updated")) {
                $status = $template->ExportTemplate() ? __("Exported") : __("Error");
            }
            break;
        default:
            // do nothing if the value isn't one we expect
    }
}
$templateList = $template->GetTemplateList();
$ManufacturerList = $manufacturer->GetManufacturerList();
$ManufacturerListByID = $manufacturer->GetManufacturerList(true);
$mtList = MediaTypes::GetMediaTypeList();
$ccList = ColorCoding::GetCodeList();
$dcaList = DeviceCustomAttribute::GetDeviceCustomAttributeList();
$imageselect = '<div id="preview"></div><div id="filelist">';
$path = './pictures';
$dir = scandir($path);
foreach ($dir as $i => $f) {
    if (is_file($path . DIRECTORY_SEPARATOR . $f)) {
        // Suppress the getimagesize because it will error out on non-image files
        @($imageinfo = getimagesize($path . DIRECTORY_SEPARATOR . $f));
        if (preg_match('/^image/i', $imageinfo['mime'])) {
            $imageselect .= "<span>{$f}</span>\n";
        }
    }
}
$imageselect .= "</div>";
Exemple #2
0
    $devarray = array('Server' => __("Server"), 'Appliance' => __("Appliance"), 'Storage Array' => __("Storage Array"), 'Switch' => __("Switch"), 'Chassis' => __("Chassis"), 'Patch Panel' => __("Patch Panel"), 'Sensor' => __("Sensor"));
} else {
    $devarray = array('Server' => __("Server"), 'Appliance' => __("Appliance"), 'Storage Array' => __("Storage Array"), 'Switch' => __("Switch"), 'Chassis' => __("Chassis"), 'Patch Panel' => __("Patch Panel"), 'Physical Infrastructure' => __("Physical Infrastructure"), 'CDU' => __("CDU"), 'Sensor' => __("Sensor"));
}
if ($config->ParameterArray["mDate"] == "now") {
    if ($dev->MfgDate <= "1970-01-01") {
        $dev->MfgDate = date("Y-m-d");
    }
}
if ($config->ParameterArray["wDate"] == "now") {
    if ($dev->WarrantyExpire <= "1970-01-01") {
        $dev->WarrantyExpire = date("Y-m-d");
    }
}
$portList = DevicePorts::getPortList($dev->DeviceID);
$mediaTypes = MediaTypes::GetMediaTypeList();
$colorCodes = ColorCoding::GetCodeList();
$templateList = $templ->GetTemplateList();
$escTimeList = $escTime->GetEscalationTimeList();
$escList = $esc->GetEscalationList();
$deptList = $Dept->GetDepartmentList();
$templ->TemplateID = $dev->TemplateID;
$templ->GetTemplateByID();
$title = $dev->Label != '' ? "{$dev->Label} :: {$dev->DeviceID}" : __("openDCIM Device Maintenance");
function buildESXtable($DeviceID)
{
    $ESX = new ESX();
    $ESX->DeviceID = $DeviceID;
    $vmList = $ESX->GetDeviceInventory();
    print "\n<div class=\"table border\"><div><div>" . __("VM Name") . "</div><div>" . __("Status") . "</div><div>" . __("Owner") . "</div><div>" . __("Last Updated") . "</div></div>\n";
    foreach ($vmList as $vmRow) {
Exemple #3
0
 static function getPatchCandidates($DeviceID, $PortNum = null, $listports = null, $patchpanels = null, $scopelimit = null)
 {
     /*
      * $DeviceID = ID of the device that you are wanting to make a connection from
      * $PortNum(optional) = Port Number on the device you are wanting to connect,
      *		mandatory if media enforcing is on
      * $listports(optional) = Any value will trigger this to kick back a list of
      * 		valid points that this port can connect to instead of the default list
      *		of valid devices that it can connect to.
      */
     global $dbh;
     global $config;
     global $person;
     $dev = new Device();
     // make sure we have a real device first
     $dev->DeviceID = $DeviceID;
     if (!$dev->GetDevice()) {
         return false;
     }
     $mediaenforce = "";
     if ($config->ParameterArray["MediaEnforce"] == 'enabled' && !is_null($PortNum)) {
         $dp = new DevicePorts();
         $dp->DeviceID = $DeviceID;
         $dp->PortNumber = $PortNum;
         $dp->getPort();
         $mt = new MediaTypes();
         $mt->MediaID = $dp->MediaID;
         $mt->GetType();
         $mediaenforce = " AND MediaID={$mt->MediaID}";
     } elseif ($config->ParameterArray["MediaEnforce"] == 'enabled' && is_null($PortNum)) {
         // Media Type Enforcing is enabled and you didn't supply a port to match type on
         return false;
     }
     $limiter = '';
     if (!is_null($scopelimit)) {
         $cab = new Cabinet();
         $cab->CabinetID = $dev->Cabinet;
         $cab->GetCabinet();
         switch ($scopelimit) {
             case 'cabinet':
                 $limiter = " AND Cabinet={$dev->Cabinet}";
                 break;
             case 'row':
                 $limiter = " AND Cabinet IN (SELECT CabinetID FROM fac_Cabinet WHERE CabRowID={$cab->CabRowID} AND CabRowID>0)";
                 break;
             case 'zone':
                 $limiter = " AND Cabinet IN (SELECT CabinetID FROM fac_Cabinet WHERE ZoneID={$cab->ZoneID} AND ZoneID>0)";
                 break;
             case 'datacenter':
                 $limiter = " AND Cabinet IN (SELECT CabinetID FROM fac_Cabinet WHERE DataCenterID={$cab->DataCenterID})";
                 break;
             default:
                 break;
         }
     }
     $pp = "";
     if (!is_null($patchpanels)) {
         $pp = ' AND DeviceType="Patch Panel"';
     }
     $candidates = array();
     if (is_null($listports)) {
         $currentperson = $person;
         if (!$currentperson->WriteAccess) {
             $groups = $currentperson->isMemberOf();
             // list of groups the current user is member of
             $rights = null;
             foreach ($groups as $index => $DeptID) {
                 if (is_null($rights)) {
                     $rights = "Owner={$DeptID}";
                 } else {
                     $rights .= " OR Owner={$DeptID}";
                 }
             }
             $rights = is_null($rights) ? null : " AND ({$rights})";
         } else {
             $rights = null;
         }
         $cabinetID = $dev->GetDeviceCabinetID();
         $sqlSameCabDevice = "SELECT * FROM fac_Device WHERE Ports>0 AND \r\n\t\t\t\tCabinet={$cabinetID} {$rights}{$pp}{$limiter} GROUP BY DeviceID ORDER BY Position \r\n\t\t\t\tDESC, Label ASC;";
         $sqlDiffCabDevice = "SELECT * FROM fac_Device WHERE Ports>0 AND \r\n\t\t\t\tCabinet!={$cabinetID} {$rights}{$pp}{$limiter} GROUP BY DeviceID ORDER BY Label ASC;";
         foreach (array($sqlSameCabDevice, $sqlDiffCabDevice) as $sql) {
             foreach ($dbh->query($sql) as $row) {
                 // false to skip rights check we filtered using sql above
                 $tmpDev = Device::RowToObject($row, false);
                 $candidates[] = array("DeviceID" => $tmpDev->DeviceID, "Label" => $tmpDev->Label, "CabinetID" => $tmpDev->Cabinet);
             }
         }
     } else {
         $sql = "SELECT a.*, b.Cabinet as CabinetID FROM fac_Ports a, fac_Device b WHERE \r\n\t\t\t\tPorts>0 AND Cabinet>-1 AND a.DeviceID=b.DeviceID AND \r\n\t\t\t\ta.DeviceID!={$dev->DeviceID} AND ConnectedDeviceID IS NULL{$mediaenforce}{$pp};";
         foreach ($dbh->query($sql) as $row) {
             $candidates[] = array("DeviceID" => $row["DeviceID"], "Label" => $row["Label"], "CabinetID" => $row["CabinetID"]);
         }
     }
     return $candidates;
 }
 function isVisible($file)
 {
     return !MediaTypes::isHidden($file) && (MediaTypes::isPlaylist($file) || MediaTypes::isVideo($file) || MediaTypes::isAudio($file));
 }
     if ($colorType == 0 || $colorType == 1) {
         $cc = new ColorCoding();
         $cc->ColorID = $colorKey;
         $cc->GetCode();
         $label = $cc->Name != "" ? $cc->Name : "Unset";
     } elseif ($colorType == 2) {
         $mt = new MediaTypes();
         $mt->MediaID = $colorKey;
         $mt->GetType();
         $label = $mt->MediaType != "" ? $mt->MediaType : "Unset";
     } else {
         $keys = explode(':', $colorKey);
         $cc = new ColorCoding();
         $cc->ColorID = $keys[0];
         $cc->GetCode();
         $mt = new MediaTypes();
         $mt->MediaID = $keys[1];
         $mt->GetType();
         $colorname = $cc->Name != "" ? $cc->Name : "Unset";
         $mediatype = $mt->MediaType != "" ? $mt->MediaType : "Unset";
         $label = $mediatype . "--" . $colorname;
     }
     $graphstr .= "\t\tinvis1 -- invis2 [color=" . $color . ",label=\"" . $label . "\"];\n";
 }
 $graphstr .= "\t}\n}";
 # safe format types. newer versions of graphviz also support pdf. maybe
 # we should add it when the ability is more prevalent.
 $formatTypes = array('svg', 'png', 'jpg', 'dot');
 if (!isset($formatTypes[$_REQUEST['format']])) {
     exit;
 }
Exemple #6
0
        } else {
            echo 'f';
        }
    } else {
        if ($mt->CreateType()) {
            echo $mt->MediaID;
        } else {
            echo 'f';
        }
    }
    exit;
}
if (isset($_POST['mtused'])) {
    $count = MediaTypes::TimesUsed($_POST['mtused']);
    if ($count == 0) {
        $mt = new MediaTypes();
        $mt->MediaID = $_POST['mtused'];
        $mt->DeleteType();
    }
    echo $count;
    exit;
}
if (isset($_POST['mtlist'])) {
    $codeList = MediaTypes::GetMediaTypeList();
    $output = '<option value=""></option>';
    foreach ($codeList as $mt) {
        $output .= "<option value=\"{$mt->MediaID}\">{$mt->MediaType}</option>";
    }
    echo $output;
    exit;
}
 /**
  * Returns a media type based on the filename extension
  *
  * @param  string $filename Filename to determine the media type for
  * @return string
  * @deprecated since 1.1.0
  */
 public static function getMediaTypeFromFilename($filename)
 {
     return MediaTypes::getMediaTypeFromFilename($filename);
 }
 function ImportTemplate($file)
 {
     $result = array();
     $result["status"] = "";
     $result["log"] = array();
     $ierror = 0;
     //validate xml template file with openDCIMdevicetemplate.xsd
     libxml_use_internal_errors(true);
     $xml = new XMLReader();
     $xml->open($file);
     $resp = $xml->setSchema("openDCIMdevicetemplate.xsd");
     while (@$xml->read()) {
     }
     // empty loop
     $errors = libxml_get_errors();
     if (count($errors) > 0) {
         $result["status"] = __("No valid file");
         foreach ($errors as $error) {
             $result["log"][$ierror++] = $error->message;
         }
         return $result;
     }
     libxml_clear_errors();
     $xml->close();
     //read xml template file
     $xmltemplate = simplexml_load_file($file);
     //manufacturer
     $manufacturer = new Manufacturer();
     $manufacturer->Name = transform($xmltemplate->ManufacturerName);
     if (!$manufacturer->GetManufacturerByName()) {
         //New Manufacturer
         $manufacturer->CreateManufacturer();
     }
     $template = new DeviceTemplate();
     $template->ManufacturerID = $manufacturer->ManufacturerID;
     $template->Model = transform($xmltemplate->TemplateReg->Model);
     $template->Height = $xmltemplate->TemplateReg->Height;
     $template->Weight = $xmltemplate->TemplateReg->Weight;
     $template->Wattage = $xmltemplate->TemplateReg->Wattage;
     $template->DeviceType = $xmltemplate->TemplateReg->DeviceType;
     $template->PSCount = $xmltemplate->TemplateReg->PSCount;
     $template->NumPorts = $xmltemplate->TemplateReg->NumPorts;
     $template->Notes = trim($xmltemplate->TemplateReg->Notes);
     $template->Notes = $template->Notes == "<br>" ? "" : $template->Notes;
     $template->FrontPictureFile = $xmltemplate->TemplateReg->FrontPictureFile;
     $template->RearPictureFile = $xmltemplate->TemplateReg->RearPictureFile;
     $template->SNMPVersion = $xmltemplate->TemplateReg->SNMPVersion;
     $template->ChassisSlots = $template->DeviceType == "Chassis" ? $xmltemplate->TemplateReg->ChassisSlots : 0;
     $template->RearChassisSlots = $template->DeviceType == "Chassis" ? $xmltemplate->TemplateReg->RearChassisSlots : 0;
     //Check if picture files exist
     if ($template->FrontPictureFile != "" && file_exists("pictures/" . $template->FrontPictureFile)) {
         $result["status"] = __("Import Error");
         $result["log"][0] = __("Front picture file already exists");
         return $result;
     }
     if ($template->RearPictureFile != "" && file_exists("pictures/" . $template->RearPictureFile)) {
         $result["status"] = __("Import Error");
         $result["log"][0] = __("Rear picture file already exists");
         return $result;
     }
     //create the template
     if (!$template->CreateTemplate()) {
         $result["status"] = __("Import Error");
         $result["log"][0] = __("An error has occurred creating the template.<br>Possibly there is already a template of the same manufacturer and model");
         return $result;
     }
     //get template to this object
     $this->TemplateID = $template->TemplateID;
     $this->GetTemplateByID();
     //slots
     foreach ($xmltemplate->SlotReg as $xmlslot) {
         $slot = new Slot();
         $slot->TemplateID = $this->TemplateID;
         $slot->Position = intval($xmlslot->Position);
         $slot->BackSide = intval($xmlslot->BackSide);
         $slot->X = intval($xmlslot->X);
         $slot->Y = intval($xmlslot->Y);
         $slot->W = intval($xmlslot->W);
         $slot->H = intval($xmlslot->H);
         if ($slot->Position <= $this->ChassisSlots && !$slot->BackSide || $slot->Position <= $this->RearChassisSlots && $slot->BackSide) {
             if (!$slot->CreateSlot()) {
                 $result["status"] = __("Import Warning");
                 $result["log"][$ierror++] = sprintf(__("An error has occurred creating the slot %s"), $slot->Position . "-" . $slot->BackSide ? __("Rear") : __("Front"));
             }
         } else {
             $result["status"] = __("Import Warning");
             $result["log"][$ierror++] = sprintf(__("Ignored slot %s"), $slot->Position . "-" . $slot->BackSide ? __("Rear") : __("Front"));
         }
     }
     //ports
     foreach ($xmltemplate->PortReg as $xmlport) {
         //media type
         $mt = new MediaTypes();
         $mt->MediaType = transform($xmlport->PortMedia);
         if (!$mt->GetTypeByName()) {
             //New media type
             $mt->CreateType();
         }
         //color
         $cc = new ColorCoding();
         $cc->Name = transform($xmlport->PortColor);
         if (!$cc->GetCodeByName()) {
             //New color
             $cc->CreateCode();
         }
         $tport = new TemplatePorts();
         $tport->TemplateID = $this->TemplateID;
         $tport->PortNumber = intval($xmlport->PortNumber);
         $tport->Label = $xmlport->Label;
         $tport->MediaID = $mt->MediaID;
         $tport->ColorID = $cc->ColorID;
         $tport->PortNotes = $xmlport->PortNotes;
         if ($tport->PortNumber <= $this->NumPorts) {
             if (!$tport->CreatePort()) {
                 $result["status"] = __("Import Warning");
                 $result["log"][$ierror++] = sprintf(__("An error has occurred creating the port %s"), $tport->PortNumber);
             }
         } else {
             $result["status"] = __("Import Warning");
             $result["log"][$ierror++] = sprintf(__("Ignored port %s"), $tport->PortNumber);
         }
     }
     //files
     if ($this->FrontPictureFile != "") {
         $im = base64_decode($xmltemplate->FrontPicture);
         file_put_contents("pictures/" . $this->FrontPictureFile, $im);
     }
     if ($this->RearPictureFile != "" && $this->RearPictureFile != $this->FrontPictureFile) {
         $im = base64_decode($xmltemplate->RearPicture);
         file_put_contents("pictures/" . $this->RearPictureFile, $im);
     }
     return $result;
 }
function getFilesFromWatchfolder($directory)
{
    mountNetworkShare($directory);
    $files = array();
    $base = '';
    $directory = substr($directory, 0, -1);
    exec("ls -1R {$directory}", $output);
    while (list(, $line) = each($output)) {
        if (substr($line, -1) == ':') {
            $base = substr($line, 0, -1);
            if (MediaTypes::isVisible($base)) {
                $files[] = $base;
            }
        } else {
            if ($line != '') {
                $file = $base . '/' . $line;
                if (MediaTypes::isVisible($file)) {
                    $files[] = $file;
                }
            }
        }
    }
    return $files;
}
         $targetDev->GetDevice();
         $targetPort->DeviceID = $targetDev->DeviceID;
         $targetPort->PortNumber = $powerPort->ConnectedPort;
         $targetPort->getPort();
         $sheet->getActiveSheet()->SetCellValue('C' . $row, $targetDev->Label);
         $sheet->getActiveSheet()->SetCellValue('D' . $row, $targetPort->Label);
         $sheet->getActiveSheet()->SetCellValue('H' . $row, __("Power Connection"));
     }
     $row++;
 }
 foreach ($portList as $devPort) {
     // These are created inside the loop, because they need to be clean instances each time
     $targetDev = new Device();
     $targetPort = new DevicePorts();
     $color = new ColorCoding();
     $mediaType = new MediaTypes();
     if ($devPort->ConnectedDeviceID > 0 || $devPort->Notes != "") {
         $targetDev->DeviceID = $devPort->ConnectedDeviceID;
         $targetDev->GetDevice();
         $targetPort->DeviceID = $targetDev->DeviceID;
         $targetPort->PortNumber = $devPort->ConnectedPort;
         $targetPort->getPort();
         if ($targetPort->Label == '') {
             $targetPort->Label = $devPort->ConnectedDeviceID > 0 ? $devPort->ConnectedPort : '';
         }
         $color->ColorID = $devPort->ColorID;
         $color->GetCode();
         $mediaType->MediaID = $devPort->MediaID;
         $mediaType->GetType();
         $sheet->getActiveSheet()->SetCellValue('A' . $row, '="' . $dev->Label . '"');
         $sheet->getActiveSheet()->SetCellValue('B' . $row, '="' . $devPort->Label . '"');