• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP usePreparedSelectBlade函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中usePreparedSelectBlade函数的典型用法代码示例。如果您正苦于以下问题:PHP usePreparedSelectBlade函数的具体用法?PHP usePreparedSelectBlade怎么用?PHP usePreparedSelectBlade使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了usePreparedSelectBlade函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: CableIDTabHandler

function CableIDTabHandler()
{
    echo '<div class=portlet><h2>Cable ID Helper</h2></div>';
    $rack = spotEntity('rack', $_REQUEST['rack_id']);
    $result = usePreparedSelectBlade('SELECT DISTINCT object_id FROM RackSpace WHERE rack_id = ? ', array($rack['id']));
    $objects = $result->fetchAll(PDO::FETCH_ASSOC);
    $cableIDs = array();
    foreach ($objects as $object) {
        $pals = getObjectPortsAndLinks($object['object_id']);
        foreach ($pals as $portLink) {
            if ($portLink['cableid']) {
                $new = true;
                $dublicate = false;
                foreach ($cableIDs as $key => $cableID) {
                    if ($portLink['object_id'] == $cableID['object1_id'] && $portLink['name'] == $cableID['object1_port'] || $portLink['object_id'] == $cableID['object2_id'] && $portLink['name'] == $cableID['object2_port']) {
                        $new = false;
                        // Link already in List
                    }
                    // Check for duplicate cable ids
                    if ($new && $portLink['cableid'] == $cableID['cableID']) {
                        $dublicate = true;
                        $cableIDs[$key]['dublicate'] = true;
                    }
                }
                if ($new) {
                    $cableID = array();
                    $cableID['cableID'] = $portLink['cableid'];
                    $cableID['object1_id'] = $portLink['object_id'];
                    $cableID['object1_name'] = $portLink['object_name'];
                    $cableID['object1_port'] = $portLink['name'];
                    $cableID['object2_id'] = $portLink['remote_object_id'];
                    $cableID['object2_name'] = $portLink['remote_object_name'];
                    $cableID['object2_port'] = $portLink['remote_name'];
                    $cableID['dublicate'] = $dublicate;
                    array_push($cableIDs, $cableID);
                }
            }
        }
    }
    // Sort by cableIDs
    usort($cableIDs, function ($elem1, $elem2) {
        return strnatcasecmp($elem1['cableID'], $elem2['cableID']);
    });
    // Print table
    echo '<table class="cooltable" align="center" border="0" cellpadding="5" cellspacing="0">' . '<tbody>' . '  <tr>' . '  <th>CableID</th>' . '  <th>Object 1</th>' . '  <th>Object 2</th>' . '  </tr>';
    $i = 0;
    foreach ($cableIDs as $cableID) {
        if ($i % 2) {
            $class = 'row_even tdleft';
        } else {
            $class = 'row_odd tdleft';
        }
        if ($cableID['dublicate']) {
            $class .= ' trerror';
        }
        echo '<tr class="' . $class . '">' . '<td>' . $cableID['cableID'] . '</td>' . '<td><a href="' . makeHref(array('page' => 'object', 'object_id' => $cableID['object1_id'])) . '">' . $cableID['object1_name'] . ': ' . $cableID['object1_port'] . '</a></td>' . '<td><a href="' . makeHref(array('page' => 'object', 'object_id' => $cableID['object2_id'])) . '">' . $cableID['object2_name'] . ': ' . $cableID['object2_port'] . '</a></td>' . '</tr>';
        $i++;
    }
    echo '  </tbody>' . '</table>';
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:60,代码来源:cableIDHelper.php


示例2: getRacktablesObjects

function getRacktablesObjects($type_id, $attr_id, $attr_value)
{
    $r = usePreparedSelectBlade('select o.id, o.name, o.objtype_id, o.label, i.ip, i.type, i.name as ifname,
        av.attr_id as zabbix_flag_id, av.uint_value as zabbix_flag_value, av2.attr_id as sw_type_id,
        av2.uint_value as sw_type_value from Object AS o
            INNER JOIN IPv4Allocation as i ON (o.id = i.object_id AND o.objtype_id = ?)
            INNER JOIN AttributeValue av on (av.object_id = o.id AND av.attr_id = ? AND av.uint_value = ?)
			LEFT JOIN AttributeValue av2 on (av2.object_id = o.id AND av2.attr_id = ?)', array($type_id, $attr_id, $attr_value, RACKTABLES_SOFTWARE_TYPE_ID));
    $items = $r->fetchAll(PDO::FETCH_ASSOC);
    $result = array();
    foreach ($items as $item) {
        $ip = ip_format(ip4_int2bin($item['ip']));
        if (!isset($result[$item['id']])) {
            if (!empty($item['ifname'])) {
                $item['ip'] = array($item['ifname'] => $ip);
            } else {
                $item['ip'] = array($ip);
            }
            $result[$item['id']] = $item;
        } else {
            if (is_array($result[$item['id']]['ip'])) {
                if (!empty($item['ifname'])) {
                    $result[$item['id']]['ip'][$item['ifname']] = $ip;
                } else {
                    $result[$item['id']]['ip'][] = $ip;
                }
            }
        }
    }
    return $result;
}
开发者ID:andreibacos,项目名称:rackbbix,代码行数:31,代码来源:functions.php


示例3: testUpdateLinkWithPortAGreaterThanPortB

 public function testUpdateLinkWithPortAGreaterThanPortB()
 {
     usePreparedInsertBlade('Link', array('porta' => self::$porta, 'portb' => self::$portb));
     usePreparedUpdateBlade('Link', array('porta' => self::$portb, 'portb' => self::$porta), array('porta' => self::$porta, 'portb' => self::$portb));
     $result = usePreparedSelectBlade('SELECT COUNT(*) FROM Link WHERE porta=? AND portb=?', array(self::$porta, self::$portb));
     $this->assertEquals($result->fetchColumn(), 1);
 }
开发者ID:ivladdalvi,项目名称:racktables,代码行数:7,代码来源:LinkTriggerTest.php


示例4: createVMPool

/** Create a new Virtual Machine Pool
	@param		name	Pool name
	@param		tagid	Tag ID to use for this new VM
	@returns 	poolID	ID of new VMPool object
*/
function createVMPool($name, $tagid)
{
    // Get "VM Cluster" dict key
    $vmClusterTypeID = usePreparedSelectBlade("select * from Dictionary where dict_value = 'VM Cluster'")->fetch(PDO::FETCH_ASSOC);
    $vmClusterTypeID = $vmClusterTypeID['dict_key'];
    // Add the pool, with the proper type and tags
    $taglist = array($tagid);
    $poolID = commitAddObject($name, $name, $vmClusterTypeID, '', $taglist);
    // return the pool ID
    return $poolID;
}
开发者ID:xtha,项目名称:salt,代码行数:16,代码来源:importer.php


示例5: fetchBackendPortList

function fetchBackendPortList($sql_where_clause, $query_params = array())
{
    $query = <<<END
SELECT
\tPort.id,
\tPort.name,
\tPort.object_id,
\tObject.name AS object_name,
\tPort.l2address,
\tPort.label,
\tPort.reservation_comment,
\tPort.iif_id,
\tPort.type AS oif_id,
\t(SELECT PortInnerInterface.iif_name FROM PortInnerInterface WHERE PortInnerInterface.id = Port.iif_id) AS iif_name,
\t(SELECT Dictionary.dict_value FROM Dictionary WHERE Dictionary.dict_key = Port.type) AS oif_name,
\tIF(lba.porta, lba.cable, lbb.cable) AS cableid,
\tIF(lba.porta, pa.id, pb.id) AS remote_id,
\tIF(lba.porta, pa.name, pb.name) AS remote_name,
\tIF(lba.porta, pa.object_id, pb.object_id) AS remote_object_id,
\tIF(lba.porta, oa.name, ob.name) AS remote_object_name,
\t(SELECT COUNT(*) FROM PortLog WHERE PortLog.port_id = Port.id) AS log_count,
\tPortLog.user,
\tUNIX_TIMESTAMP(PortLog.date) as time
FROM
\tPort
\tINNER JOIN Object ON Port.object_id = Object.id
\tLEFT JOIN LinkBackend AS lba ON lba.porta = Port.id
\tLEFT JOIN Port AS pa ON pa.id = lba.portb
\tLEFT JOIN Object AS oa ON pa.object_id = oa.id
\tLEFT JOIN LinkBackend AS lbb on lbb.portb = Port.id
\tLEFT JOIN Port AS pb ON pb.id = lbb.porta
\tLEFT JOIN Object AS ob ON pb.object_id = ob.id
\tLEFT JOIN PortLog ON PortLog.id = (SELECT id FROM PortLog WHERE PortLog.port_id = Port.id ORDER BY date DESC LIMIT 1)
WHERE
\t{$sql_where_clause}
END;
    $result = usePreparedSelectBlade($query, $query_params);
    $ret = array();
    while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
        $row['l2address'] = l2addressFromDatabase($row['l2address']);
        $row['linked'] = isset($row['remote_id']) ? 1 : 0;
        // last changed log
        $row['last_log'] = array();
        if ($row['log_count']) {
            $row['last_log']['user'] = $row['user'];
            $row['last_log']['time'] = $row['time'];
        }
        unset($row['user']);
        unset($row['time']);
        $ret[] = $row;
    }
    return $ret;
}
开发者ID:epx998,项目名称:racktables-contribs,代码行数:53,代码来源:local_copy_object.php


示例6: getTripletsByIP

 public static function getTripletsByIP($ip_bin)
 {
     $ret = array();
     $result = usePreparedSelectBlade("\nSELECT DISTINCT IPv4LB.*\nFROM\n\tIPv4LB INNER JOIN IPv4VS ON IPv4VS.id = IPv4LB.vs_id\n\tLEFT JOIN IPv4RS USING (rspool_id)\nWHERE\n\trsip = ? OR vip = ?\nORDER BY\n\tvs_id\n\t", array($ip_bin, $ip_bin));
     $rows = $result->fetchAll(PDO::FETCH_ASSOC);
     unset($result);
     global $triplet_class;
     foreach ($rows as $row) {
         $triplet = new $triplet_class($row['object_id'], $row['vs_id'], $row['rspool_id'], $row);
         $triplet->display_cells = array('vs', 'lb', 'rs');
         $ret[] = $triplet;
     }
     return $ret;
 }
开发者ID:ivladdalvi,项目名称:racktables,代码行数:14,代码来源:slb.php


示例7: getEntityIdByName

function getEntityIdByName($element, $name)
{
    // set table name
    $id = -1;
    $table = "";
    switch ($element) {
        case "rack":
            $table = "Rack";
            break;
        case "object":
            $table = "Object";
            break;
        default:
            return $id;
    }
    $query = "SELECT id, name FROM {$table} WHERE name = '{$name}'";
    $result = usePreparedSelectBlade($query);
    foreach ($result as $key => $value) {
        $id = $value["id"];
        break;
    }
    return $id;
}
开发者ID:micromachine,项目名称:RackTables-ZABBIX-bridge,代码行数:23,代码来源:api.php


示例8: renderCablingPlan

function renderCablingPlan()
{
    // Build cabling plan
    // Select edges
    $sql = "SELECT oa.id AS source, ob.id AS target, CONCAT(pa.name, _utf8' <> ', pb.name) AS label, 0 AS weight " . "FROM ((Link l JOIN Port pa ON l.porta = pa.id) JOIN RackObject oa ON pa.object_id = oa.id " . "JOIN Port pb ON l.portb = pb.id JOIN RackObject ob ON pb.object_id = ob.id)";
    $result = usePreparedSelectBlade($sql);
    $edges = array();
    while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
        $found = FALSE;
        foreach ($edges as $key => $edge) {
            if ($edge['source'] == $row['source'] && $edge['target'] == $row['target']) {
                // Edge already exists ("Parallel"). Alter label and add weight
                $edges[$key]['label'] .= "\n" . $row['label'];
                $edges[$key]['weight']++;
                $found = TRUE;
            }
        }
        if (!$found) {
            $edges[] = $row;
        }
    }
    // Select nodes
    $sql = "SELECT DISTINCT o.id AS id, o.name AS label, '' AS url " . "FROM Port p JOIN RackObject o ON p.object_id = o.id " . "WHERE (p.id IN (SELECT Link.porta AS porta FROM Link) OR p.id IN " . "(SELECT Link.portb AS portb FROM Link))";
    $result = usePreparedSelectBlade($sql);
    $nodes = $result->fetchAll(PDO::FETCH_ASSOC);
    $graph = new Image_GraphViz(TRUE, array(), 'Cabling Plan', FALSE, FALSE);
    foreach ($nodes as $node) {
        $graph->addNode($node['id'], array('label' => $node['label'], 'shape' => 'box3d'));
    }
    foreach ($edges as $edge) {
        $graph->addEdge(array($edge['source'] => $edge['target']), array('label' => $edge['label'], 'weight' => floatval($edge['weight']), 'fontsize' => 8.0, 'arrowhead' => 'dot', 'arrowtail' => 'dot', 'arrowsize' => 0.5));
    }
    if (in_array($_REQUEST['format'], array('svg', 'png'))) {
        $graph->image($_REQUEST['format']);
    }
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:36,代码来源:cablingplan.php


示例9: fetchNetworkRowsByAttr

function fetchNetworkRowsByAttr($attribute_id, $attribute_value, $use_key = FALSE, $dont_filter = FALSE)
{
    global $netobject_type_id, $SQLSchema;
    // get attribute type
    static $map;
    if (!isset($map)) {
        $map = getAttrMap();
    }
    if (!array_key_exists($attribute_id, $map)) {
        throw new InvalidArgException('attribute_id', $attribute_id, "No such attribute");
    }
    $attribute = $map[$attribute_id];
    // get realms
    $realms = array();
    foreach ($attribute['application'] as $application) {
        foreach ($netobject_type_id as $realm => $type) {
            if ($application['objtype_id'] == $type) {
                $realms[] = $realm;
            }
        }
    }
    $join_side = $dont_filter && $attribute_value !== NULL ? 'INNER' : 'LEFT';
    $join = '';
    $field = '';
    switch ($attribute['type']) {
        case 'string':
            $field = 'AV.string_value';
            break;
        case 'uint':
            $field = 'AV.uint_value';
            break;
        case 'float':
            $field = 'AV.float_value';
            break;
        case 'date':
            $field = 'AV.uint_value';
            break;
        case 'dict':
            if ($use_key) {
                $field = 'AV.uint_value';
            } else {
                $join = 'LEFT JOIN Dictionary D ON D.dict_key = AV.uint_value';
                $field = 'D.dict_value';
            }
            break;
        default:
            throw new RackTablesError();
    }
    $subqueries = array();
    $params = array();
    foreach (array('ipv4net' => 'AttributeValue_IPv4', 'ipv6net' => 'AttributeValue_IPv6') as $realm => $table) {
        if (in_array($realm, $realms)) {
            $main_table = $SQLSchema[$realm]['table'];
            $subquery = "\nSELECT\n MT.id as net_id,\n MT.ip,\n MT.mask,\n ? as realm,\n {$field} as attr_value\nFROM\n `{$main_table}` MT\n {$join_side} JOIN `{$table}` AV ON MT.id = AV.net_id AND AV.attr_id = ?\n {$join}\n";
            $params[] = $realm;
            $params[] = $attribute_id;
            if (!$dont_filter) {
                if (isset($attribute_value)) {
                    $subquery .= " WHERE {$field} = ?";
                    $params[] = $attribute_value;
                } else {
                    $subquery .= " WHERE {$field} IS NULL";
                }
            }
            $subqueries[] = $subquery;
        }
    }
    $query = implode(' UNION ', $subqueries);
    $result = usePreparedSelectBlade($query, $params);
    return $result->fetchAll(PDO::FETCH_ASSOC);
}
开发者ID:epx998,项目名称:racktables-contribs,代码行数:71,代码来源:network-attrs.php


示例10: findObjectParentCandidates

function findObjectParentCandidates($object_id)
{
    $object = spotEntity('object', $object_id);
    $args = array($object['objtype_id'], $object_id, $object_id);
    $query = "SELECT O.id, O.name, O.objtype_id FROM Object O ";
    $query .= "LEFT JOIN ObjectParentCompat OPC ON O.objtype_id = OPC.parent_objtype_id ";
    $query .= "WHERE OPC.child_objtype_id = ? ";
    $query .= "AND O.id != ? ";
    // exclude existing parents
    $query .= "AND O.id NOT IN (SELECT parent_entity_id FROM EntityLink WHERE parent_entity_type = 'object' AND child_entity_type = 'object' AND child_entity_id = ?) ";
    if ($object['objtype_id'] == 1504 || $object['objtype_id'] == 1507) {
        array_push($args, $object['objtype_id'], $object_id, $object_id);
        $query .= "AND OPC.parent_objtype_id != 4 ";
        $query .= "UNION ";
        $query .= "SELECT O.id, O.name, O.objtype_id FROM Object O  ";
        $query .= "LEFT JOIN ObjectParentCompat OPC ON O.objtype_id = OPC.parent_objtype_id ";
        $query .= "LEFT JOIN AttributeValue AV ON O.id = AV.object_id ";
        $query .= "WHERE OPC.child_objtype_id = ? ";
        $query .= "AND (O.objtype_id = 4 AND AV.attr_id = 26 AND AV.uint_value = 1501) ";
        $query .= "AND O.id != ? ";
        // exclude existing parents
        $query .= "AND O.id NOT IN (SELECT parent_entity_id FROM EntityLink WHERE parent_entity_type = 'object' AND child_entity_type = 'object' AND child_entity_id = ?) ";
    }
    $query .= "ORDER BY 2";
    $result = usePreparedSelectBlade($query, $args);
    $ret = array();
    while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
        $ret[$row['id']] = empty($row['name']) ? sprintf("[%s] - object %d", decodeObjectType($row['objtype_id']), $row['id']) : $row['name'];
    }
    return $ret;
}
开发者ID:spartak-radchenko,项目名称:racktables,代码行数:31,代码来源:popup.php


