当前位置: 首页>>代码示例>>PHP>>正文


PHP assertStringArg函数代码示例

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


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

示例1: importRipeData

function importRipeData()
{
    $ripe_db = "http://rest.db.ripe.net/search.xml?source=ripe&query-string=";
    // Prepare update
    assertStringArg('ripe_query');
    assertUIntArg('net_id');
    assertStringArg('net_name');
    //$nbad = $ngood = 0;
    $net_id = $_REQUEST['net_id'];
    $ripe_query = htmlspecialchars_decode($_REQUEST['ripe_query']);
    $ripe_result_str = file_get_contents($ripe_query, false, NULL);
    $ripe_result = simplexml_load_string($ripe_result_str);
    $filedir = realpath(dirname(__FILE__));
    $ripe_xsl = simplexml_load_file($filedir . '/ripe_text.xsl');
    $proc = new XSLTProcessor();
    $proc->importStyleSheet($ripe_xsl);
    $newName = htmlspecialchars_decode($_REQUEST['net_name']);
    $newComment = trim($proc->transformToXML($ripe_result));
    // Update
    usePreparedUpdateBlade('IPv4Network', array('name' => $newName, 'comment' => $newComment), array('id' => $net_id), 'AND');
    //		$retcode = 51;
    //    if (!$nbad)
    //		return showFuncMessage (__FUNCTION__, 'OK', array ($ngood));
    //	else
    //		return showFuncMessage (__FUNCTION__, 'ERR', array ($nbad, $ngood));
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:26,代码来源:ripe.php

示例2: handleOneShotRequest

function handleOneShotRequest()
{
    assertStringArg('realm');
    assertStringArg('q');
    switch ($_REQUEST['realm']) {
        case 'object':
            if (NULL === ($id = lookupEntityByString($_REQUEST['realm'], $_REQUEST['q']))) {
                echo "<h2>Nothing found for '{$_REQUEST['q']}'</h2>";
            } else {
                echo "<script language='Javascript'>document.location='index.php?page=object&object_id={$id}';//</script>";
            }
            break;
        default:
            dragon();
            break;
    }
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:17,代码来源:oneshot.php

示例3: addObjectlog

function addObjectlog()
{
    assertStringArg('logentry');
    global $remote_username, $sic;
    if (isset($sic['object_id'])) {
        $object_id = $sic['object_id'];
    } elseif (isset($sic['location_id'])) {
        $object_id = $sic['location_id'];
    } else {
        $object_id = $sic['rack_id'];
    }
    usePreparedExecuteBlade('INSERT INTO ObjectLog SET object_id=?, user=?, date=NOW(), content=?', array($object_id, $remote_username, $sic['logentry']));
    showSuccess('Log entry added');
}
开发者ID:xtha,项目名称:salt,代码行数:14,代码来源:ophandlers.php

示例4: renderSLBFormAJAX

function renderSLBFormAJAX()
{
    global $pageno, $tabno;
    parse_str(assertStringArg('form'), $orig_request);
    parse_str(ltrim(assertStringArg('action'), '?'), $action);
    $pageno = $action['page'];
    $tabno = $action['tab'];
    printOpFormIntro($action['op'], $orig_request);
    $realm_list = array_diff(array('ipvs', 'object', 'ipv4rspool'), array($pageno));
    echo '<table align=center><tr class="tdleft">';
    foreach ($realm_list as $realm) {
        switch ($realm) {
            case 'object':
                $slb_cell = spotEntity('object', $orig_request['object_id']);
                break;
            case 'ipv4rspool':
                $slb_cell = spotEntity('ipv4rspool', $orig_request['rspool_id']);
                break;
            case 'ipvs':
                $slb_cell = spotEntity('ipvs', $orig_request['vs_id']);
                break;
        }
        echo '<td>';
        renderSLBEntityCell($slb_cell);
        echo '</td>';
    }
    $vsinfo = spotEntity('ipvs', $orig_request['vs_id']);
    amplifyCell($vsinfo);
    echo '<td><ul style="list-style: none">';
    foreach ($vsinfo['ports'] as $port) {
        $key = $port['proto'] . '-' . $port['vport'];
        echo '<li><label><input type=checkbox name="enabled_ports[]" value="' . htmlspecialchars($key, ENT_QUOTES) . '" checked>' . formatVSPort($port) . '</label></li>';
    }
    echo '</ul></td>';
    echo '<td><ul style="list-style: none">';
    foreach ($vsinfo['vips'] as $vip) {
        $key = ip_format($vip['vip']);
        echo '<li><label><input type=checkbox name="enabled_vips[]" value="' . htmlspecialchars($key, ENT_QUOTES) . '" checked>' . $key . '</label></li>';
    }
    echo '</ul></td>';
    echo '<td>';
    printImageHREF('ADD', 'Configure LB', TRUE);
    echo '</td>';
    echo '</tr></table>';
    echo '</form>';
}
开发者ID:spartak-radchenko,项目名称:racktables,代码行数:46,代码来源:slb2-interface.php

示例5: importFingData

function importFingData()
{
    $net = spotEntity('ipv4net', getBypassValue());
    assertUIntArg('addrcount');
    $nbad = $ngood = 0;
    for ($i = 1; $i <= $_REQUEST['addrcount']; $i++) {
        $inputname = "import_{$i}";
        if (!isCheckSet($inputname)) {
            continue;
        }
        $ip_bin = assertIPv4Arg("addr_{$i}");
        assertStringArg("descr_{$i}", TRUE);
        assertStringArg("rsvd_{$i}");
        // Non-existent addresses will not have this argument set in request.
        $rsvd = 'no';
        if ($_REQUEST["rsvd_{$i}"] == 'yes') {
            $rsvd = 'yes';
        }
        try {
            if (!ip_in_range($ip_bin, $net)) {
                throw new InvalidArgException('ip_bin', $ip_bin);
            }
            updateAddress($ip_bin, $_REQUEST["descr_{$i}"], $rsvd);
            $ngood++;
        } catch (RackTablesError $e) {
            $nbad++;
        }
    }
    if (!$nbad) {
        showFuncMessage(__FUNCTION__, 'OK', array($ngood));
    } else {
        showFuncMessage(__FUNCTION__, 'ERR', array($nbad, $ngood));
    }
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:34,代码来源:fingtab.php

示例6: updateVLANDomain

function updateVLANDomain()
{
    $domain_id = assertUIntArg('vdom_id');
    $group_id = assertUIntArg('group_id', TRUE);
    $description = assertStringArg('vdom_descr');
    if (!$group_id) {
        $group_id = NULL;
    } else {
        $dominfo = getVLANDomain($domain_id);
        $parent_dominfo = getVLANDomain($group_id);
        if ($group_id == $domain_id) {
            throw new InvalidRequestArgException('group_id', $group_id, "domains should not be the same");
        }
        if ($parent_dominfo['group_id'] || $dominfo['subdomc']) {
            throw new InvalidRequestArgException('group_id', $group_id, "Multi-level domain groups are not allowed");
        }
    }
    usePreparedUpdateBlade('VLANDomain', array('group_id' => $group_id, 'description' => $description), array('id' => $domain_id));
    showSuccess("VLAN domain updated successfully");
}
开发者ID:spartak-radchenko,项目名称:racktables,代码行数:20,代码来源:ophandlers.php

示例7: handlePopupPortLink

function handlePopupPortLink()
{
    assertPermission('depot', 'default');
    assertUIntArg('port');
    assertUIntArg('remote_port');
    assertStringArg('cable', TRUE);
    $port_info = getPortInfo($_REQUEST['port']);
    $remote_port_info = getPortInfo($_REQUEST['remote_port']);
    $POIFC = getPortOIFCompat();
    if (isset($_REQUEST['port_type']) and isset($_REQUEST['remote_port_type'])) {
        $type_local = $_REQUEST['port_type'];
        $type_remote = $_REQUEST['remote_port_type'];
    } else {
        $type_local = $port_info['oif_id'];
        $type_remote = $remote_port_info['oif_id'];
    }
    $matches = FALSE;
    $js_table = '';
    foreach ($POIFC as $pair) {
        if ($pair['type1'] == $type_local && $pair['type2'] == $type_remote) {
            $matches = TRUE;
            break;
        } else {
            $js_table .= "POIFC['{$pair['type1']}-{$pair['type2']}'] = 1;\n";
        }
    }
    if ($matches) {
        if ($port_info['oif_id'] != $type_local) {
            commitUpdatePortOIF($port_info['id'], $type_local);
        }
        if ($remote_port_info['oif_id'] != $type_remote) {
            commitUpdatePortOIF($remote_port_info['id'], $type_remote);
        }
        linkPorts($port_info['id'], $remote_port_info['id'], $_REQUEST['cable']);
        // patch cable?
        if (array_key_exists('heap_id', $_REQUEST)) {
            // Leave the compatibility constraints check up to the foreign keys.
            if (0 != ($heap_id = genericAssertion('heap_id', 'uint0'))) {
                $heaps = getPatchCableHeapSummary();
                if (commitModifyPatchCableAmount($heap_id, -1)) {
                    showSuccess('consumed a patch cable from ' . formatPatchCableHeapAsPlainText($heaps[$heap_id]));
                } else {
                    showError('failed to consume a patch cable');
                }
            }
        }
        showOneLiner(8, array(formatPortLink($port_info['object_id'], NULL, $port_info['id'], $port_info['name']), formatPort($remote_port_info)));
        addJS(<<<END
window.opener.location.reload(true);
window.close();
END
, TRUE);
        backupLogMessages();
    } else {
        // JS code to display port compatibility hint
        addJS(<<<END
POIFC = {};
{$js_table}
\$(document).ready(function () {
\t\$('select.porttype').change(onPortTypeChange);\t
\tonPortTypeChange();
});
function onPortTypeChange() {
\tvar key = \$('*[name=port_type]')[0].value + '-' + \$('*[name=remote_port_type]')[0].value;
\tif (POIFC[key] == 1)
\t{
\t\t\$('#hint-not-compat').hide();
\t\t\$('#hint-compat').show();
\t}
\telse
\t{
\t\t\$('#hint-compat').hide();
\t\t\$('#hint-not-compat').show();
\t}
}
END
, TRUE);
        addCSS(<<<END
.compat-hint {
\tdisplay: none;
\tfont-size: 125%;
}
.compat-hint#hint-compat {
\tcolor: green;
}
.compat-hint#hint-not-compat {
\tcolor: #804040;
}
END
, TRUE);
        // render port type editor form
        echo '<form method=GET>';
        echo '<input type=hidden name="module" value="popup">';
        echo '<input type=hidden name="helper" value="portlist">';
        echo '<input type=hidden name="port" value="' . $port_info['id'] . '">';
        echo '<input type=hidden name="remote_port" value="' . $remote_port_info['id'] . '">';
        echo '<input type=hidden name="cable" value="' . htmlspecialchars($_REQUEST['cable'], ENT_QUOTES) . '">';
        echo '<p>The ports you have selected are not compatible. Please select a compatible transceiver pair.';
        echo '<p>';
        echo formatPort($port_info) . ' ';
//.........这里部分代码省略.........
开发者ID:spartak-radchenko,项目名称:racktables,代码行数:101,代码来源:popup.php

示例8: readChapter

     $words = readChapter($_REQUEST['chapter_no'], 'o');
     if (!in_array($_REQUEST['dict_value'], $words)) {
         throw new InvalidArgException('dict_value', $_REQUEST['dict_value'], "invalid argument: no such value in chapter ID " . $_REQUEST['chapter_no']);
     }
     usePreparedDeleteBlade('Dictionary', array('chapter_id' => $_REQUEST['chapter_no'], 'dict_value' => $_REQUEST['dict_value']));
     sendAPIResponse(array(), array('message' => 'dictionary entry deleted successfully', 'chapter_no' => $_REQUEST['chapter_no'], 'dict_value' => $_REQUEST['dict_value']));
     break;
     // perform a generic search
     //    UI equivalent: /index.php?page=search
     //    UI handler: searchEntitiesByText()
 // perform a generic search
 //    UI equivalent: /index.php?page=search
 //    UI handler: searchEntitiesByText()
 case 'search':
     require_once 'inc/init.php';
     assertStringArg('term', TRUE);
     sendAPIResponse(searchEntitiesByText($_REQUEST['term']));
     break;
     // <<DESCRIPTION>>
     //    UI equivalent: /index.php?page=
     //    UI handler: ()
     //case '':
     //        require_once 'inc/init.php';
     //        ...do stuff...
     //        sendAPIResponse();
     //        break;
 // <<DESCRIPTION>>
 //    UI equivalent: /index.php?page=
 //    UI handler: ()
 //case '':
 //        require_once 'inc/init.php';
开发者ID:xtha,项目名称:salt,代码行数:31,代码来源:api.php

示例9: genericAssertion

function genericAssertion($argname, $argtype)
{
    global $sic;
    switch ($argtype) {
        case 'string':
            assertStringArg($argname);
            break;
        case 'string0':
            assertStringArg($argname, TRUE);
            break;
        case 'uint':
            assertUIntArg($argname);
            break;
        case 'uint-uint':
            assertStringArg($argname);
            if (1 != preg_match('/^[1-9][0-9]*-[1-9][0-9]*$/', $_REQUEST[$argname])) {
                throw new InvalidRequestArgException($argname, $_REQUEST[$argname], 'illegal format');
            }
            break;
        case 'uint0':
            assertUIntArg($argname, TRUE);
            break;
        case 'inet':
            assertIPArg($argname);
            break;
        case 'inet4':
            assertIPv4Arg($argname);
            break;
        case 'inet6':
            assertIPv6Arg($argname);
            break;
        case 'l2address':
            assertStringArg($argname);
        case 'l2address0':
            assertStringArg($argname, TRUE);
            try {
                l2addressForDatabase($sic[$argname]);
            } catch (InvalidArgException $e) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'malformed MAC/WWN address');
            }
            break;
        case 'tag':
            assertStringArg($argname);
            if (!validTagName($sic[$argname])) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'Invalid tag name');
            }
            break;
        case 'pcre':
            assertPCREArg($argname);
            break;
        case 'json':
            assertStringArg($argname);
            if (NULL === json_decode($sic[$argname], TRUE)) {
                throw new InvalidRequestArgException($argname, '(omitted)', 'Invalid JSON code received from client');
            }
            break;
        case 'array':
            if (!array_key_exists($argname, $_REQUEST)) {
                throw new InvalidRequestArgException($argname, '(missing argument)');
            }
            if (!is_array($_REQUEST[$argname])) {
                throw new InvalidRequestArgException($argname, '(omitted)', 'argument is not an array');
            }
            break;
        case 'enum/attr_type':
            assertStringArg($argname);
            if (!in_array($sic[$argname], array('uint', 'float', 'string', 'dict', 'date'))) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'Unknown value');
            }
            break;
        case 'enum/vlan_type':
            assertStringArg($argname);
            // "Alien" type is not valid until the logic is fixed to implement it in full.
            if (!in_array($sic[$argname], array('ondemand', 'compulsory'))) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'Unknown value');
            }
            break;
        case 'enum/wdmstd':
            assertStringArg($argname);
            global $wdm_packs;
            if (!array_key_exists($sic[$argname], $wdm_packs)) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'Unknown value');
            }
            break;
        case 'enum/ipproto':
            assertStringArg($argname);
            global $vs_proto;
            if (!array_key_exists($sic[$argname], $vs_proto)) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'Unknown value');
            }
            break;
        case 'enum/alloc_type':
            assertStringArg($argname);
            if (!in_array($sic[$argname], array('regular', 'shared', 'virtual', 'router'))) {
                throw new InvalidRequestArgException($argname, $sic[$argname], 'Unknown value');
            }
            break;
        case 'enum/dqcode':
            assertStringArg($argname);
            global $dqtitle;
