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


PHP buildRedirectURL函数代码示例

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


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

示例1: dispatch

 public function dispatch()
 {
     global $debug_mode;
     if ($debug_mode) {
         printGenericException($this);
         return;
     }
     showError($this->message);
     redirectUser(buildRedirectURL('index', 'default'));
 }
开发者ID:ivladdalvi,项目名称:racktables,代码行数:10,代码来源:exceptions.php

示例2: testVcrAfterSave

 public function testVcrAfterSave()
 {
     $return_id = '1bb73165-dcd7-21b2-b648-4ded8dce0bf8';
     $_REQUEST['return_action'] = 'DetailView';
     $_REQUEST['return_module'] = 'Accounts';
     $_REQUEST['return_id'] = $return_id;
     $_REQUEST['offset'] = 4;
     require_once 'include/formbase.php';
     $url = buildRedirectURL($return_id, 'Accounts');
     unset($_REQUEST['return_action']);
     unset($_REQUEST['return_module']);
     unset($_REQUEST['return_id']);
     unset($_REQUEST['offset']);
     $this->assertContains('offset=4', $url, "Offset was not included in the redirect url");
 }
开发者ID:rgauss,项目名称:sugarcrm_dev,代码行数:15,代码来源:Bug23816Test.php

示例3: doVSMigrate

function doVSMigrate()
{
    global $dbxlink;
    $vs_id = assertUIntArg('vs_id');
    $vs_cell = spotEntity('ipvs', $vs_id);
    amplifyCell($vs_cell);
    $tag_ids = genericAssertion('taglist', 'array0');
    $old_vs_list = genericAssertion('vs_list', 'array');
    $plan = callHook('buildVSMigratePlan', $vs_id, $old_vs_list);
    $dbxlink->beginTransaction();
    // remove all triplets
    usePreparedDeleteBlade('VSEnabledIPs', array('vs_id' => $vs_id));
    usePreparedDeleteBlade('VSEnabledPorts', array('vs_id' => $vs_id));
    // remove all VIPs and ports that are in $plan and create new ones
    foreach ($plan['vips'] as $vip) {
        usePreparedDeleteBlade('VSIPs', array('vs_id' => $vs_id, 'vip' => $vip['vip']));
        usePreparedInsertBlade('VSIPs', array('vs_id' => $vs_id) + $vip);
    }
    foreach ($plan['ports'] as $port) {
        usePreparedDeleteBlade('VSPorts', array('vs_id' => $vs_id, 'proto' => $port['proto'], 'vport' => $port['vport']));
        usePreparedInsertBlade('VSPorts', array('vs_id' => $vs_id) + $port);
    }
    // create triplets
    foreach ($plan['triplets'] as $triplet) {
        $tr_key = array('vs_id' => $triplet['vs_id'], 'object_id' => $triplet['object_id'], 'rspool_id' => $triplet['rspool_id']);
        foreach ($triplet['ports'] as $port) {
            addSLBPortLink($tr_key + $port);
        }
        foreach ($triplet['vips'] as $vip) {
            addSLBIPLink($tr_key + $vip);
        }
    }
    // update configs
    usePreparedUpdateBlade('VS', $plan['properties'], array('id' => $vs_id));
    // replace tags
    global $taglist;
    $chain = array();
    foreach ($tag_ids as $tid) {
        if (!isset($taglist[$tid])) {
            $dbxlink->rollback();
            showError("Unknown tag id {$tid}");
        } else {
            $chain[] = $taglist[$tid];
        }
    }
    rebuildTagChainForEntity('ipvs', $vs_id, $chain, TRUE);
    $dbxlink->commit();
    showSuccess("old VS configs were copied to VS group");
    return buildRedirectURL(NULL, 'default');
}
开发者ID:xtha,项目名称:salt,代码行数:50,代码来源:ophandlers.php

示例4: doPDUSNMPmining

function doPDUSNMPmining($switch)
{
    global $objectInfo, $known_APC_SKUs;
    if (FALSE !== ($dict_key = array_search($switch->getHWModel(), $known_APC_SKUs))) {
        updateStickerForCell($objectInfo, 2, $dict_key);
    }
    updateStickerForCell($objectInfo, 1, $switch->getHWSerial());
    updateStickerForCell($objectInfo, 3, $switch->getName());
    updateStickerForCell($objectInfo, 5, $switch->getFWRev());
    checkPIC('1-16');
    commitAddPort($objectInfo['id'], 'input', '1-16', 'input', '');
    $portno = 1;
    foreach ($switch->getPorts() as $name => $port) {
        $label = mb_strlen($port[0]) ? $port[0] : $portno;
        checkPIC('1-1322');
        commitAddPort($objectInfo['id'], $portno, '1-1322', $port[0], '');
        $portno++;
    }
    showSuccess("Added {$portno} port(s)");
    return buildRedirectURL(NULL, 'ports');
}
开发者ID:ivladdalvi,项目名称:racktables,代码行数:21,代码来源:snmp.php

示例5: handleRedirect

/**
 * Handles a redirect from a Form SugarCRM based or return_url information.
 *
 * This function redirect automatically if $_REQUEST['return_url'] isn't empty.
 * It also exits the app always.
 *
 * @see buildRedirectUrl()
 * @see SugarApplication::redirect()
 *
 * @deprecated since 7.0.0. Use buildRedirectUrl() and SugarApplication::redirect().
 *
 * @param string $return_id (optional) The record id to redirect to.
 * @param string $return_module (optional) The module to redirect to.
 * @param array $additionalFlags (optional) Additional flags to sent to the URL.
 */
