Exemple #1
0
 $s = new stdClass();
 $s->portnumber = $app->request->get('portnumber');
 $s->connectto = $app->request->get('connectto');
 $s->listports = $app->request->get('listports');
 $s->patchpanels = $app->request->get('patchpanels');
 $s->limiter = $app->request->get('limiter');
 $response['error'] = false;
 $response['errorcode'] = 200;
 // I like nulls and wrote this function originally around them
 foreach ($s as $prop => $val) {
     $s->{$prop} = !$val ? null : $val;
 }
 if (is_null($s->listports)) {
     $response['device'] = DevicePorts::getPatchCandidates($deviceid, $s->portnumber, null, $s->patchpanels, $s->limiter);
 } else {
     $dp = new DevicePorts();
     $dp->DeviceID = $s->connectto;
     $list = $dp->getPorts();
     foreach ($list as $key => $port) {
         if (!is_null($port->ConnectedDeviceID)) {
             if ($port->ConnectedDeviceID == $deviceid && $port->ConnectedPort == $s->portnumber) {
                 // This is what is currently connected so leave it in the list
             } else {
                 // Remove any other ports that already have connections
                 unset($list[$key]);
             }
         }
     }
     // S.U.T. #2342 I touch myself
     if ($dp->DeviceID == $deviceid && isset($list[$s->portnumber])) {
         unset($list[$s->portnumber]);
Exemple #2
0
        if ($id == "dc-front") {
            $idnum = 1;
        } elseif ($id == "dc-rear") {
            $idnum = 2;
        }
        $id = " name=\"{$id}\" id=\"{$id}\"";
    }
    $dcpicklist = "<select{$id}><option value=0>&nbsp;</option>";
    foreach ($dcList as $d) {
        $dcpicklist .= "<option value={$d->DataCenterID}>{$d->Name}</option>";
    }
    $dcpicklist .= '</select>';
    return $dcpicklist;
}
if (isset($_POST['action']) && $_POST['action'] == 'delete') {
    $port = new DevicePorts();
    $ports = array();
    // list of ports we want to remove
    $rights = "None";
    for ($i = 1; $i < count($_POST["PortNumber"]); $i++) {
        if ($_POST["PortNumber"][$i] > 0) {
            $port->DeviceID = $_POST["DeviceID"][$i];
            $port->PortNumber = $_POST["PortNumber"][$i];
            $port->getPort();
            $dev = new Device();
            $dev->DeviceID = $port->DeviceID;
            $dev->GetDevice();
            $rights = $dev->Rights == "Write" ? "Write" : $rights;
            //only remove connections between front ports
            if ($port->ConnectedPort > 0) {
                // Add to the list
Exemple #3
0
    displayjson($cab->ListCabinetsByDC());
}
if (isset($_POST['cab'])) {
    $dev = new Device();
    $dev->Cabinet = $_POST['cab'];
    // Filter devices by rights
    $devs = array();
    foreach ($dev->ViewDevicesByCabinet(true) as $d) {
        if ($d->Rights == "Write") {
            $devs[] = $d;
        }
    }
    displayjson($devs);
}
if (isset($_POST['dev'])) {
    $dp = new DevicePorts();
    $dp->DeviceID = $_POST['dev'];
    $dev = new Device();
    $dev->DeviceID = $dp->DeviceID;
    $dev->GetDevice();
    $ports = $dev->Rights == "Write" ? $dp->getPorts() : array();
    displayjson($ports);
}
// AJAX - End
if (!$person->SiteAdmin) {
    // No soup for you.
    header('Location: ' . redirect());
    exit;
}
if (isset($_POST['bot_implementar'])) {
    for ($i = 1; $i < $_POST['elem_path']; $i++) {
Exemple #4
0
 function MakePath()
 {
     $this->MakeSafe();
     //reset PathError
     $this->PathError = 0;
     //check devices/ports
     $device = new Device();
     $device->DeviceID = $this->devID1;
     if (!$device->GetDevice()) {
         $this->PathError = 1;
         //dev1 does not exist
         return false;
     }
     $devType1 = $device->DeviceType;
     if ($device->DeviceType == "Patch Panel") {
         $this->PathError = 2;
         //dev1 is a Patch Pannel
         return false;
     }
     $port1 = new DevicePorts();
     $port1->DeviceID = $this->devID1;
     $port1->PortNumber = $this->port1;
     if (!$port1->getPort()) {
         $this->PathError = 3;
         //dev1,port1 is missing
         return False;
     }
     if ($port1->ConnectedDeviceID > 0 && $port1->ConnectedPort > 0) {
         $this->PathError = 4;
         //dev1,port1 is connected
         return False;
     }
     $device->DeviceID = $this->devID2;
     if (!$device->GetDevice()) {
         $this->PathError = 5;
         //dev2 does not exist
         return false;
     }
     $devType2 = $device->DeviceType;
     if ($device->DeviceType == "Patch Panel") {
         $this->PathError = 6;
         //dev2 is a Patch Pannel
         return false;
     }
     $port2 = new DevicePorts();
     $port2->DeviceID = $this->devID2;
     $port2->PortNumber = $this->port2;
     if (!$port2->getPort()) {
         $this->PathError = 7;
         //dev2,port2 is missing
         return False;
     }
     if ($port2->ConnectedDeviceID > 0 && $port2->ConnectedPort > 0) {
         $this->PathError = 8;
         //dev2,port2 is connected
         return False;
     }
     //get dev2 info
     $this->cab2 = $device->GetDeviceCabinetID();
     //cab2
     $cabinet = new Cabinet();
     $cabinet->CabinetID = $this->cab2;
     $cabinet->GetCabinet();
     $this->row2 = $cabinet->CabRowID;
     //row2
     //if dev2 is panel protected device (connected to rear connection of a panel)
     $this->espejo2 = $port2->ConnectedDeviceID > 0 && $port2->ConnectedPort < 0;
     @unlink('ppath.log');
     $this->escribe_log("**** NEW PATH ****");
     $this->escribe_log("DEV1: ID=" . $this->devID1 . "  PORT=" . $this->port1);
     $this->escribe_log("DEV2: ID=" . $this->devID2 . "  PORT=" . $this->port2 . "  CAB_ID=" . $this->cab2 . "  ROW_ID=" . $this->row2);
     $this->escribe_log("-------------------");
     //reset Path
     $this->ClearPath();
     //initiate list with device1, port1, weitgh=0, prev_dev=0, prev_port=0
     $this->AddNodeToList($this->devID1, $this->port1, 0, 0, 0);
     while ($this->SelectNode()) {
         if ($this->DeviceID == $this->devID2) {
             $this->escribe_log("Target found. Making the PATH...");
             //make the path
             $i = 1;
             while ($this->DeviceID > 0) {
                 $dev = $this->DeviceID;
                 $port = $this->PortNumber;
                 $Path[$i]["DeviceID"] = $dev;
                 $Path[$i]["PortNumber"] = $port;
                 $this->DeviceID = $this->nodes[$dev][$port]["prev_dev"];
                 $this->PortNumber = $this->nodes[$dev][$port]["prev_port"];
                 $i++;
             }
             for ($j = 1; $j < $i; $j++) {
                 $this->Path[$j]["DeviceID"] = $Path[$i - $j]["DeviceID"];
                 $this->Path[$j]["PortNumber"] = $Path[$i - $j]["PortNumber"];
             }
             $this->escribe_log("PATH created.");
             $this->escribe_log("");
             return true;
         }
         $this->UpdateList();
     }
     $this->PathError = 9;
     //not found
     return false;
 }
Exemple #5
0
        // Allow the user to modify the port if they have rights over the patch panel itself or
        // the attached device, but only the front port.  The rear is still reserved for administrators only.
        $jsondata[$i] = $dev->Rights == "Write" ? true : $frontDev->Rights == "Write" ? true : false;
        $fp = "";
        //front port Label
        $cPort = new DevicePorts();
        if ($frontDev->DeviceID > 0) {
            $cPort->DeviceID = $frontDev->DeviceID;
            $cPort->PortNumber = $portList[$i]->ConnectedPort;
            $cPort->getPort();
            $fp = $cPort->Label != "" ? $cPort->Label : $cPort->PortNumber;
        }
        $mt = isset($mediaTypes[$portList[$i]->MediaID]) ? $mediaTypes[$portList[$i]->MediaID]->MediaType : '';
        // rear port Label
        if ($portList[-$i]->ConnectedPort != '') {
            $p = new DevicePorts();
            $p->DeviceID = $portList[-$i]->ConnectedDeviceID;
            $p->PortNumber = $portList[-$i]->ConnectedPort;
            $p->getPort();
            $rp = $p->Label == '' ? abs($p->PortNumber) : $p->Label;
            $p->PortNumber < 0 ? $rp .= ' (' . __("Rear") . ')' : '';
        } else {
            $rp = '';
        }
        $portList[$i]->Label = $portList[$i]->Label == '' ? $i : $portList[$i]->Label;
        print "\n\t\t\t\t<div data-port={$i}>\r\n\t\t\t\t\t<div id=\"fd{$i}\" data-default={$frontDev->DeviceID}><a href=\"devices.php?DeviceID={$frontDev->DeviceID}\">{$frontDev->Label}</a></div>\r\n\t\t\t\t\t<div id=\"fp{$i}\" data-default={$portList[$i]->ConnectedPort}><a href=\"paths.php?deviceid={$frontDev->DeviceID}&portnumber={$portList[$i]->ConnectedPort}\">{$fp}</a></div>\r\n\t\t\t\t\t<div id=\"fn{$i}\" data-default=\"{$portList[$i]->Notes}\">{$portList[$i]->Notes}</div>\r\n\t\t\t\t\t<div id=\"pp{$i}\">{$portList[$i]->Label}</div>\r\n\t\t\t\t\t<div id=\"mt{$i}\" data-default={$portList[$i]->MediaID} data-color={$portList[$i]->ColorID}>{$mt}</div>\r\n\t\t\t\t\t<div id=\"rd{$i}\" data-default={$rearDev->DeviceID}><a href=\"devices.php?DeviceID={$rearDev->DeviceID}\">{$rearDev->Label}</a></div>\r\n\t\t\t\t\t<div id=\"rp{$i}\" data-default={$portList[-$i]->ConnectedPort}><a href=\"paths.php?deviceid={$rearDev->DeviceID}&portnumber={$portList[-$i]->ConnectedPort}\">{$rp}</a></div>\r\n\t\t\t\t\t<div id=\"rn{$i}\" data-default=\"{$portList[-$i]->Notes}\">{$portList[-$i]->Notes}</div>\r\n\t\t\t\t</div>";
    }
    print "\t\t\t</div><!-- END div.table -->\n\t\t</div>\n\t</div>\n";
}
?>
		<div class="caption">
if (isset($_GET["getDevList"])) {
    $returnData = array();
    $devList = array();
    $getDevList = json_decode($_GET["getDevList"]);
    foreach ($getDevList as $getDev) {
        $dev = new Device();
        $dev->DeviceID = $getDev;
        if ($dev->GetDevice()) {
            $devList[] = $dev;
            $returnData[] = $dev;
        }
    }
    if (isset($_GET["getConnList"])) {
        $connList = array();
        foreach ($devList as $dev) {
            $ports = DevicePorts::getPortList($dev->DeviceID);
            foreach ($ports as $port) {
                $notdup = true;
                if (isset($port->ConnectedDeviceID)) {
                    $returnData[] = $port;
                }
            }
        }
    }
    header('Content-Type: application/json');
    echo json_encode($returnData);
    exit;
}
//build add device menu
$addmenuhtml = "\n<ul id='menu-add-devices'>\n  <li><a>Add Devices</a>\n    <ul>";
$cList = new Container();
}
$logo = getcwd() . '/images/' . $config->ParameterArray["PDFLogoFile"];
$logo = $message->embed(Swift_Image::fromPath($logo)->setFilename('logo.png'));
$htmlMessage = sprintf("<!doctype html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><title>ITS Data Center Inventory</title></head><body><div id=\"header\" style=\"padding: 5px 0;background: %s;\"><center><img src=\"%s\"></center></div><div class=\"page\"><p>\n", $config->ParameterArray["HeaderColor"], $logo);
$htmlMessage .= sprintf("<p>The following switches are near full capacity per documentation.</p>");
$devList = Device::GetSwitchesToReport();
$lastDC = null;
$lastCabinet = null;
$urlBase = $config->ParameterArray["InstallURL"];
$threshold = intval($config->ParameterArray["NetworkThreshold"]) / 100;
if (sizeof($devList) == 0) {
    $htmlMessage .= "<p>There are no switches that qualify for this report.</p>\n";
} else {
    $cab = new Cabinet();
    $dc = new DataCenter();
    $port = new DevicePorts();
    $dev = new Device();
    $exceptionRows = "";
    $mismatchRows = "";
    foreach ($devList as $devRow) {
        if ($devRow->Cabinet != $lastCabinet) {
            $cab->CabinetID = $devRow->Cabinet;
            $cab->GetCabinet();
            $lastCabinet = $cab->CabinetID;
            $cabinet = $cab->Location;
        }
        if ($cab->DataCenterID != $lastDC) {
            $dc->DataCenterID = $cab->DataCenterID;
            $dc->GetDataCenter();
            $lastDC = $dc->DataCenterID;
            $dataCenter = $dc->Name;