//.........这里部分代码省略.........
开发者ID:rhysm,项目名称:racktables,代码行数:101,代码来源:functions.php

示例10: makeGatewayParams

function makeGatewayParams($object_id, $tolerate_remote_errors, $ref_settings, $ref_commands)
{
    $ret = array();
    $settings =& $ref_settings[0];
    $commands =& $ref_commands[0];
    $prepend_credentials = FALSE;
    switch ($settings['protocol']) {
        case 'telnet':
            $prepend_credentials = TRUE;
            $params_from_settings['port'] = 'port';
            $params_from_settings['prompt'] = 'prompt';
            $params_from_settings['connect-timeout'] = 'connect_timeout';
            $params_from_settings['timeout'] = 'timeout';
            $params_from_settings['prompt-delay'] = 'prompt_delay';
            $params_from_settings[] = $settings['hostname'];
            break;
        case 'netcat':
            $prepend_credentials = TRUE;
            $params_from_settings['p'] = 'port';
            $params_from_settings['w'] = 'timeout';
            $params_from_settings['b'] = 'ncbin';
            $params_from_settings[] = $settings['hostname'];
            break;
        case 'sshnokey':
            $prepend_credentials = TRUE;
            $params_from_settings['proto'] = 'proto';
            $params_from_settings['prompt'] = 'prompt';
            $params_from_settings['prompt-delay'] = 'prompt_delay';
            $params_from_settings['username'] = 'username';
            $params_from_settings['password'] = 'password';
            $params_from_settings[] = $settings['hostname'];
            break;
        case 'ssh':
            $params_from_settings['sudo-user'] = 'sudo_user';
            $params_from_settings[] = '--';
            $params_from_settings['p'] = 'port';
            $params_from_settings['l'] = 'username';
            $params_from_settings['i'] = 'identity_file';
            if (isset($settings['proto'])) {
                switch ($settings['proto']) {
                    case 4:
                        $params_from_settings[] = '-4';
                        break;
                    case 6:
                        $params_from_settings[] = '-6';
                        break;
                    default:
                        throw new RTGatewayError("Proto '{$settings['proto']}' is invalid. Valid protocols are: '4', '6'");
                }
            }
            if (isset($settings['connect_timeout'])) {
                $params_from_settings[] = '-oConnectTimeout=' . $settings['connect_timeout'];
            }
            $params_from_settings[] = '-T';
            $params_from_settings[] = '-oStrictHostKeyChecking=no';
            $params_from_settings[] = '-oBatchMode=yes';
            $params_from_settings[] = '-oCheckHostIP=no';
            $params_from_settings[] = '-oLogLevel=ERROR';
            $params_from_settings[] = $settings['hostname'];
            break;
        case 'ucssdk':
            # remote XML through a Python backend
            # UCS in its current implementation besides the terminal_settings() provides
            # an additional username/password feed through the HTML from. Whenever the
            # user provides the credentials through the form, use these instead of the
            # credentials [supposedly] set by terminal_settings().
            global $script_mode;
            if ($script_mode != TRUE && !isCheckSet('use_terminal_settings')) {
                $settings['username'] = assertStringArg('ucs_login');
                $settings['password'] = assertStringArg('ucs_password');
            }
            foreach (array('hostname', 'username', 'password') as $item) {
                if (empty($settings[$item])) {
                    throw new RTGatewayError("{$item} not available, check terminal_settings()");
                }
            }
            $commands = "login {$settings['hostname']} {$settings['username']} {$settings['password']}\n" . $commands;
            break;
        default:
            throw new RTGatewayError("Invalid terminal protocol '{$settings['protocol']}' specified");
    }
    // prepend commands by credentials
    if ($prepend_credentials) {
        if (isset($settings['password'])) {
            $commands = $settings['password'] . "\n" . $commands;
        }
        if (isset($settings['username'])) {
            $commands = $settings['username'] . "\n" . $commands;
        }
    }
    foreach ($params_from_settings as $param_name => $setting_name) {
        if (is_int($param_name)) {
            $ret[] = $setting_name;
        } elseif (isset($settings[$setting_name])) {
            $ret[$param_name] = $settings[$setting_name];
        }
    }
    return $ret;
}
开发者ID:ivladdalvi,项目名称:racktables,代码行数:99,代码来源:remote.php