示例11: renderDataIntegrityReport

function renderDataIntegrityReport()
{
    global $nextorder;
    $violations = FALSE;
    // check 1: EntityLink rows referencing not-existent relatives
    // check 1.1: children
    $realms = array('location' => 'Location', 'object' => 'RackObject', 'rack' => 'Rack', 'row' => 'Row');
    $orphans = array();
    foreach ($realms as $realm => $table) {
        $result = usePreparedSelectBlade('SELECT EL.* FROM EntityLink EL ' . "LEFT JOIN {$table} ON EL.child_entity_id = {$table}.id " . "WHERE EL.child_entity_type = ? AND {$table}.id IS NULL", array($realm));
        $rows = $result->fetchAll(PDO::FETCH_ASSOC);
        unset($result);
        $orphans = array_merge($orphans, $rows);
    }
    if (count($orphans)) {
        $violations = TRUE;
        startPortlet('EntityLink: Missing Children (' . count($orphans) . ')');
        echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n";
        echo "<tr><th>Parent</th><th>Child Type</th><th>Child ID</th></tr>\n";
        $order = 'odd';
        foreach ($orphans as $orphan) {
            $realm_name = formatRealmName($orphan['parent_entity_type']);
            $parent = spotEntity($orphan['parent_entity_type'], $orphan['parent_entity_id']);
            echo "<tr class=row_{$order}>";
            echo "<td>{$realm_name}: {$parent['name']}</td>";
            echo "<td>{$orphan['child_entity_type']}</td>";
            echo "<td>{$orphan['child_entity_id']}</td>";
            echo "</tr>\n";
            $order = $nextorder[$order];
        }
        echo "</table>\n";
        finishPortLet();
    }
    // check 1.2: parents
    $orphans = array();
    foreach ($realms as $realm => $table) {
        $result = usePreparedSelectBlade('SELECT EL.* FROM EntityLink EL ' . "LEFT JOIN {$table} ON EL.parent_entity_id = {$table}.id " . "WHERE EL.parent_entity_type = ? AND {$table}.id IS NULL", array($realm));
        $rows = $result->fetchAll(PDO::FETCH_ASSOC);
        unset($result);
        $orphans = array_merge($orphans, $rows);
    }
    if (count($orphans)) {
        $violations = TRUE;
        startPortlet('EntityLink: Missing Parents (' . count($orphans) . ')');
        echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n";
        echo "<tr><th>Child</th><th>Parent Type</th><th>Parent ID</th></tr>\n";
        $order = 'odd';
        foreach ($orphans as $orphan) {
            $realm_name = formatRealmName($orphan['child_entity_type']);
            $child = spotEntity($orphan['child_entity_type'], $orphan['child_entity_id']);
            echo "<tr class=row_{$order}>";
            echo "<td>{$realm_name}: {$child['name']}</td>";
            echo "<td>{$orphan['parent_entity_type']}</td>";
            echo "<td>{$orphan['parent_entity_id']}</td>";
            echo "</tr>\n";
            $order = $nextorder[$order];
        }
        echo "</table>\n";
        finishPortLet();
    }
    // check 3: multiple tables referencing non-existent dictionary entries
    // check 3.1: AttributeMap
    $orphans = array();
    $result = usePreparedSelectBlade('SELECT AM.*, A.name AS attr_name, C.name AS chapter_name ' . 'FROM AttributeMap AM ' . 'LEFT JOIN Attribute A ON AM.attr_id = A.id ' . 'LEFT JOIN Chapter C ON AM.chapter_id = C.id ' . 'LEFT JOIN Dictionary D ON AM.objtype_id = D.dict_key ' . 'WHERE D.dict_key IS NULL');
    $orphans = $result->fetchAll(PDO::FETCH_ASSOC);
    unset($result);
    if (count($orphans)) {
        $violations = TRUE;
        startPortlet('AttributeMap: Invalid Mappings (' . count($orphans) . ')');
        echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n";
        echo "<tr><th>Attribute</th><th>Chapter</th><th>Object TypeID</th></tr>\n";
        $order = 'odd';
        foreach ($orphans as $orphan) {
            echo "<tr class=row_{$order}>";
            echo "<td>{$orphan['attr_name']}</td>";
            echo "<td>{$orphan['chapter_name']}</td>";
            echo "<td>{$orphan['objtype_id']}</td>";
            echo "</tr>\n";
            $order = $nextorder[$order];
        }
        echo "</table>\n";
        finishPortLet();
    }
    // check 3.2: Object
    $orphans = array();
    $result = usePreparedSelectBlade('SELECT O.* FROM Object O ' . 'LEFT JOIN Dictionary D ON O.objtype_id = D.dict_key ' . 'WHERE D.dict_key IS NULL');
    $orphans = $result->fetchAll(PDO::FETCH_ASSOC);
    unset($result);
    if (count($orphans)) {
        $violations = TRUE;
        startPortlet('Object: Invalid Types (' . count($orphans) . ')');
        echo "<table cellpadding=5 cellspacing=0 align=center class=cooltable>\n";
        echo "<tr><th>ID</th><th>Name</th><th>Type ID</th></tr>\n";
        $order = 'odd';
        foreach ($orphans as $orphan) {
            echo "<tr class=row_{$order}>";
            echo "<td>{$orphan['id']}</td>";
            echo "<td>{$orphan['name']}</td>";
            echo "<td>{$orphan['objtype_id']}</td>";
            echo "</tr>\n";
//.........这里部分代码省略.........
开发者ID:xtha,项目名称:salt,代码行数:101,代码来源:interface.php


示例12: determine_PortLinker

function determine_PortLinker()
{
    global $localSplit, $remoteSplit, $portLinkerObjectTypes;
    $errorText = "";
    assertUIntArg('object_id', __FUNCTION__);
    $object = spotEntity('object', $_REQUEST['object_id']);
    $linkok = localpretrigger_PortLinker();
    if ($linkok == 2) {
        if (in_array($object['objtype_id'], $portLinkerObjectTypes)) {
            $localPortCount = countPorts($object['id']);
            $remotePortCount = array();
            $remoteObject = array();
            $remoteSplit = array();
            $localSplit = determinePortSplit($object['label'], $localPortCount);
            $current = 1;
            foreach ($localSplit as $aKey => $aValue) {
                if (strlen($errorText) == 0) {
                    $q = "SELECT id FROM RackObject WHERE name='{$aKey}' ";
                    $result = usePreparedSelectBlade($q);
                    if ($result == NULL) {
                        print_r($dbxlink->errorInfo());
                        die;
                    }
                    if ($row = $result->fetch(PDO::FETCH_NUM)) {
                        $remotePortCount[$aKey] = countPorts($row[0]);
                        $remoteObject[$aKey] = spotEntity('object', $row[0]);
                        $remoteSplit[$aKey] = determinePortSplit($remoteObject[$aKey]['label'], $remotePortCount[$aKey]);
                    } else {
                        $errorText = "Could not find object <b>{$aKey}</b>";
                    }
                }
            }
            if (strlen($errorText) == 0) {
                foreach ($localSplit as $aKey => $aValue) {
                    if (strlen($errorText) == 0 && !isset($remoteSplit[$aKey][$object['name']]['count'])) {
                        $errorText = "Object <b>{$aKey}</b> does not list this object in the label field as a remote panel";
                    }
                    if (strlen($errorText) == 0 && $remoteSplit[$aKey][$object['name']]['count'] != $aValue['count']) {
                        $errorText = "Port count does not match for object <b>{$aKey}</b>";
                    }
                }
                if (strlen($errorText) == 0) {
                    foreach ($localSplit as $aKey => $aValue) {
                        if (strlen($errorText) == 0) {
                            $localSplit[$aKey]['ports'] = getPorts($object['id'], $aValue['count'], $aValue['start']);
                            if (count($localSplit[$aKey]['ports']) != $aValue['count']) {
                                $errorText = "Not all ports available on this object";
                            }
                        }
                        if (strlen($errorText) == 0) {
                            $localSplit[$aKey]['remote_ports'] = getPorts($remoteObject[$aKey]['id'], $remoteSplit[$aKey][$object['name']]['count'], $remoteSplit[$aKey][$object['name']]['start']);
                            if (count($localSplit[$aKey]['ports']) != $remoteSplit[$aKey][$object['name']]['count']) {
                                $errorText = "Not all ports available on this object";
                            }
                        }
                    }
                }
            }
        } else {
            $errorText = "Object type should be PatchPanel or ODFPanel";
        }
    } else {
        switch ($linkok) {
            case "-1":
                $errorText = "There are no ports configured yet, so nothing to link to.";
                break;
            case "0":
                $errorText = "Some link ports are already linked to another port.";
                break;
            case "1":
                $errorText = "No ports found that end in link.";
                break;
            default:
                $errorText = "Unknown error.";
        }
    }
    return $errorText;
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:78,代码来源:local_portlinker.php


示例13: renderObjectHistory

function renderObjectHistory($object_id)
{
    $order = 'odd';
    global $nextorder;
    echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
    echo '<tr><th>change time</th><th>author</th><th>name</th><th>visible label</th><th>asset no</th><th>has problems?</th><th>comment</th></tr>';
    $result = usePreparedSelectBlade('SELECT ctime, user_name, name, label, asset_no, has_problems, comment FROM ObjectHistory WHERE id=? ORDER BY ctime', array($object_id));
    while ($row = $result->fetch(PDO::FETCH_NUM)) {
        echo "<tr class=row_{$order}><td>{$row[0]}</td>";
        for ($i = 1; $i <= 6; $i++) {
            echo "<td>" . $row[$i] . "</td>";
        }
        echo "</tr>\n";
        $order = $nextorder[$order];
    }
    echo "</table><br>\n";
}
开发者ID:rhysm,项目名称:racktables,代码行数:17,代码来源:interface.php


示例14: updateconfig_PortGenerator

function updateconfig_PortGenerator()
{
    global $tablePortGenerator;
    checkForTable();
    $q = "SELECT autoportconfig FROM {$tablePortGenerator} WHERE dict_key={$_REQUEST['yId']} ";
    $result = usePreparedSelectBlade($q);
    if ($result == NULL) {
        print_r($dbxlink->errorInfo());
        die;
    }
    if ($row = $result->fetch(PDO::FETCH_NUM)) {
        $q = "UPDATE {$tablePortGenerator} SET autoportconfig='{$_REQUEST['yConfig']}' WHERE dict_key={$_REQUEST['yId']} ";
    } else {
        $q = "INSERT INTO {$tablePortGenerator} (dict_key,autoportconfig) VALUES ({$_REQUEST['yId']},'{$_REQUEST['yConfig']}') ";
    }
    $result = usePreparedSelectBlade($q);
    if ($result == NULL) {
        print_r($dbxlink->errorInfo());
        die;
    }
    if (true) {
        return setMessage('success', $message = "Successfully updated auto port configuration");
    } else {
        print "false";
        return setMessage('error', $message = "Error in update to auto port configuration");
    }
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:27,代码来源:local_portgenerator.php


示例15: ConfigTabHandler

function ConfigTabHandler()
{
    $dateadd = date("Y-m-d H:i:s");
    // Add show/hide JS functionality for existing configuration fields
    echo "<SCRIPT language=\"JavaScript\">\n\t<!--\n\tfunction toggle_visibility(id){\n\tvar e = document.getElementById(id);\n\tif(e.style.display == 'block')\n\t\te.style.display = 'none';\n\telse\n\t\te.style.display = 'block';\n\t}\n\t//-->\n\t</script>\n";
    // Print markup content for config tab
    $display = "<center>\n";
    if (isset($_POST['op'])) {
        if ($_POST['op'] == "addConfig") {
            commitNewConfig($_POST['object_id'], $_POST['config'], $_POST['comments'], $_POST['dateadd']);
        }
        if ($_POST['op'] == "editConfig") {
            commitUpdateConfig($_POST['conf_id'], $_POST['config'], $_POST['comments'], $_POST['dateadd']);
        }
    }
    if (isset($_GET['op'])) {
        if ($_GET['op'] == "delConfig") {
            commitDeleteConfig($_GET['conf_id']);
        }
    }
    // Table header
    $display .= "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>";
    $display .= "<tr><th>&nbsp;</th>";
    $display .= "<th class=tdleft></br>Saved Configurations</th>";
    //$display .= "<th class=tdleft>Comment</th>";
    $display .= "<th>&nbsp;</th></tr>";
    assertUIntArg('object_id', __FUNCTION__);
    $object = spotEntity('object', $_REQUEST['object_id']);
    // Existing configs
    $query = "SELECT * FROM ObjectConfigs WHERE object_id = '{$object['id']}'";
    $result = NULL;
    $result = usePreparedSelectBlade($query);
    while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
        $conf_id = $row['id'];
        $object_id = $row['object_id'];
        $config = $row['config'];
        $comments = $row['comments'];
        $date = $row['date'];
        $display .= "<form method=post id=editConfig name=editConfig autocomplete=off action=\"\">";
        $display .= "<input type=hidden name=\"conf_id\" value=\"" . $conf_id . "\">";
        $display .= "<input type=hidden name=\"date\" value=\"" . $date . "\">";
        $display .= "<input type=hidden name=\"op\" value=\"editConfig\">";
        $display .= "<input type=hidden name=\"object_id\" value=\"" . $object_id . "\">";
        $display .= "<tr><td><a href='?page=object&tab=configs&object_id=" . $object_id . "&op=delConfig&conf_id=" . $conf_id . "'onclick=\"javascript:return confirm('Are you sure you want to delete this Config?')\">";
        $display .= "<img src='?module=chrome&uri=pix/tango-list-remove.png' width=16 height=16 border=0 title='Delete this Config'></a></td>";
        $display .= "<td><a href=# onclick=toggle_visibility('{$conf_id}');>{$date} &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp Comments:&nbsp&nbsp{$comments}</a>";
        $display .= "</br><div id={$conf_id} style=display:none;><textarea style=background-color:#CCCCCC form=editConfig name=\"config\" cols=125 rows=15>" . $config . "</textarea></div></td><td></td>";
        //$display .= "<td class='tdleft' NOWRAP><textarea name=comment value='".$comments."' cols=25 maxlength=254></textarea></td>";
        $display .= "<td><input type=image name=submit class=icon src='?module=chrome&uri=pix/tango-document-save-16x16.png' border=0 title='Save' onclick=\"javascript:return confirm('Are you sure you want to overwrite this Config?')\"></td></form></tr>";
    }
    // New config
    $display .= "<form action=\"\" method=post autocomplete=off id=\"addConfig\" name=\"addConfig\">";
    $display .= "<input type=hidden name=\"object_id\" value=\"" . $object['id'] . "\">";
    $display .= "<input type=hidden name=\"dateadd\" value=\"" . $dateadd . "\">";
    $display .= "<input type=hidden name=\"op\" value=\"addConfig\">";
    $display .= "<tr><td><input type=image name=submit class=icon src='?module=chrome&uri=pix/tango-list-add.png' border=0  title='Add a Config'></td>";
    $display .= "<td class='tdleft'></br></br><p style=font-weight:bold;> Add New Configurations</p>Comment: <input cols=40 name=comments tabindex=102></br><textarea cols=125 rows=20 name=config tabindex=100 required></textarea></br></td></tr>";
    $display .= "</form></br></table></br></center>";
    // Output all .display strings to markup
    echo $display;
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:61,代码来源:configs.php


示例16: updateTripletConfig

function updateTripletConfig()
{
    $key_fields = array('object_id' => assertUIntArg('object_id'), 'vs_id' => assertUIntArg('vs_id'), 'rspool_id' => assertUIntArg('rspool_id'));
    $config_fields = array('vsconfig' => nullEmptyStr(assertStringArg('vsconfig', TRUE)), 'rsconfig' => nullEmptyStr(assertStringArg('rsconfig', TRUE)));
    $vsinfo = spotEntity('ipvs', $key_fields['vs_id']);
    amplifyCell($vsinfo);
    $found = FALSE;
    if ($_REQUEST['op'] == 'updPort') {
        $table = 'VSEnabledPorts';
        $proto = assertStringArg('proto');
        $vport = assertUIntArg('port', TRUE);
        $key_fields['proto'] = $proto;
        $key_fields['vport'] = $vport;
        $key = "Port {$proto}-{$vport}";
        // check if such port exists in VS
        foreach ($vsinfo['ports'] as $vs_port) {
            if ($vs_port['proto'] == $proto && $vs_port['vport'] == $vport) {
                $found = TRUE;
                break;
            }
        }
    } else {
        $table = 'VSEnabledIPs';
        $vip = assertIPArg('vip');
        $config_fields['prio'] = nullEmptyStr(assertStringArg('prio', TRUE));
        $key_fields['vip'] = $vip;
        $key = "IP " . ip_format($vip);
        // check if such VIP exists in VS
        foreach ($vsinfo['vips'] as $vs_vip) {
            if ($vs_vip['vip'] === $vip) {
                $found = TRUE;
                break;
            }
        }
    }
    if (!$found) {
        showError("{$key} not found in VS");
        return;
    }
    $nchanged = 0;
    if (!isCheckSet('enabled')) {
        if ($nchanged += usePreparedDeleteBlade($table, $key_fields)) {
            showSuccess("{$key} disabled");
            return;
        }
    } else {
        global $dbxlink;
        $dbxlink->beginTransaction();
        $q = "SELECT * FROM {$table} WHERE";
        $sep = '';
        $params = array();
        foreach ($key_fields as $field => $value) {
            $q .= " {$sep} {$field} = ?";
            $params[] = $value;
            $sep = 'AND';
        }
        $result = usePreparedSelectBlade("{$q} FOR UPDATE", $params);
        $row = $result->fetch(PDO::FETCH_ASSOC);
        unset($result);
        if ($row) {
            if ($nchanged += usePreparedUpdateBlade($table, $config_fields, $key_fields)) {
                showSuccess("{$key} config updated");
            }
        } else {
            if ($nchanged += $table == 'VSEnabledIPs' ? addSLBIPLink($key_fields + $config_fields) : addSLBPortLink($key_fields + $config_fields)) {
                showSuccess("{$key} enabled");
            }
        }
        $dbxlink->commit();
    }
    if (!$nchanged) {
        showNotice("No changes made");
    }
}
开发者ID:xtha,项目名称:salt,代码行数:74,代码来源:ophandlers.php


示例17: scanAttrRelativeDays

function scanAttrRelativeDays($attr_id, $not_before_days, $not_after_days)
{
    $attrmap = getAttrMap();
    if ($attrmap[$attr_id]['type'] != 'date') {
        throw new InvalidArgException('attr_id', $attr_id, 'attribute cannot store dates');
    }
    $result = usePreparedSelectBlade('SELECT uint_value, object_id FROM AttributeValue ' . 'WHERE attr_id=? and FROM_UNIXTIME(uint_value) BETWEEN ' . 'DATE_ADD(curdate(), INTERVAL ? DAY) and DATE_ADD(curdate(), INTERVAL ? DAY)', array($attr_id, $not_before_days, $not_after_days));
    return $result->fetchAll(PDO::FETCH_ASSOC);
}
开发者ID:rhysm,项目名称:racktables,代码行数:9,代码来源:database.php


示例18: getPortOIOptions

function getPortOIOptions()
{
    $result = usePreparedSelectBlade('SELECT dict_key,dict_value from Dictionary where chapter_id = 2', array());
    $row = $result->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_UNIQUE | PDO::FETCH_COLUMN);
    return $row;
}
开发者ID:xtha,项目名称:salt,代码行数:6,代码来源:snmpgeneric.php


示例19: getUnlinkedNodePingChecks

function getUnlinkedNodePingChecks($object_id)
{
    $result = usePreparedSelectBlade('SELECT id, label, target, type ' . 'FROM NodePingCheck ' . 'WHERE id NOT IN (SELECT check_id FROM NodePingLink WHERE object_id = ?) ' . 'ORDER BY label, target, type', array($object_id));
    return reindexById($result->fetchAll(PDO::FETCH_ASSOC));
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:5,代码来源:nodeping.php


示例20: updateObjectAllocation


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP useThisRule函数代码示例发布时间:2022-05-23
下一篇:
PHP useHeading函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap