Esempio n. 1
0
function ports_create()
{
    $cfg = $GLOBALS['cfg'];
    $db = $GLOBALS['db'];
    // which view to render
    $nesting = get_nesting();
    $number = intval($_POST['number']);
    $proto = $db->escape($_POST['proto']);
    $daemon_id = intval($_POST['daemon_id']);
    $result = $db->insert("INSERT INTO {$cfg['tblPort']}\n        (number, proto, daemon_id) VALUES\n        ('{$number}', '{$proto}', '{$daemon_id}')");
    $id = $db->insertId();
    if (!$result) {
        halt(SERVER_ERROR);
        return;
    }
    $arrPorts = fetchPorts("WHERE {$cfg['tblPort']}.id={$id}");
    set('port', array_pop($arrPorts));
    if (isAjaxRequest()) {
        return js('ports/show.js.php', null, array('nested' => $nesting));
    } else {
        redirect_to('ports');
    }
}
Esempio n. 2
0
function clients_create()
{
    $cfg = $GLOBALS['cfg'];
    $db = $GLOBALS['db'];
    // sets which view to render
    $nested = get_nesting();
    $type = $db->escape($_POST['type']);
    $mac = $db->escape($_POST['mac']);
    $desc = $db->escape($_POST['desc']);
    $person_id = intval($_POST['person_id']);
    $result = $db->insert("INSERT INTO {$cfg['tblClient']}\n        (type, mac, `desc`, person_id) VALUES\n        ('{$type}', '{$mac}', '{$desc}', '{$person_id}')");
    $id = $db->insertId();
    if (!$result) {
        halt(SERVER_ERROR);
        return;
    }
    $arrClient = fetchClients("WHERE {$cfg['tblClient']}.id={$id}");
    set('client', array_pop($arrClient));
    if (isAjaxRequest()) {
        return js('clients/show.js.php', null, array('nested' => $nested));
    } else {
        redirect_to('clients');
    }
}