示例11: ob_clean

         ob_clean();
         showError('Database error: ' . $e->getMessage());
     } catch (RTPermissionDenied $e) {
         ob_clean();
         showError('Operation not permitted');
     }
     redirectUser($location);
     // any other error requires no special handling and will be caught outside
     break;
 case 'popup':
     require_once 'inc/popup.php';
     require_once 'inc/init.php';
     prepareNavigation();
     fixContext();
     assertPermission();
     $helper = assertStringArg('helper');
     header('Content-Type: text/html; charset=UTF-8');
     // call the main handler - page or tab handler.
     if (isset($popuphandler[$helper]) and is_callable($popuphandler[$helper])) {
         call_user_func($popuphandler[$helper], $helper);
     } else {
         throw new RackTablesError("Missing handler function for node '{$handler}'", RackTablesError::INTERNAL);
     }
     $contents = ob_get_contents();
     ob_clean();
     renderPopupHTML($contents);
     break;
 case 'upgrade':
     require_once 'inc/config.php';
     // for CODE_VERSION
     require_once 'inc/database.php';
开发者ID:spartak-radchenko,项目名称:racktables,代码行数:31,代码来源:index.php

示例12: handleNetworkAttrsChange

function handleNetworkAttrsChange()
{
    genericAssertion('num_attrs', 'uint0');
    global $dbxlink, $sic, $pageno;
    $network = spotEntity($pageno === 'ipv4net' ? 'ipv4net' : 'ipv6net', getBypassValue());
    $dbxlink->beginTransaction();
    // Update optional attributes
    $oldvalues = getAttrValuesForNetwork($network);
    for ($i = 0; $i < $_REQUEST['num_attrs']; $i++) {
        genericAssertion("{$i}_attr_id", 'uint');
        $attr_id = $_REQUEST["{$i}_attr_id"];
        if (!array_key_exists($attr_id, $oldvalues)) {
            throw new InvalidRequestArgException('attr_id', $attr_id, 'malformed request');
        }
        $value = $_REQUEST["{$i}_value"];
        if ('date' == $oldvalues[$attr_id]['type']) {
            assertDateArg("{$i}_value", TRUE);
            if ($value != '') {
                $value = strtotime($value);
            }
        }
        # Delete attribute and move on, when the field is empty or if the field
        # type is a dictionary and it is the "--NOT SET--" value of 0.
        if ($value == '' || $oldvalues[$attr_id]['type'] == 'dict' && $value == 0) {
            if (permitted(NULL, NULL, NULL, array(array('tag' => '$attr_' . $attr_id)))) {
                commitUpdateAttrForNetwork($network, $attr_id);
            } else {
                showError('Permission denied, "' . $oldvalues[$attr_id]['name'] . '" left unchanged');
            }
            continue;
        }
        // The value could be uint/float, but we don't know ATM. Let SQL
        // server check this and complain.
        assertStringArg("{$i}_value");
        switch ($oldvalues[$attr_id]['type']) {
            case 'uint':
            case 'float':
            case 'string':
            case 'date':
                $oldvalue = $oldvalues[$attr_id]['value'];
                break;
            case 'dict':
                $oldvalue = $oldvalues[$attr_id]['key'];
                break;
            default:
        }
        if ($value === $oldvalue) {
            // ('' == 0), but ('' !== 0)
            continue;
        }
        if (permitted(NULL, NULL, NULL, array(array('tag' => '$attr_' . $attr_id)))) {
            commitUpdateAttrForNetwork($network, $attr_id, $value);
        } else {
            showError('Permission denied, "' . $oldvalues[$attr_id]['name'] . '" left unchanged');
        }
    }
    $dbxlink->commit();
    return showSuccess("Attributes were updated successfully");
}
开发者ID:epx998,项目名称:racktables-contribs,代码行数:59,代码来源:network-attrs.php

