function update_router()
{
    global $password;
    $stmt = "select name, switch, port, bandwidth from comps order by port";
    $q = query($stmt);
    global $switches;
    foreach ($switches as $id => $sw) {
        $sw->conn = ftp_connect($sw->ip);
        $login_result = ftp_login($sw->conn, "admin", $password);
        if (!$login_result) {
            echo "ftp connection failed\n";
            pfinish();
        }
        $t = sprintf("/tmp/switchconfig%d", $id);
        $sw->fp = fopen($t, "w");
        $sw->config = "";
        $sw->fp = fopen($t, "w");
        $sw->config = "";
        $sw->config .= "vlan 1\n" . "  name 1\n" . "  normal \"\"\n" . "  fixed 1-8\n" . "  forbidden \"\"\n" . "  untagged 1-8\n" . "  ip address default-management";
        $sw->config .= sprintf(" %s 255.255.255.0\n", $sw->ip);
        $sw->config .= "exit\n";
    }
    global $low_speed;
    while (($r = fetch($q)) != NULL) {
        $switches[$r->switch]->config .= sprintf("interface port-channel %d\n", $r->port);
        $switches[$r->switch]->config .= sprintf("  name %s\n", $r->name);
        if ($r->bandwidth == "high") {
            $switches[$r->switch]->config .= sprintf("  no bandwidth-limit ingress\n" . "  no bandwidth-limit egress\n");
        } else {
            $switches[$r->switch]->config .= sprintf("  bandwidth-limit ingress\n" . "  bandwidth-limit ingress %d\n" . "  bandwidth-limit egress\n" . "  bandwidth-limit egress %d\n", $low_speed, $low_speed);
        }
        $switches[$r->switch]->config .= sprintf("exit\n");
    }
    foreach ($switches as $id => $sw) {
        $sw->config .= "bandwidth-control\n";
        fwrite($sw->fp, $sw->config);
        fclose($sw->fp);
        $t = sprintf("/tmp/switchconfig%d", $id);
        $upload = ftp_put($sw->conn, "config", $t, FTP_ASCII);
        if (!$upload) {
            echo "ftp upload failed";
            pfinish();
        }
        ftp_close($sw->conn);
    }
    $_SESSION['flash'] = sprintf("router update in progress, please" . " wait at least 20 seconds before" . " updating again.<br />");
}
Exemple #2
0
    $t = sprintf("trans.php?tid=%d", $elt->tid);
    $rows .= sprintf("<td>%s</td>\n", mklink($elt->name2, $t));
    $t = sprintf("trans.php?tid=%d", $elt->tid);
    $rows .= sprintf("<td>%s</td>\n", mklink($elt->name, $t));
    $text = sprintf("%.2f", $elt->amount);
    $rows .= sprintf("<td class='num'>%s</td>\n", mklink($text, $t));
    $tag_name = @$tag_id_to_name[$elt->tag_id];
    $t = sprintf("tag.php?tag_id=%d", $elt->tag_id);
    $rows .= sprintf("<td>%s</td>", mklink($tag_name, $t));
    $rows .= "</tr>\n";
}
$body .= "<h2>Similar transactions</h2>\n";
if (count($splits) == 1 && count($similar_tids) > 0) {
    $sp = $splits[0];
    $body .= "<form action='trans.php'>\n";
    $body .= "<input type='hidden' name='set_splits' value='1' />\n";
    $body .= sprintf("<input type='hidden' name='tid' value='%d' />\n", $arg_tid);
    $body .= sprintf("<input type='hidden' name='name2' value='%s' />\n", h($db_name2));
    $val = join(",", $similar_tids);
    $body .= sprintf("<input type='hidden' name='tids' value='%s' />\n", h($val));
    $body .= sprintf("<input type='hidden' name='tag_id' value='%d' />\n", $sp->tag_id);
    $body .= "<input type='checkbox'" . " name='set_splits_checkbox' value='1' />\n";
    $tag_name = $tag_id_to_name[$sp->tag_id];
    $text = sprintf("Set %d transactions to %s", count($similar_tids), $tag_name);
    $body .= sprintf("<input type='submit' value='%s' />\n", h($text));
    $body .= "</form>\n";
}
$cols = array("Posted", "Name2", "Name", "Amount", "Tag");
$body .= boxed_table($cols, $rows);
pfinish();
Exemple #3
0
function redirect($target)
{
    $target = make_absolute($target);
    if ($debug || $stop_redirect) {
        global $login_id, $anon_ok;
        echo "debug or stop redirect... {$login_id} {$anon_ok} ";
        var_dump($target);
        var_dump($_SERVER);
        $s = trim(@$_SESSION['flash']);
        if ($s != "") {
            $body .= "<p>pending flash: \n";
            $body .= h($s);
            $body .= "</p>\n";
        }
        $body .= "<p>";
        $body .= mklink("(dbg=1: click here to finish redirect)", $target);
        $body .= "</p>\n";
        foobar();
        pfinish();
    }
    session_write_close();
    do_commits();
    ob_clean();
    header("Location: {$target}");
    exit;
}
Exemple #4
0
function csrf_check()
{
    if (!csrf_valid()) {
        global $body;
        $body .= "form submission timeout ..." . " please go back, reload, and try again";
        putsess("csrf_token", NULL);
        pfinish();
    }
    global $csrf_safe;
    $csrf_safe = 1;
}