function handleRedirect($return_id = '', $return_module = '', array $additionalFlags = array())
{
    if (!empty($_REQUEST['return_url'])) {
        $url = $_REQUEST['return_url'];
    } else {
        $url = buildRedirectURL($return_id, $return_module, $additionalFlags);
    }
    SugarApplication::redirect($url);
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:24,代码来源:formbase.php

示例6: handleSave


//.........这里部分代码省略.........
         }
     } elseif (empty($focus->id)) {
         //this is not from long form so add assigned and current user automatically as there is no invitee list UI.
         //This call could be through an ajax call from subpanels or shortcut bar
         if (!isset($_POST['user_invitees'])) {
             $_POST['user_invitees'] = '';
         }
         $_POST['user_invitees'] .= ',' . $_POST['assigned_user_id'] . ', ';
         //add current user if the assigned to user is different than current user.
         if ($current_user->id != $_POST['assigned_user_id'] && $_REQUEST['module'] != "Calendar") {
             $_POST['user_invitees'] .= ',' . $current_user->id . ', ';
         }
         //remove any double comma's introduced during appending
         $_POST['user_invitees'] = str_replace(',,', ',', $_POST['user_invitees']);
     }
     if (isset($_POST['isSaveFromDetailView']) && $_POST['isSaveFromDetailView'] == 'true' || (isset($_POST['is_ajax_call']) && !empty($_POST['is_ajax_call']) && !empty($focus->id) || isset($_POST['return_action']) && $_POST['return_action'] == 'SubPanelViewer' && !empty($focus->id)) || !isset($_POST['user_invitees'])) {
         $focus->save(true);
         $return_id = $focus->id;
     } else {
         if ($focus->status == 'Held' && $this->isEmptyReturnModuleAndAction() && !$this->isSaveFromDCMenu()) {
             //if we are closing the meeting, and the request does not have a return module AND return action set and it is not a save
             //being triggered by the DCMenu (shortcut bar) then the request is coming from a dashlet or subpanel close icon and there is no
             //need to process user invitees, just save the current values.
             $focus->save(true);
         } else {
             $relate_to = $this->getRelatedModuleName($focus);
             $userInvitees = array();
             $contactInvitees = array();
             $leadInvitees = array();
             $existingUsers = array();
             $existingContacts = array();
             $existingLeads = array();
             if (!empty($_POST['user_invitees'])) {
                 $userInvitees = explode(',', trim($_POST['user_invitees'], ','));
             }
             if (!empty($_POST['existing_invitees'])) {
                 $existingUsers = explode(",", trim($_POST['existing_invitees'], ','));
             }
             if (!empty($_POST['contact_invitees'])) {
                 $contactInvitees = explode(',', trim($_POST['contact_invitees'], ','));
             }
             if (!empty($_POST['existing_contact_invitees'])) {
                 $existingContacts = explode(",", trim($_POST['existing_contact_invitees'], ','));
             }
             if (!empty($_POST['parent_id']) && $_POST['parent_type'] == 'Contacts') {
                 $contactInvitees[] = $_POST['parent_id'];
             }
             if ($relate_to == 'Contacts') {
                 if (!empty($_REQUEST['relate_id']) && !in_array($_REQUEST['relate_id'], $contactInvitees)) {
                     $contactInvitees[] = $_REQUEST['relate_id'];
                 }
             }
             if (!empty($_POST['lead_invitees'])) {
                 $leadInvitees = explode(',', trim($_POST['lead_invitees'], ','));
             }
             if (!empty($_POST['existing_lead_invitees'])) {
                 $existingLeads = explode(",", trim($_POST['existing_lead_invitees'], ','));
             }
             if (!empty($_POST['parent_id']) && $_POST['parent_type'] == 'Leads') {
                 $leadInvitees[] = $_POST['parent_id'];
             }
             if ($relate_to == 'Leads') {
                 if (!empty($_REQUEST['relate_id']) && !in_array($_REQUEST['relate_id'], $leadInvitees)) {
                     $leadInvitees[] = $_REQUEST['relate_id'];
                 }
             }
             // Call the Meeting module's save function to handle saving other fields besides
             // the users and contacts relationships
             $focus->update_vcal = false;
             // Bug #49195 : don't update vcal b/s related users aren't saved yet, create vcal cache below
             $focus->users_arr = $userInvitees;
             $focus->contacts_arr = $contactInvitees;
             $focus->leads_arr = $leadInvitees;
             $focus->save(true);
             $return_id = $focus->id;
             if (empty($return_id)) {
                 //this is to handle the situation where the save fails, most likely because of a failure
                 //in the external api. bug: 42200
                 $_REQUEST['action'] = 'EditView';
                 $_REQUEST['return_action'] = 'EditView';
                 handleRedirect('', 'Meetings');
             }
             $focus->setUserInvitees($userInvitees, $existingUsers);
             $focus->setContactInvitees($contactInvitees, $existingContacts);
             $focus->setLeadInvitees($focus->leads_arr, $existingLeads);
             // Bug #49195 : update vcal
             vCal::cache_sugar_vcal($current_user);
             $this->processRecurring($focus);
         }
     }
     if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] === 'Home') {
         SugarApplication::redirect(buildRedirectURL('', 'Home'));
     } else {
         if ($redirect) {
             handleRedirect($return_id, 'Meetings');
         } else {
             return $focus;
         }
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:101,代码来源:MeetingFormBase.php

示例7: handleRedirect

function handleRedirect($return_id = '', $return_module = '', $additionalFlags = false)
{
    if (isset($_REQUEST['return_url']) && $_REQUEST['return_url'] != "") {
        header("Location: " . $_REQUEST['return_url']);
        exit;
    }
    $url = buildRedirectURL($return_id, $return_module);
    header($url);
    exit;
}
开发者ID:thsonvt,项目名称:sugarcrm_dev,代码行数:10,代码来源:formbase.php

示例8: execute_PortLinker

function execute_PortLinker()
{
    global $localSplit, $remoteSplit;
    $errorText = determine_PortLinker();
    $object = spotEntity('object', $_REQUEST['object_id']);
    if (strlen($errorText) == 0) {
        $count = 0;
        // loop through all remote objects as defined
        foreach ($localSplit as $aKey => $aValue) {
            $numAdd = $remoteSplit[$aKey][$object['name']]['start'] - $aValue['start'];
            foreach ($aValue['ports'] as $aPortNum => $aPort) {
                linkPorts($aPort['id'], $aValue['remote_ports'][$aPortNum + $numAdd]['id']);
                $count++;
            }
        }
    }
    if (strlen($errorText) == 0) {
        return buildRedirectURL(__FUNCTION__, 'OK', array("{$count} ports successfully linked"));
    } else {
        return buildRedirectURL(__FUNCTION__, 'ERR', array($errorText));
    }
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:22,代码来源:local_portlinker.php

示例9: array

$params = array();
$params[] = "<a href='index.php?module={$focus->module_dir}&action=index'>{$focus->module_dir}</a>";
$params[] = "<a href='index.php?module={$focus->module_dir}&action=DetailView&record={$focus->id}'>{$focus->name}</a>";
$params[] = $mod_strings['LBL_MANAGE_SUBSCRIPTIONS_TITLE'];
$title = getClassicModuleTitle($focus->module_dir, $params, true);
$orig_vals_str = printOriginalValues($focus);
$orig_vals_array = constructDDSubscriptionList($focus);
$this->ss->assign('title', $title);
$this->ss->assign('enabled_subs', $orig_vals_array[0]);
$this->ss->assign('disabled_subs', $orig_vals_array[1]);
$this->ss->assign('enabled_subs_string', $orig_vals_str[0]);
$this->ss->assign('disabled_subs_string', $orig_vals_str[1]);
// FIXME we are doing this way since this view is going to be removed later
// this should be with proper buttons from smarty tpls.
require_once 'include/formbase.php';
$url = buildRedirectURL();
$cancelButtonClick = "SUGAR.ajaxUI.loadContent('{$url}'); return false;";
/*
 * Parse the module from the URL first using regular expression.
 * This is faster than parse_url + parse_str in first place and most of
 * our redirects won't go to sidecar (at least for now).
 */
if (preg_match('/module=([^&]+)/', $url, $matches) && !isModuleBWC($matches[1])) {
    parse_str(parse_url($url, PHP_URL_QUERY), $params);
    $script = navigateToSidecar(buildSidecarRoute($params['module'], $params['record'], translateToSidecarAction($params['action'])));
    $cancelButtonClick = "{$script} return false;";
}
$buttons = array('<input id="save_button" title="' . $app_strings['LBL_SAVE_BUTTON_TITLE'] . '" accessKey="' . $app_strings['LBL_SAVE_BUTTON_KEY'] . '" class="button" onclick="save();this.form.action.value=\'Subscriptions\'; " type="submit" name="button" value="' . $app_strings['LBL_SAVE_BUTTON_LABEL'] . '">', '<input id="cancel_button" title="' . $app_strings['LBL_CANCEL_BUTTON_TITLE'] . '" accessKey="' . $app_strings['LBL_CANCEL_BUTTON_KEY'] . '" class="button" onclick="' . $cancelButtonClick . '" type="submit" name="button" value="' . $app_strings['LBL_CANCEL_BUTTON_LABEL'] . '">');
$this->ss->assign('BUTTONS', $buttons);
$this->ss->display('modules/Campaigns/Subscriptions.tpl');
/*
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:31,代码来源:Subscriptions.php

示例10: genericAssertion

         echo "NAK\nRuntime exception: " . $e->getMessage();
     }
     break;
 case 'redirect' == $_REQUEST['module']:
     // Include init after ophandlers/snmp, not before, so local.php can redefine things.
     require_once 'inc/ophandlers.php';
     // snmp.php is an exception, it is treated by a special hack
     if (isset($_REQUEST['op']) and $_REQUEST['op'] == 'querySNMPData') {
         require_once 'inc/snmp.php';
     }
     require_once 'inc/init.php';
     try {
         genericAssertion('op', 'string');
         $op = $_REQUEST['op'];
         prepareNavigation();
         $location = buildRedirectURL();
         // FIXME: find a better way to handle this error
         if ($op == 'addFile' && !isset($_FILES['file']['error'])) {
             throw new RackTablesError('File upload error, check upload_max_filesize in php.ini', RackTablesError::MISCONFIGURED);
         }
         fixContext();
         if (!isset($ophandler[$pageno][$tabno][$op]) or !is_callable($ophandler[$pageno][$tabno][$op])) {
             throw new RackTablesError("Invalid navigation data for '{$pageno}-{$tabno}-{$op}'", RackTablesError::INTERNAL);
         }
         // We have a chance to handle an error before starting HTTP header.
         if (!isset($delayauth["{$pageno}-{$tabno}-{$op}"])) {
             assertPermission();
         }
         # Call below does the job of bypass argument assertion, if such is required,
         # so the ophandler function doesn't have to re-assert this portion of its
         # arguments. And it would be even better to pass returned value to ophandler,
开发者ID:ehironymous,项目名称:racktables,代码行数:31,代码来源:index.php

示例11: updateObjectAllocation

function updateObjectAllocation()
{
    global $remote_username, $sic;
    if (!isset($_REQUEST['got_atoms'])) {
        unset($_GET['page']);
        unset($_GET['tab']);
        unset($_GET['op']);
        unset($_POST['page']);
        unset($_POST['tab']);
        unset($_POST['op']);
        return buildRedirectURL(NULL, NULL, $_REQUEST);
    }
    $object_id = getBypassValue();
    $rf1 = $_REQUEST['rfid'];
    if (isset($_REQUEST['rfid'])) {
        //	$rf1 = 1000000;//$_REQUEST['rfid'];
        $result = usePreparedSelectBlade("SELECT object_id FROM objecttorf WHERE rf_id = ?", array($rf1));
        $row = $result->fetch(PDO::FETCH_ASSOC);
        if (isset($row)) {
            $object_id = $row['object_id'];
        }
        //получить значение из базы где rf1=njvenj
        //showError ('Permission deniedddddddd, "' . $object_id . '" left unchanged');
    }
    $changecnt = 0;
    // Get a list of all of this object's parents,
    // then trim the list to only include parents that are racks
    $objectParents = getEntityRelatives('parents', 'object', $object_id);
    $parentRacks = array();
    foreach ($objectParents as $parentData) {
        if ($parentData['entity_type'] == 'rack') {
            $parentRacks[] = $parentData['entity_id'];
        }
    }
    $workingRacksData = array();
    foreach ($_REQUEST['rackmulti'] as $cand_id) {
        if (!isset($workingRacksData[$cand_id])) {
            $rackData = spotEntity('rack', $cand_id);
            amplifyCell($rackData);
            $workingRacksData[$cand_id] = $rackData;
        }
        // It's zero-U mounted to this rack on the form, but not in the DB.  Mount it.
        if (isset($_REQUEST["zerou_{$cand_id}"]) && !in_array($cand_id, $parentRacks)) {
            $changecnt++;
            commitLinkEntities('rack', $cand_id, 'object', $object_id);
        }
        // It's not zero-U mounted to this rack on the form, but it is in the DB.  Unmount it.
        if (!isset($_REQUEST["zerou_{$cand_id}"]) && in_array($cand_id, $parentRacks)) {
            $changecnt++;
            commitUnlinkEntities('rack', $cand_id, 'object', $object_id);
        }
    }
    foreach ($workingRacksData as &$rd) {
        applyObjectMountMask($rd, $object_id);
    }
    $oldMolecule = getMoleculeForObject($object_id);
    foreach ($workingRacksData as $rack_id => $rackData) {
        if (!processGridForm($rackData, 'F', 'T', $object_id)) {
            continue;
        }
        $changecnt++;
        // Reload our working copy after form processing.
        $rackData = spotEntity('rack', $cand_id);
        amplifyCell($rackData);
        applyObjectMountMask($rackData, $object_id);
        $workingRacksData[$rack_id] = $rackData;
    }
    if ($changecnt) {
        // Log a record.
        $newMolecule = getMoleculeForObject($object_id);
        usePreparedInsertBlade('MountOperation', array('object_id' => $object_id, 'old_molecule_id' => count($oldMolecule) ? createMolecule($oldMolecule) : NULL, 'new_molecule_id' => count($newMolecule) ? createMolecule($newMolecule) : NULL, 'user_name' => $remote_username, 'comment' => empty($sic['comment']) ? NULL : $sic['comment']));
    }
    showFuncMessage(__FUNCTION__, 'OK', array($changecnt));
}
开发者ID:peter-volkov,项目名称:RackTrack,代码行数:74,代码来源:ophandlers.php

示例12: cloneRSPool

function cloneRSPool()
{
    assertUIntArg('pool_id');
    $pool = spotEntity('ipv4rspool', $_REQUEST['pool_id']);
    $rs_list = getRSListInPool($pool['id']);
    $tagidlist = array();
    foreach ($pool['etags'] as $taginfo) {
        $tagidlist[] = $taginfo['id'];
    }
    $new_id = commitCreateRSPool($pool['name'] . ' (copy)', $pool['vsconfig'], $pool['rsconfig'], $tagidlist);
    foreach ($rs_list as $rs) {
        addRStoRSPool($new_id, $rs['rsip_bin'], $rs['rsport'], $rs['inservice'], $rs['rsconfig'], $rs['comment']);
    }
    showSuccess("Created a copy of pool <a href='" . makeHref(array('page' => 'ipv4rspool', 'tab' => 'default', 'pool_id' => $pool['id'])) . "'>{$pool['name']}</a>");
    return buildRedirectURL('ipv4rspool', 'default', array('pool_id' => $new_id));
}
开发者ID:rhysm,项目名称:racktables,代码行数:16,代码来源:ophandlers.php

示例13: sugar_cleanup

 * Contributor(s): ______________________________________..
 ********************************************************************************/
require_once 'include/formbase.php';
$focus = BeanFactory::getBean('ContractTypes', $_POST['record']);
if (!$focus->ACLAccess('Save')) {
    ACLController::displayNoAccess(true);
    sugar_cleanup(true);
}
$check_notify = FALSE;
foreach ($focus->column_fields as $field) {
    if (isset($_POST[$field])) {
        $value = $_POST[$field];
        $focus->{$field} = $value;
    }
}
foreach ($focus->additional_column_fields as $field) {
    if (isset($_POST[$field])) {
        $value = $_POST[$field];
        $focus->{$field} = $value;
    }
}
$return_id = $focus->save($check_notify);
$GLOBALS['log']->debug("Saved record with id of " . $return_id);
$url = buildRedirectURL($return_id, 'ContractTypes');
if (isset($_REQUEST['edit'])) {
    $url .= "&edit=" . $_REQUEST['edit'];
}
if (isset($_REQUEST['isDuplicate'])) {
    $url .= "&isDuplicate=" . $_REQUEST['isDuplicate'];
}
SugarApplication::redirect($url);
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:31,代码来源:Save.php

示例14: redirectIfNecessary

function redirectIfNecessary()
{
    global $trigger, $pageno, $tabno;
    @session_start();
    if (!isset($_REQUEST['tab']) and isset($_SESSION['RTLT'][$pageno]) and getConfigVar('SHOW_LAST_TAB') == 'yes' and permitted($pageno, $_SESSION['RTLT'][$pageno]['tabname']) and time() - $_SESSION['RTLT'][$pageno]['time'] <= TAB_REMEMBER_TIMEOUT) {
        redirectUser(buildRedirectURL($pageno, $_SESSION['RTLT'][$pageno]['tabname']));
    }
    // check if we accidentaly got on a dynamic tab that shouldn't be shown for this object
    if (isset($trigger[$pageno][$tabno]) and !strlen(call_user_func($trigger[$pageno][$tabno]))) {
        $_SESSION['RTLT'][$pageno]['dont_remember'] = 1;
        redirectUser(buildRedirectURL($pageno, 'default'));
    }
    if (is_array(@$_SESSION['RTLT'][$pageno]) && isset($_SESSION['RTLT'][$pageno]['dont_remember'])) {
        unset($_SESSION['RTLT'][$pageno]['dont_remember']);
    }
    // store the last visited tab name
    if (isset($_REQUEST['tab'])) {
        $_SESSION['RTLT'][$pageno] = array('tabname' => $tabno, 'time' => time());
    }
    session_commit();
    // if we are continuing to run, unlock session data
}
开发者ID:rhysm,项目名称:racktables,代码行数:22,代码来源:functions.php

示例15: Update


//.........这里部分代码省略.........
                            commitUpdateAttrValue($newmachine, $id, strtotime($value));
                        } else {
                            commitUpdateAttrValue($newmachine, $id, $value);
                        }
                    }
                }
            }
        }
    }
    fclose($manifest_file);
    // Add network interfaces
    // Create an array with interfaces
    $nics = explode(',', $facter['interfaces']);
    // Go through all interfaces and add IP and MAC
    $count = count($nics);
    for ($i = 0; $i < $count; $i++) {
        // Remove newline from the field
        $nics[$i] = str_replace("\n", "", $nics[$i]);
        // We generally don't monitor sit interfaces.
        // We don't do this for lo interfaces, too
        // 2011-08-31 <neil.scholten@gamigo.com>
        // * Only Document real interfaces, dont do bridges, bonds, vlan-interfaces
        //   when they have no IP defined.
        if (preg_match('(_|^(bond|lo|sit|vnet|virbr|veth|peth))', $nics[$i]) != 0) {
            // do nothing
        } else {
            // Get IP
            if (isset($facter['ipaddress_' . $nics[$i]])) {
                $ip = $facter['ipaddress_' . $nics[$i]];
            }
            // Get MAC
            if (isset($facter['macaddress_' . $nics[$i]])) {
                $mac = $facter['macaddress_' . $nics[$i]];
            }
            //check if VM or not
            if ($facter['is_virtual'] == "false") {
                // Find 1000Base-T id
                $query = "select id from PortOuterInterface where oif_name REGEXP '^ *1000Base-T\$' LIMIT 1";
            } else {
                // Find virtual port id
                $query = "select id from PortOuterInterface where oif_name REGEXP '^ *virtual port\$' LIMIT 1";
            }
            unset($result);
            $result = usePreparedSelectBlade($query);
            $resultarray = $result->fetchAll(PDO::FETCH_ASSOC);
            if ($resultarray) {
                $nictypeid = $resultarray[0]['id'];
            }
            // Remove newline from ip
            $ip = str_replace("\n", "", $ip);
            // Check to se if the interface has an ip assigned
            $query = "SELECT object_id FROM IPv4Allocation where object_id={$newmachine} and name=\"{$nics[$i]}\"";
            unset($result);
            $result = usePreparedSelectBlade($query);
            $resultarray = $result->fetchAll(PDO::FETCH_ASSOC);
            if ($resultarray) {
                unset($id);
                $ipcheck = $resultarray;
            }
            // Check if it's been configured a port already
            $query = "SELECT id,iif_id FROM Port where object_id={$newmachine} and name=\"{$nics[$i]}\"";
            unset($result);
            $result = usePreparedSelectBlade($query);
            $resultarray = $result->fetchAll(PDO::FETCH_ASSOC);
            if ($resultarray) {
                $portid = $resultarray[0]['id'];
                unset($id);
                $portcheck = $resultarray;
            }
            // Add/update port
            // 2011-08-31 <neil.scholten@gamigo.com>
            // * Don't touch already existing complex ports
            if ($resultarray[0]['type'] != 9) {
                if (count($portcheck) == 1) {
                    commitUpdatePort($newmachine, $portid, $nics[$i], $nictypeid, "Ethernet port", "{$mac}", NULL);
                } else {
                    commitAddPort($object_id = $newmachine, $nics[$i], $nictypeid, 'Ethernet port', "{$mac}");
                }
            } else {
                //We've got a complex port, don't touch it, it raises an error with 'Database error: foreign key violation'
            }
            if (count($ipcheck) == 1) {
                if ($ip) {
                    updateAddress(ip_parse($ip), $newmachine, $nics[$i], 'regular');
                }
            } else {
                if ($ip) {
                    bindIpToObject(ip_parse($ip), $newmachine, $nics[$i], 'regular');
                }
            }
            unset($portcheck);
            unset($ipcheck);
            unset($ip);
            unset($mac);
        }
    }
    //uncomment to start using auto tags
    //addTagToObject($facter, $newmachine);
    return buildRedirectURL();
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:101,代码来源:facter.php


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