示例13: deleteVlan

function deleteVlan()
{
    assertStringArg('vlan_ck');
    $confports = getVLANConfiguredPorts($_REQUEST['vlan_ck']);
    if (!empty($confports)) {
        throw new RackTablesError("You can not delete vlan which has assosiated ports");
    }
    list($vdom_id, $vlan_id) = decodeVLANCK($_REQUEST['vlan_ck']);
    usePreparedDeleteBlade('VLANDescription', array('domain_id' => $vdom_id, 'vlan_id' => $vlan_id));
    showSuccess("VLAN {$vlan_id} has been deleted");
    return buildRedirectURL('vlandomain', 'default', array('vdom_id' => $vdom_id));
}
开发者ID:rhysm,项目名称:racktables,代码行数:12,代码来源:ophandlers.php

示例14: copyLotOfObjects

function copyLotOfObjects()
{
    global $dbxlink;
    $dbrollback = 0;
    if (!$dbxlink->beginTransaction()) {
        throw new RTDatabaseError("can not start transaction");
    }
    // do we need this ?
    $log = emptyLog();
    $taglist = isset($_REQUEST['taglist']) ? $_REQUEST['taglist'] : array();
    assertUIntArg('global_type_id', TRUE);
    assertStringArg('namelist', TRUE);
    $global_type_id = $_REQUEST['global_type_id'];
    $source_object_id = $_REQUEST['object_id'];
    $source_object = spotEntity('object', $source_object_id);
    amplifyCell($source_object);
    // only call amplifyCell_object_Backend_Port if we have function linkmgmt_linkPorts from linkmgmt.php
    if (function_exists('amplifyCell_object_Backend_Port') && function_exists('linkmgmt_linkPorts')) {
        amplifyCell_object_Backend_Port($source_object);
    }
    if ($global_type_id == 0 or !strlen($_REQUEST['namelist'])) {
        // Log something reasonable with showError Here
        // We do not have names to copy our object to !
        // Pls check what makes $global_type_id == 0  an error
        $log = mergeLogs($log, oneLiner(186));
        return;
    }
    // The name extractor below was stolen from ophandlers.php:addMultiPorts()
    $names1 = explode("\n", $_REQUEST['namelist']);
    $names2 = array();
    foreach ($names1 as $line) {
        $parts = explode('\\r', $line);
        reset($parts);
        if (!strlen($parts[0])) {
            continue;
        } else {
            $names2[] = rtrim($parts[0]);
        }
    }
    foreach ($names2 as $name_or_csv) {
        $label = '';
        $asset_no = '';
        $object_name = '';
        $regexp = '/^\\"([^\\"]*)\\","([^\\"]*)\\","([^\\"]*)\\"/';
        $object_name_or_csv = htmlspecialchars_decode($name_or_csv, ENT_QUOTES);
        // error_log( "$regexp $object_name" );
        if (preg_match($regexp, $object_name_or_csv, $matches)) {
            $object_name = $matches[1];
            $label = $matches[2];
            $asset_no = $matches[3];
        } else {
            $object_name = $name_or_csv;
        }
        try {
            $object_id = commitAddObject($object_name, $label, $global_type_id, $asset_no, $taglist);
            if (!$object_id) {
                throw new RTDatabaseError("could not create {$object_name}");
            }
            $info = spotEntity('object', $object_id);
            amplifyCell($info);
            foreach ($source_object['ports'] as $source_port) {
                $update_port = 0;
                foreach ($info['ports'] as $new_port) {
                    if ($new_port['name'] == $source_port['name']) {
                        commitUpdatePort($object_id, $new_port['id'], $new_port['name'], $new_port['oif_id'], $source_port['label'], "");
                        $update_port = 1;
                    }
                }
                if ($update_port) {
                    true;
                } else {
                    commitAddPort($object_id, $source_port['name'], sprintf("%s-%s", $source_port['iif_id'], $source_port['oif_id']), $source_port['label'], "");
                }
            }
            // Copy Backendlinks only start if we ghave function linkmgmt_linkPorts from linkmgmt.php
            if (function_exists('amplifyCell_object_Backend_Port') && function_exists('linkmgmt_linkPorts')) {
                $info = spotEntity('object', $object_id);
                amplifyCell($info);
                amplifyCell_object_Backend_Port($info);
                /*	 showError( '<div align="left"><pre>\n===== Source Object ======\n\n' .
                				 		 varDumpToString ( $source_object ) .
                						'\n\n===== New Object ======\n\n' .
                						 varDumpToString ( $info )  .  '</pre></div>' );
                			*/
                $name_by_id = array();
                foreach ($info['BackendPorts'] as $new_be_port) {
                    $name_by_id[$new_be_port['name']] = $new_be_port['id'];
                }
                $linked_ports = array();
                foreach ($source_object['BackendPorts'] as $source_be_port) {
                    if ($source_be_port['object_id'] == $source_be_port['remote_object_id']) {
                        // We have a Port that has the own object as remote object we want to copy this type of Linko
                        // We have backend Links
                        $new_be_port_a = $name_by_id[$source_be_port['name']];
                        $new_be_port_b = $name_by_id[$source_be_port['remote_name']];
                        if ($new_be_port_a && $new_be_port_b && !array_key_exists($new_be_port_a, $linked_ports) && !array_key_exists($new_be_port_b, $linked_ports)) {
                            // error_log ( sprintf ('new_be_port_a %s // new_be_port_b %s // cableid %s', $new_be_port_a  , $new_be_port_b, $source_be_port['cableid'] ));
                            $ret_val = linkmgmt_linkPorts($new_be_port_a, $new_be_port_b, 'back', $source_be_port['cableid']);
                            // error_log ( sprintf (' linkmgmt_linkPorts ret val: "%s" ', $ret_val)) ;
                            if ($ret_val) {
//.........这里部分代码省略.........
开发者ID:epx998,项目名称:racktables-contribs,代码行数:101,代码来源:local_copy_object.php

示例15: updateNodePingCheck

function updateNodePingCheck()
{
    assertUIntArg('check_id');
    assertUIntArg('account_id');
    assertStringArg('np_check_id');
    $check = getNodePingCheck($_REQUEST['check_id']);
    $account = getNodePingAccount($_REQUEST['account_id']);
    $nodeping = new NodePingClient(array('token' => $account['token']));
    $np_check = $nodeping->check->get(array('id' => $_REQUEST['np_check_id'], 'limit' => 1, 'clean' => true));
    if (isset($check['error'])) {
        return showFuncMessage(__FUNCTION__, 'ERR1', array('Error: ' . $np_check['error']));
    }
    usePreparedUpdateBlade('NodePingCheck', array('account_id' => $_REQUEST['account_id'], 'np_check_id' => $_REQUEST['np_check_id'], 'label' => $np_check['label'], 'type' => $np_check['type'], 'target' => $np_check['parameters']['target'], 'check_interval' => $np_check['interval']), array('id' => $_REQUEST['check_id']));
    return showFuncMessage(__FUNCTION__, 'OK', array(htmlspecialchars($np_check['label'])));
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:15,代码来源:nodeping.php


注:本文中的assertStringArg函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。