Example #1
0
function CheckSchema()
{
    // check php version
    if (phpversion() < "4.1.0") {
        die("You need php version 4.1.0 or later");
    }
    if (phpversion() >= "6") {
        die("This version of IPplan will not work with PHP 6.x");
    }
    // cant use myError here as we do not have access to layout yet!
    $ds = new IPplanDbf();
    //$ds->ds->debug = true;
    if (!$ds) {
        die(my_("Could not connect to database"));
    }
    // check mysql version
    if (DBF_TYPE == "mysql" or DBF_TYPE == "maxsql") {
        $result =& $ds->ds->Execute("SELECT version() AS version");
        $row = $result->FetchRow();
        $version = $row["version"];
        if ($version < "3.23.15") {
            die("You need mysql version 3.23.15 or later");
        }
    }
    // get schema version
    // schema is reserved word in mssql
    if (DBF_TYPE == "mssql" or DBF_TYPE == "ado_mssql" or DBF_TYPE == "odbc_mssql" or DBF_TYPE == 'mysql' or DBF_TYPE == 'maxsql') {
        $result =& $ds->ds->Execute("SELECT version\n                             FROM version");
    } else {
        $result =& $ds->ds->Execute("SELECT version\n                             FROM schema");
    }
    // could return error if schema table does not exist!
    if (!$result) {
        echo my_("Problem with database permission or database tables - have installation instructions been followed?") . "<p>";
        die(my_("Could not connect to database"));
    }
    $row = $result->FetchRow();
    $version = $row["version"];
    // schema version did not change
    if ($version == SCHEMA) {
        return;
    } else {
        if (SCHEMA < $version) {
            echo my_("You are trying to downgrade IPplan - impossible");
            exit;
        }
    }
    echo "<b>" . my_("Schema version outdated") . "</b>:<p>";
    echo sprintf(my_("The database structures need to be upgraded to accommodate new features. For this to happen, you require enough access rights on the %s database. If you get errors back from the upgrade process, you will need to temporarily grant more access rights to the %s database for the duration of the upgrade"), DBF_NAME, DBF_NAME);
    echo "<p>" . my_("This process needs to be done by the administrator by executing the installation scripts. See information in the INSTALL and UPGRADE files.");
    exit;
}
Example #2
0
function searchRangeDropDown($ds, $f2, $cust, $areaindex, $rangeindex = 0)
{
    $cust = floor($cust);
    // dont trust $cust as it could
    // come from form post
    $areaindex = floor($areaindex);
    // display range drop down list
    if ($areaindex) {
        $result = $ds->GetRangeInArea($cust, $areaindex);
    } else {
        $result = $ds->GetRange($cust, 0);
    }
    // don't bother if there are no records, will always display "No range"
    insert($f2, textbrbr(my_("Range (optional)")));
    $lst = array();
    $lst["0"] = my_("No range selected");
    while ($row = $result->FetchRow()) {
        $col = $row["rangeindex"];
        $lst["{$col}"] = inet_ntoa($row["rangeaddr"]) . "/" . inet_ntoa(inet_aton(ALLNETS) - $row["rangesize"] + 1) . "/" . inet_bits($row["rangesize"]) . " - " . $row["descrip"];
    }
    insert($f2, selectbox($lst, array("name" => "rangeindex", "onChange" => "submit()"), $rangeindex));
    return $rangeindex;
}
Example #3
0
            insert($w, text(my_("Password changed")));
        } else {
            $formerror .= my_("Password could not be changed") . "\n";
        }
    }
}
if (!$_POST || $formerror) {
    myError($w, $p, $formerror, FALSE);
    if ($user) {
        insert($w, heading(3, sprintf(my_("Change password for user %s"), $user)));
    } else {
        insert($w, heading(3, sprintf(my_("Change password for user %s"), getAuthUsername())));
    }
    // start form
    insert($w, $f = form(array("method" => "post", "action" => $_SERVER["PHP_SELF"])));
    insert($f, $con = container("fieldset", array("class" => "fieldset")));
    insert($con, $legend = container("legend", array("class" => "legend")));
    insert($legend, text($title));
    // display opening text
    if ($user) {
        insert($con, hidden(array("name" => "user", "value" => "{$user}")));
    }
    insert($con, textbr(my_("New password (case sensitive!):")));
    insert($con, password(array("name" => "password1", "value" => "{$password1}", "size" => "40", "maxlength" => "40")));
    insert($con, textbrbr(my_("New password (again):")));
    insert($con, password(array("name" => "password2", "value" => "{$password2}", "size" => "40", "maxlength" => "40")));
    insert($con, generic("br"));
    insert($con, submit(array("value" => my_("Submit"))));
    insert($con, freset(array("value" => my_("Clear"))));
}
printhtml($p);
Example #4
0
    // end while: loop through ips of subnet.
    // Loop through the dynamic IPs above, and print the ranges.
    $iprange_start = $iprange_dynamicIPs[0];
    for ($i = 0; $i < count($iprange_dynamicIPs); $i++) {
        if ($iprange_dynamicIPs[$i] + 1 != $iprange_dynamicIPs[$i + 1]) {
            fputs($fp, sprintf("\t<iprange type=\"dynamic\" firstip=\"%s\" lastip=\"%s\" />\n", htmlspecialchars(inet_ntoa($iprange_start)), htmlspecialchars(inet_ntoa($iprange_dynamicIPs[$i]))));
            $iprange_start = $iprange_dynamicIPs[$i + 1];
        }
    }
    $iprange_start = $iprange_fixedIPs[0];
    for ($i = 0; $i < count($iprange_fixedIPs); $i++) {
        if ($iprange_fixedIPs[$i] + 1 != $iprange_fixedIPs[$i + 1]) {
            fputs($fp, sprintf("\t<iprange type=\"static\" firstip=\"%s\" lastip=\"%s\" />\n", htmlspecialchars(inet_ntoa($iprange_start)), htmlspecialchars(inet_ntoa($iprange_fixedIPs[$i]))));
            $iprange_start = $iprange_fixedIPs[$i + 1];
        }
    }
    fputs($fp, sprintf("</network>\n"));
}
// end while
if ($cnt) {
    fputs($fp, sprintf("</dhcp>\n"));
    fclose($fp);
    $ds->AuditLog(array("event" => 913, "action" => "export DHCP subnets", "cust" => $cust, "user" => getAuthUsername(), "tmpfname" => $tmpfname));
    insert($w, textbr(sprintf(my_("Sent update to Backend Processor as file %s"), $tmpfname)));
} else {
    myError($w, $p, my_("No DHCP subnets could be found."));
}
printhtml($p);
?>
 
Example #5
0
insert($con, hidden(array("name" => "baseindex", "value" => $baseindex)));
insert($con, hidden(array("name" => "block", "value" => $block)));
insert($con, hidden(array("name" => "search", "value" => $search)));
insert($con, hidden(array("name" => "expr", "value" => "{$expr}")));
$cnt = 0;
foreach ($ip as $value) {
    insert($con, hidden(array("name" => "ip[" . $cnt++ . "]", "value" => "{$value}")));
}
insert($con, hidden(array("name" => "md5str", "value" => "{$md5str}")));
insert($f, submit(array("value" => my_("Submit"))));
insert($f, freset(array("value" => my_("Clear"))));
// start form for delete
// all info will be blank, thus record will be deleted
$settings = array("name" => "DELETE", "method" => "post", "action" => "displaysubnet.php");
if ($ipplanParanoid) {
    $settings["onsubmit"] = "return confirm('" . my_("Are you sure?") . "')";
}
insert($w, $f = form($settings));
insert($f, hidden(array("name" => "baseindex", "value" => "{$baseindex}")));
insert($f, hidden(array("name" => "block", "value" => "{$block}")));
insert($f, hidden(array("name" => "search", "value" => $search)));
insert($con, hidden(array("name" => "expr", "value" => "{$expr}")));
$cnt = 0;
foreach ($ip as $value) {
    insert($f, hidden(array("name" => "ip[" . $cnt++ . "]", "value" => "{$value}")));
}
insert($f, hidden(array("name" => "action", "value" => "delete")));
insert($f, hidden(array("name" => "md5str", "value" => "{$md5str}")));
insert($f, submit(array("value" => my_("Delete records"))));
insert($f, textbr(my_("WARNING: Deleting an entry does not preserve the last modified information as the record is completely removed from the database to conserve space.")));
printhtml($p);
Example #6
0
    // save the last customer used
    // must set path else Netscape gets confused!
    setcookie("ipplanCustomer", "{$cust}", time() + 10000000, "/");
    // check if user belongs to customer admin group
    $result = $ds->GetCustomerGrp($cust);
    // can only be one row - does not matter if nothing is
    // found as array search will return false
    $row = $result->FetchRow();
    if (!in_array($row["admingrp"], $grps)) {
        myError($w, $p, my_("You may not delete an area for this customer as you are not a member of the customers admin group"));
    }
    if ($rangeindex > 0) {
        $result = $ds->GetRange($cust, $rangeindex);
        $row = $result->FetchRow();
        $rangeip = inet_ntoa($row["rangeaddr"]);
        $rangesize = $row["rangesize"];
        $ds->DbfTransactionStart();
        $result =& $ds->ds->Execute("DELETE FROM netrange\n                              WHERE rangeindex={$rangeindex}") and $ds->AuditLog(array("event" => 162, "action" => "delete range", "baseaddr" => $rangeip, "user" => getAuthUsername(), "size" => $rangesize, "cust" => $cust));
        if ($result) {
            $ds->DbfTransactionEnd();
            Header("Location: " . location_uri("modifyarearange.php?cust={$cust}"));
            exit;
            //insert($w,text(my_("Range deleted")));
        } else {
            insert($w, text(my_("Range could not be deleted")));
        }
    } else {
        insert($w, text(my_("Range index is invalid")));
    }
}
printhtml($p);
Example #7
0
function ProcessRow($ds, $cust, &$w, &$p, $data, $template, $append)
{
    global $format;
    $num = count($data);
    // blank row
    if (empty($data[0])) {
        insert($w, block("<b>" . my_("Row is blank - ignoring") . "</b>"));
        return;
    }
    // bogus row
    if ($num < 7) {
        // ok to save what has been imported already
        $ds->DbfTransactionEnd();
        myError($w, $p, my_("Row not the correct format."));
    }
    if (testIP(trim($data[0]))) {
        insert($w, block("<b>" . my_("Invalid IP address") . "</b>"));
        return;
    }
    $ip = inet_aton(trim($data[0]));
    $user = substr($data[1], 0, 80);
    $location = substr($data[2], 0, 80);
    $descrip = substr($data[3], 0, 80);
    $hname = substr($data[4], 0, 100);
    $telno = substr($data[5], 0, 15);
    $macaddr = substr($data[6], 0, 12);
    if ($format == "xml") {
        $macaddr = $data[6];
    }
    $info = "";
    if (is_object($template)) {
        // all columns over 6 are considered for adding to template fields
        $cnt = 7;
        $userfld = array();
        foreach ($template->userfld as $key => $value) {
            // set fields in template only if field in import file exists, else make blank
            $userfld[$key] = isset($data[$cnt]) ? $data[$cnt] : "";
            $cnt++;
        }
        $template->Merge($userfld);
        $err = $template->Verify($w);
        if ($err) {
            // ok to save what has been imported already
            $ds->DbfTransactionEnd();
            myError($w, $p, my_("Row failed template verify."));
        }
        if ($template->is_blank() == FALSE) {
            $info = $template->encode();
        }
    }
    // NOTE: Test ip address
    $result = $ds->GetBaseFromIP($ip, $cust);
    if (!($row = $result->FetchRow())) {
        // ok to save what has been imported already
        $ds->DbfTransactionEnd();
        myError($w, $p, sprintf(my_("Subnet could not be found for IP address %s"), $data[0]));
    }
    $baseindex = $row["baseindex"];
    $baseaddr = $row["baseaddr"];
    $subnetsize = $row["subnetsize"];
    if ($append == "on") {
        $ip = (array) $ip;
        if ($user === "NULL") {
            $user = "";
        }
        if ($location === "NULL") {
            $location = "";
        }
        if ($telno === "NULL") {
            $telno = "";
        }
        if ($macaddr === "NULL") {
            $macaddr = "";
        }
        if ($descrip === "NULL") {
            $descrip = "";
        }
        if ($hname === "NULL") {
            $hname = "";
        }
    }
    if ($ds->ModifyIP($ip, $baseindex, $user, $location, $telno, $macaddr, $descrip, $hname, $info) == 0) {
        insert($w, text(my_("IP address details modified")));
    } else {
        insert($w, text(my_("IP address details could not be modified")));
    }
}
Example #8
0
        insert($t, $c = cell());
        insert($c, block("<small>"));
        insert($c, block($result->UserTimeStamp($row["swipmod"], "M d Y H:i:s")));
        insert($c, block("</small>"));
    }
    $export->addCell($row["swipmod"]);
    $export->saveRow();
    if ($totcnt % MAXTABLESIZE == MAXTABLESIZE - 1) {
        break;
    }
    $cnt++;
    $totcnt++;
}
insert($w, block("<p>"));
if (!$cnt) {
    myError($w, $p, my_("Search found no matching entries"));
}
$vars = "";
$printed = 0;
while ($row = $result->FetchRow()) {
    $totcnt++;
    $vars = DisplayBlock($w, $row, $totcnt, "&cust={$cust}&areaindex={$areaindex}" . "&rangeindex={$rangeindex}&ipaddr={$ipaddr}&expr={$expr}&size={$size}" . "&descrip=" . urlencode($descrip));
    if (!empty($vars) and !$printed) {
        insert($ck, anchor($vars, ">>"));
        $printed = 1;
    }
}
$result->Close();
// create the export view form
$expression = $export->translateExpr($expr);
$export->setInfo(array(array("customer_ID", "customer_description", "area_ID", "range_ID", "search_criterion", "search_expression"), array($cust, $ds->getCustomerDescrip($cust), $areaindex, $rangeindex, $expression, $descrip)));
Example #9
0
$row = $result->FetchRow();
if (!in_array($row["admingrp"], $grps)) {
    myError($w, $p, my_("You may not send a registrar update for this customer as you are not a member of the customers admin group"));
}
$formerror = "";
$cnt = 0;
foreach ($baseindex as $key => $value) {
    $value = floor($value);
    // dont trust values posted
    $result = $ds->GetBaseFromIndex($value);
    $row = $result->FetchRow();
    $baseip = inet_ntoa($row["baseaddr"]);
    $size = $row["subnetsize"];
    $swipmod = $row["swipmod"];
    $swip = genSWIP($ds, $value, $baseip, inet_ntoa($row["baseaddr"] + $size - 1), $cust, $row["descrip"], $swipmod, $filename);
    insert($w, block("<pre>"));
    insert($w, text($swip));
    insert($w, block("</pre><hr>"));
    $err = emailSWIP($swip);
    // on email error, fail
    if ($err) {
        $formerror .= my_("E-mail message was not sent") . "\n";
        $formerror .= my_("Mailer Error: ") . $err;
        break;
    }
    $result =& $ds->ds->Execute("UPDATE base\n                          SET swipmod=" . $ds->ds->DBTimeStamp(time()) . "\n                          WHERE baseindex={$value}");
    $ds->AuditLog(array("event" => 190, "action" => "send swip", "user" => getAuthUsername(), "baseaddr" => $baseip, "template" => $filename, "size" => $size, "cust" => $cust));
}
myError($w, $p, $formerror, FALSE);
insert($w, block("<p>"));
printhtml($p);
Example #10
0
if ($_GET) {
    // save the last customer used
    // must set path else Netscape gets confused!
    setcookie("ipplanCustomer", "{$cust}", time() + 10000000, "/");
    // check if user belongs to customer admin group
    $result = $ds->GetCustomerGrp($cust);
    // can only be one row - does not matter if nothing is
    // found as array search will return false
    $row = $result->FetchRow();
    if (!in_array($row["admingrp"], $grps)) {
        myError($w, $p, my_("You may not delete an area for this customer as you are not a member of the customers admin group"));
    }
    if ($areaindex > 0) {
        $result = $ds->GetArea($cust, $areaindex);
        $row = $result->FetchRow();
        $areaip = inet_ntoa($row["areaaddr"]);
        $ds->DbfTransactionStart();
        $result =& $ds->ds->Execute("DELETE FROM area\n                              WHERE areaindex={$areaindex}") and $ds->AuditLog(array("event" => 152, "action" => "delete area", "area" => $areaip, "user" => getAuthUsername(), "cust" => $cust));
        if ($result) {
            $ds->DbfTransactionEnd();
            Header("Location: " . location_uri("modifyarearange.php?cust={$cust}"));
            exit;
            //insert($w,text(my_("Area deleted")));
        } else {
            insert($w, text(my_("Area could not be deleted")));
        }
    } else {
        insert($w, text("Area index is invalid"));
    }
}
printhtml($p);
Example #11
0
function parseDeleteBounds($w, $ds)
{
    list($grp, $boundsaddr) = myRegister("S:grp S:boundsaddr");
    $result =& $ds->ds->Execute("DELETE FROM bounds\n            WHERE grp=" . $ds->ds->qstr($grp) . " AND boundsaddr={$boundsaddr}");
    if ($result) {
        $ds->DbfTransactionEnd();
        insert($w, text(my_("Boundary deleted")));
    } else {
        insert($w, text(my_("Boundary could not be deleted")));
    }
    insertEditGroupForm($w, $ds);
}
Example #12
0
    $diff = (100 - $width) * 5;
    $width = $width * 5;
    insert($w, block("<img height=\"10\" width=\"{$width}\" src=\"../images/square_red.jpg\">"));
    insert($w, block("<img height=\"10\" width=\"{$diff}\" src=\"../images/square_green.jpg\">"));
    insert($w, textbr(''));
    insert($w, textb(my_("Total unassigned subnets (pre-allocated subnets marked as free): ")));
    insert($w, textbr($cntfree));
    insert($w, textb(my_("Unassigned subnets (pre-allocated subnets marked as free): ")));
    insert($w, textbr(round($cntfreesubsize / ($endnum - $startnum + 1) * 100, 2) . "%"));
    $width = round($cntfreesubsize / ($endnum - $startnum + 1) * 100, 2);
    $diff = (100 - $width) * 5;
    $width = $width * 5;
    insert($w, block("<img height=\"10\" width=\"{$width}\" src=\"../images/square_red.jpg\">"));
    insert($w, block("<img height=\"10\" width=\"{$diff}\" src=\"../images/square_green.jpg\">"));
    insert($w, textbr());
    insert($w, textb(my_("IP addresses allocated (including reserved addresses/excluding reserved addresses): ")));
    insert($w, textbr(round($used / ($endnum - $startnum + 1) * 100, 2) . "%" . "/" . round(($used - $cntsubnets * 2) / ($endnum - $startnum + 1) * 100, 2) . "%"));
    $width = round($used / ($endnum - $startnum + 1) * 100, 2);
    $diff = (100 - $width) * 5;
    $width = $width * 5;
    insert($w, block("<img height=\"10\" width=\"{$width}\" src=\"../images/square_red.jpg\">"));
    insert($w, block("<img height=\"10\" width=\"{$diff}\" src=\"../images/square_green.jpg\">"));
}
/*
if( function_exists('memory_get_usage') ) {
echo memory_get_usage(); // php >=4.3 only
}
*/
// create the export view form
$export->setInfo(array(array("customer_ID", "customer_description", "addr_start", "addr_end", "total_allocated_networks_subnets", "percent_network_subnets_allocated", "total_unassigned_subnets", "percent_unassigned_subnets", "percent_ip_allocated_include_reserved", "percent_ip_allocated_exclude_reserved"), array($cust, $ds->getCustomerDescrip($cust), $start, $end, $cnt, round($cntsubsize / ($endnum - $startnum + 1) * 100, 2), $cntfree, round($cntfreesubsize / ($endnum - $startnum + 1) * 100, 2), round($used / ($endnum - $startnum + 1) * 100, 2), round(($used - $cntsubnets * 2) / ($endnum - $startnum + 1) * 100, 2))));
$export->createExportForm($w, NULL);
Example #13
0
$auth = new SQLAuthenticator(REALM, REALMERROR);
// And now perform the authentication
$auth->authenticate();
// set language
isset($_COOKIE["ipplanLanguage"]) && myLanguage($_COOKIE['ipplanLanguage']);
//setdefault("window",array("bgcolor"=>"white"));
$title = my_("Ping results");
newhtml($p);
$w = myheading($p, $title, true);
// explicitly cast variables as security measure against SQL injection
list($lookup) = myRegister("S:lookup");
if (!$_GET) {
    myError($w, $p, my_("You cannot reload or bookmark this page!"));
}
if (testIP($lookup)) {
    myError($w, $p, my_("Invalid IP address"));
}
function callback($buffer)
{
    return $buffer;
}
// need to print at this stage as display data is cached via layout template
// buffer the output and do some tricks to place system call output in correct
// place
ob_start("callback");
printhtml($p);
$buf = ob_get_contents();
ob_end_clean();
// now print first half of HTML to browser - split at start of "normalbox"
list($beg, $end) = spliti('CLASS="normalbox">', $buf);
echo $beg;
Example #14
0
    $export->addRow(NULL);
    setdefault("cell", array("class" => color_flip_flop()));
    insert($t, $c = cell());
    // no point in making this a hyperlink - there are no ranges so search will
    // always return nothing!
    insert($c, text(inet_ntoa($row["areaaddr"])));
    $export->addCell(inet_ntoa($row["areaaddr"]));
    insert($t, $c = cell());
    insert($c, text($row["adescrip"]));
    $export->addCell($row["adescrip"]);
    $export->addCell(my_("No range"));
    $export->addCell("");
    $export->addCell("");
    $export->addCell(my_("No range in this area"));
    $export->saveRow();
    insert($t, $c = cell());
    insert($c, block("<small>"));
    insert($c, anchor("deletearea.php?areaindex=" . $row["areaindex"] . "&cust=" . $cust, my_("Delete Area"), $ipplanParanoid ? array("onclick" => "return confirm('" . my_("Are you sure?") . "')") : FALSE));
    insert($c, block(" | "));
    insert($c, anchor("createarea.php?action=modify&areaindex=" . $row["areaindex"] . "&ipaddr=" . inet_ntoa($row["areaaddr"]) . "&cust=" . $cust . "&descrip=" . urlencode($row["adescrip"]), my_("Modify Area")));
    insert($c, block("</small>"));
    $cnt++;
}
insert($w, block("<p>"));
insert($w, textb(sprintf(my_("Total records: %u"), $cnt)));
$temp2 = $cnt;
$result->Close();
// create the export view form
$export->setInfo(array(array("customer_ID", "customer_description", "total_ranges_and_areas_with_ranges", "total_areas_without_ranges"), array($cust, $ds->getCustomerDescrip($cust), $temp1, $temp2)));
$export->createExportForm($w, NULL);
printhtml($p);
Example #15
0
function searchOverlap($ds, &$w, $cust1, $cust2)
{
    global $block;
    // dont trust variables
    $cust1 = floor($cust1);
    $cust2 = floor($cust2);
    $custdescrip1 = $ds->GetCustomerDescrip($cust1);
    $custdescrip2 = $ds->GetCustomerDescrip($cust2);
    // this query is not quick as indexes cannot be used!!!
    // must have first baseaddr called baseaddr else block pager
    // will not work - may break databases other than mysql
    $result =& $ds->ds->Execute("SELECT t1.baseaddr AS baseaddr,\n                           t1.baseindex AS baseindex1,\n                           t1.subnetsize AS subnetsize1,\n                           t1.descrip AS descrip1,\n                           t2.baseaddr AS baseaddr2,\n                           t2.baseindex AS baseindex2,\n                           t2.subnetsize AS subnetsize2,\n                           t2.descrip AS descrip2\n                        FROM base t1, base t2\n                        WHERE ((t1.baseaddr BETWEEN t2.baseaddr AND\n                                t2.baseaddr+t2.subnetsize-1) OR\n                               (t1.baseaddr+t1.subnetsize-1\n                                BETWEEN t2.baseaddr AND\n                                        t2.baseaddr+t2.subnetsize-1) OR\n                               (t1.baseaddr < t2.baseaddr AND\n                                t1.baseaddr+t1.subnetsize >\n                                t2.baseaddr+t2.subnetsize)) AND\n                               t1.customer={$cust1} AND\n                                t2.customer={$cust2}\n                        ORDER BY t1.baseaddr");
    $totcnt = 0;
    $vars = "";
    // fastforward till first record if not first block of data
    while ($block and $totcnt < $block * MAXTABLESIZE and $row = $result->FetchRow()) {
        $vars = DisplayBlock($w, $row, $totcnt, "&cust1[]=" . $cust1 . "&cust2[]=" . $cust2);
        $totcnt++;
    }
    insert($w, block("<p>"));
    $cnt = 0;
    while ($row = $result->FetchRow()) {
        // draw heading only if there are records to display
        if ($cnt == 0) {
            // create a table
            insert($w, $t = table(array("cols" => "8", "class" => "outputtable")));
            // draw heading
            setdefault("cell", array("class" => "heading"));
            insert($t, $c = cell(array("colspan" => "4")));
            insert($c, block("<center>"));
            insert($c, text($custdescrip1));
            insert($c, block("</center>"));
            insert($t, $c = cell(array("colspan" => "4")));
            insert($c, block("<center>"));
            insert($c, text($custdescrip2));
            insert($c, block("</center>"));
            insert($t, $c = cell());
            if (!empty($vars)) {
                insert($c, anchor($vars, "<<"));
            }
            insert($c, text(my_("Base address")));
            insert($t, $c = cell());
            insert($c, text(my_("Subnet size")));
            insert($t, $c = cell());
            insert($c, text(my_("Subnet mask")));
            insert($t, $c = cell());
            insert($c, text(my_("Description")));
            insert($t, $c = cell());
            insert($c, text(my_("Base address")));
            insert($t, $c = cell());
            insert($c, text(my_("Subnet size")));
            insert($t, $c = cell());
            insert($c, text(my_("Subnet mask")));
            insert($t, $ck = cell());
            insert($ck, text(my_("Description")));
            setdefault("cell", array("class" => color_flip_flop()));
        }
        // customer 1
        if ($row["subnetsize1"] == 1) {
            insert($t, $c = cell());
            insert($c, text(inet_ntoa($row["baseaddr"])));
        } else {
            insert($t, $c = cell());
            insert($c, anchor("displaysubnet.php?baseindex=" . $row["baseindex1"], inet_ntoa($row["baseaddr"])));
        }
        if ($row["subnetsize1"] == 1) {
            insert($t, $c = cell());
            insert($c, text("Host"));
        } else {
            insert($t, $c = cell());
            insert($c, text($row["subnetsize1"]));
        }
        insert($t, $c = cell());
        insert($c, text(inet_ntoa(inet_aton(ALLNETS) + 1 - $row["subnetsize1"]) . "/" . inet_bits($row["subnetsize1"])));
        insert($t, $c = cell());
        insert($c, text($row["descrip1"]));
        // customer 2
        if ($row["subnetsize2"] == 1) {
            insert($t, $c = cell());
            insert($c, text(inet_ntoa($row["baseaddr2"])));
        } else {
            insert($t, $c = cell());
            insert($c, anchor("displaysubnet.php?baseindex=" . $row["baseindex2"], inet_ntoa($row["baseaddr2"])));
        }
        if ($row["subnetsize2"] == 1) {
            insert($t, $c = cell());
            insert($c, text(my_("Host")));
        } else {
            insert($t, $c = cell());
            insert($c, text($row["subnetsize2"]));
        }
        insert($t, $c = cell());
        insert($c, text(inet_ntoa(inet_aton(ALLNETS) + 1 - $row["subnetsize2"]) . "/" . inet_bits($row["subnetsize2"])));
        insert($t, $c = cell());
        insert($c, text($row["descrip2"]));
        if ($totcnt % MAXTABLESIZE == MAXTABLESIZE - 1) {
            break;
        }
        $cnt++;
        $totcnt++;
    }
    insert($w, block("<p>"));
    if ($cnt) {
        $vars = "";
        $printed = 0;
        while ($row = $result->FetchRow()) {
            $totcnt++;
            $vars = DisplayBlock($w, $row, $totcnt, "&cust1[]=" . $cust1 . "&cust2[]=" . $cust2);
            if (!empty($vars) and !$printed) {
                insert($ck, anchor($vars, ">>"));
                $printed = 1;
            }
        }
    }
}
Example #16
0
 function Search()
 {
     unset($this->vars[$this->frmvar]);
     unset($this->vars["block"]);
     unset($this->vars["expr"]);
     //    $url=my_http_build_query($vars);
     // start form
     insert($this->w, $f = form(array("name" => "SEARCH", "method" => $this->method, "action" => $_SERVER["PHP_SELF"])));
     insert($f, $con = container("fieldset", array("class" => "fieldset")));
     insert($con, $legend = container("legend", array("class" => "legend")));
     insert($legend, text($this->legend));
     if ($this->expr_disp) {
         $lst = array("START" => my_("Starts with"), "END" => my_("Ends with"), "LIKE" => my_("Contains"), "NLIKE" => my_("Does not contain"), "EXACT" => my_("Equal to"));
         if (DBF_TYPE == "mysql" or DBF_TYPE == "maxsql" or DBF_TYPE == "postgres7") {
             $lst["RLIKE"] = my_("Regex contains");
         }
         // only supported by mysql
         if (DBF_TYPE == "mysql" or DBF_TYPE == "maxsql") {
             $lst["NRLIKE"] = my_("Does not regex contain");
         }
         insert($con, selectbox($lst, array("name" => "expr"), $this->expr));
     }
     insert($con, input_text(array("name" => $this->frmvar, "value" => $this->search, "size" => "20", "maxlength" => "80")));
     foreach ($this->vars as $key => $value) {
         insert($con, hidden(array("name" => "{$key}", "value" => "{$value}")));
     }
     insert($con, submit(array("value" => my_("Submit"))));
     insert($con, block(" <a href='#' onclick='SEARCH." . $this->frmvar . ".value=\"\"; SEARCH.submit();'>" . my_("Reset Search") . "</a>"));
 }
Example #17
0
    } while ($row = $result->FetchRow());
    insert($w, block("<p>"));
    printhtml($p);
    exit;
}
// check if customer has DNS information (forward zone)
$result =& $ds->ds->SelectLimit("SELECT customer\n                           FROM fwdzone\n                           WHERE customer={$cust}", 1);
if ($row = $result->FetchRow()) {
    insert($w, text(my_("Cannot delete customer because customer has DNS zones defined")));
    insert($w, block("<p>"));
    printhtml($p);
    exit;
}
// check if customer has DNS information (reverse zone)
$result =& $ds->ds->SelectLimit("SELECT customer\n                           FROM zones\n                           WHERE customer={$cust}", 1);
if ($row = $result->FetchRow()) {
    insert($w, text(my_("Cannot delete customer because customer has reverse DNS zones defined")));
    insert($w, block("<p>"));
    printhtml($p);
    exit;
}
$ds->DbfTransactionStart();
// these deletes also appear in the admin/maintenance script!
$result =& $ds->ds->Execute("DELETE FROM customer\n                        WHERE customer={$cust}") and $result =& $ds->ds->Execute("DELETE FROM custinfo\n                        WHERE customer={$cust}") and $result =& $ds->ds->Execute("DELETE FROM custadd\n                        WHERE customer={$cust}") and $result =& $ds->ds->Execute("DELETE FROM revdns\n                        WHERE customer={$cust}") and $result =& $ds->ds->Execute("DELETE FROM area\n                        WHERE customer={$cust}") and $result =& $ds->ds->Execute("DELETE FROM netrange\n                        WHERE customer={$cust}") and $result =& $ds->ds->Execute("DELETE FROM fwdzone\n                        WHERE customer={$cust}") and $result =& $ds->ds->Execute("DELETE FROM fwdzoneadd\n                        WHERE customer={$cust}") and $result =& $ds->ds->Execute("DELETE FROM fwdzonerec\n                        WHERE customer={$cust}") and $result =& $ds->ds->Execute("DELETE FROM zones\n                        WHERE customer={$cust}") and $ds->AuditLog(array("event" => 182, "action" => "delete customer", "user" => getAuthUsername(), "cust" => $cust));
if ($result) {
    $ds->DbfTransactionEnd();
    insert($w, text(my_("Customer deleted")));
} else {
    insert($w, text(my_("Customer could not be deleted")));
}
printhtml($p);
Example #18
0
insert($q, textbr(my_("IF YOU ARE UPGRADING IPPLAN, BACKUP YOUR DATABASE NOW")));
insert($q, textbr(my_("THERE IS NO WAY TO RECOVER YOUR DATA IF SOMETHING GOES WRONG.")));
insert($q, generic("p"));
insert($q, textbr(my_("THE DISPLAY TEMPLATES HAVE MOVED TO A DIFFERENT DIRECTORY - READ THE CHANGELOG AND UPGRADE DOC")));
insert($w, $t = container("div", array("class" => "MrMagooInstall")));
insert($t, $s = container("ul"));
insert($s, $l1 = container("li"));
insert($l1, textb(my_("For security purposes, it is highly recomended that IPPlan is installed on an SSL Webserver.")));
insert($s, generic("br"));
insert($s, $l2 = container("li"));
insert($l2, textb(my_("Production systems need to use a transaction-aware database table. Do not use MYISAM (use INNODB) and enable it in config.php")));
insert($s, generic("br"));
insert($s, $l3 = container("li"));
insert($l3, textb(my_("Read all Instructions carefully before proceeding!")));
insert($w, generic("br"));
insert($w, block(my_("Have you read the <a href=\"http://iptrack.sourceforge.net/doku.php?id=faq\">FAQ</a>? How about the <a href=\"http://iptrack.sourceforge.net/documentation/\">User Manual</a>? ")));
insert($w, text(my_("Have you read the UPGRADE document if upgrading?")));
insert($w, generic("br"));
insert($w, generic("br"));
insert($w, textbrbr(my_("What would you like to do today?")));
insert($w, $f = form(array("name" => "THISFORM", "method" => "POST", "action" => "schemacreate.php")));
insert($f, selectbox(array("0" => "Upgrade", "1" => "New Installation"), array("name" => "new")));
insert($f, generic("br"));
insert($f, generic("br"));
insert($f, textbr(my_("Would you like us to run the SQL against the database defined in config.php or would you rather print it to the screen so you can do it yourself?")));
insert($f, selectbox(array("0" => my_("Run the SQL Now"), "1" => my_("Just print it to the screen")), array("name" => my_("display"))));
insert($f, generic("br"));
insert($f, textbr(my_("If you are displaying the schema, please remove the comments with a text editor before executing into your database.")));
insert($f, generic("br"));
insert($f, submit(array("value" => my_("Go!"))));
printhtml($p);
Example #19
0
    $cnt++;
    $totcnt++;
}
insert($w, block("<p>"));
$vars = "";
$printed = 0;
while ($row = $result->FetchRow()) {
    $totcnt++;
    $vars = DisplayBlock($w, $row, $totcnt, "&descrip=" . urlencode($descrip), "dt");
    if (!empty($vars) and !$printed) {
        insert($ck, anchor($vars, ">>"));
        $printed = 1;
    }
}
insert($w, block("<p>"));
insert($w, text(my_("Total records:") . " " . $cnt));
/*
include_once('../adodb/adodb-pager.inc.php');
$sql = "SELECT userid, action, dt FROM auditlog ORDER BY dt DESC";

function callback($buffer) {
    return ($buffer);
}

// need to print at this stage as display data is cached via layout template
// buffer the output and do some tricks to place system call output in correct
// place
ob_start("callback");

$pager = new ADODB_Pager($ds->ds,$sql);
//$pager->htmlSpecialChars = false;
Example #20
0
            insert($ck, anchor($vars, ">>"));
            $printed = 1;
        }
    }
    //create the export view form
    $export->setInfo(array(array("maintenance_page"), array("request index")));
    $export->createExportForm($w, NULL);
}
// display opening text
insert($w, heading(3, "{$title}."));
insert($w, textbr(my_("Perform the selected IPplan database maintenance.")));
// start form
insert($w, $f = form(array("method" => "post", "action" => $_SERVER["PHP_SELF"])));
insert($f, hidden(array("name" => "action", "value" => "custindex")));
insert($f, generic("p"));
insert($f, submit(array("value" => my_("Display list of customer indexes"))));
// start form
insert($w, $f = form(array("method" => "post", "action" => $_SERVER["PHP_SELF"])));
insert($f, hidden(array("name" => "action", "value" => "reqindex")));
insert($f, generic("p"));
insert($f, submit(array("value" => my_("View request list"))));
// start form
insert($w, $f = form(array("method" => "post", "action" => $_SERVER["PHP_SELF"])));
insert($f, hidden(array("name" => "action", "value" => "deleterequest")));
insert($f, submit(array("value" => my_("Clear IP address request list"))));
// start form
insert($w, $f = form(array("method" => "post", "action" => $_SERVER["PHP_SELF"])));
insert($f, hidden(array("name" => "action", "value" => "deleteaudit")));
insert($f, generic("p"));
insert($f, submit(array("value" => my_("Clear Audit Log"))));
printhtml($p);
Example #21
0
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
require_once "config.php";
require_once "schema.php";
require_once "ipplanlib.php";
require_once "layout/class.layout";
// check for latest variable added to config.php file, if not there
// user did not upgrade properly
if (!defined("CONFIG_DIR")) {
    die("Your config.php file is inconsistent - you cannot use your old config.php file during upgrade");
}
// set language
isset($_COOKIE["ipplanLanguage"]) && myLanguage($_COOKIE['ipplanLanguage']);
CheckSchema();
newhtml($p);
insert($p, block("<script type=\"text/javascript\">\n</script>\n<noscript>\n<p><b>\n<font size=4 color=\"#FF0000\">\nYour browser must be JavaScript capable to use this application. Please turn JavaScript on.\n</font>\n</b>\n</noscript>\n"));
$w = myheading($p, my_("Main Menu"));
insert($w, block(my_("IPplan is a free (GPL), web based, multilingual, IP address management and tracking tool written in php 4, " . "simplifying the administration of your IP address space. IPplan goes beyond IP address management including DNS administration, " . "configuration file management, circuit management (customizable via templates) and storing of hardware information " . "(customizable via templates). IPplan can handle a single network or cater for multiple networks and customers with overlapping address space.")));
printhtml($p);
?>
 
Example #22
0
                        if ($baseindex = $ds->CreateSubnet($base, $size, $descrip, $cust, 0, $admingrp)) {
                            $ds->AuditLog(sprintf(my_("User %s created new subnet %s size %u cust %u"), getAuthUsername(), inet_ntoa($base), $size, $cust));
                            // Changed - Begin [FE]
                            // Start of template support for base
                            if (!empty($info)) {
                                // First, try to insert.
                                $result =& $ds->ds->Execute("INSERT INTO baseadd\n                           (info, baseindex)\n                           VALUES\n                           (" . $ds->ds->qstr($info) . ",\n                            {$baseindex})");
                                // Second, try to update.
                                if ($result == FALSE) {
                                    $result =& $ds->ds->Execute("UPDATE baseadd\n                               SET info=" . $ds->ds->qstr($info) . "                                 \n                               WHERE baseindex={$baseindex}");
                                    if ($result == FALSE) {
                                        insert($w, block("<b>" . my_("Error inserting/updating info.") . "</b>"));
                                    }
                                }
                            }
                            // End of template support for base
                            // Changed - End [FE]
                        } else {
                            insert($w, text(my_("Subnet could not be created")));
                            break;
                        }
                    }
                }
            }
        }
    }
}
// commit whatever has already been written
$ds->DbfTransactionEnd();
fclose($fp);
printhtml($p);
Example #23
0
 function return_templ_name()
 {
     //echo "<pre>";var_dump($this->userfld);echo "</pre>";
     $tmpl_def = array();
     $tmpl_def["any"] = my_("Any");
     foreach ($this->userfld as $field => $val) {
         //echo "<pre>";var_dump($val["descrip"]);echo "</pre>";
         $tmpl_def[$field] = $val["descrip"];
     }
     //echo "<pre>";var_dump($tmpl_def);echo "</pre>";
     return $tmpl_def;
 }
Example #24
0
        $result = '';
        while (!feof($fp)) {
            $result .= fgets($fp, 128);
        }
        fclose($fp);
    }
    return $result;
}
// set language
isset($_COOKIE["ipplanLanguage"]) && myLanguage($_COOKIE['ipplanLanguage']);
//setdefault("window",array("bgcolor"=>"white"));
$title = my_("WHOIS results");
newhtml($p);
$w = myheading($p, $title, true);
// explicitly cast variables as security measure against SQL injection
list($lookup) = myRegister("S:lookup");
if (!$_GET) {
    myError($w, $p, my_("You cannot reload or bookmark this page!"));
}
//$data = $whois->lookup($lookup);
$data = whois(WHOISSERVER, $lookup);
if (!$data) {
    myError($w, $p, my_("Whois query failed - are you behind a firewall?"));
} else {
    /*   $data = preg_replace("/\((.*?)\)/", 
                            "<a href='whois.php?lookup=\\1'>(\\1)</a>", 
                            $data);
    */
    insert($w, block("<pre>" . htmlspecialchars($data) . "</pre>"));
}
printhtml($p);
Example #25
0
 function FetchBase($cust, $areaindex, $rangeindex)
 {
     // use local function variables as they may change
     $this->cust = $cust;
     $this->rangeindex = $rangeindex;
     $this->areaindex = $areaindex;
     // set start and end address according to netrange
     if ($this->rangeindex) {
         // should only return one row here!
         $result = $this->GetRange($this->cust, $this->rangeindex);
         $row = $result->FetchRow();
         $this->start = inet_ntoa($row["rangeaddr"]);
         $this->end = inet_ntoa($row["rangeaddr"] + $row["rangesize"] - 1);
         $this->site = " (" . $row["descrip"] . ")";
     } else {
         if ($this->ipaddr) {
             if ($this->subnetsize) {
                 $this->start = $this->ipaddr;
                 $this->end = inet_ntoa(inet_aton($this->ipaddr) + $this->subnetsize - 1);
             } else {
                 $this->start = completeIP($this->ipaddr, 1);
                 $this->end = completeIP($this->ipaddr, 2);
             }
             if (testIP($this->start) or testIP($this->end)) {
                 $this->err = 50;
                 // Invalid IP address!
                 $this->errstr = my_("Invalid IP address!");
                 return FALSE;
             }
         } else {
             $this->start = DEFAULTROUTE;
             $this->end = ALLNETS;
         }
     }
     $startnum = inet_aton($this->start);
     $endnum = inet_aton($this->end);
     // pager could have made cust = 0
     if ($this->cust == 0) {
         $this->custdescrip = "All";
     } else {
         $this->custdescrip = $this->GetCustomerDescrip($this->cust);
     }
     if (strtolower($this->custdescrip) == "all") {
         $this->cust = 0;
     }
     if ($this->areaindex == -1) {
         // all subnets not part of an area
         $result = $this->GetBaseNoArea($this->descrip, $this->cust, $this->grps);
     } else {
         if ($this->areaindex and !$this->rangeindex) {
             $result = $this->GetBaseFromArea($this->areaindex, $this->descrip, $this->cust, $this->grps);
         } else {
             // search in subnet - finds subnets with exact ip address match
             // useful for finding from where an attack comes if you have IP
             if ($this->searchin == 0) {
                 $result = $this->GetBase($startnum, $endnum, $this->descrip, $this->cust, $this->grps);
             } else {
                 if ($this->cust == 0) {
                     $result = $this->GetDuplicateSubnetAll($startnum, 1, $this->grps);
                 } else {
                     $result = $this->GetDuplicateSubnet($startnum, 1, $this->cust);
                 }
             }
         }
     }
     return $result;
 }
Example #26
0
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
$ADMIN_MENU = ".|" . my_("Main") . "|{$BASE_URL}/index.php\n.|" . my_("Customers") . "\n..|" . my_("Create a New Customer/Autonomous System") . "|{$BASE_URL}/user/modifycustomer.php\n..|" . my_("Edit Existing Customer/Autonomous System") . "|{$BASE_URL}/user/displaycustomerform.php\n.|" . my_("Network") . "\n..|" . my_("Hierarchy") . "\n...|" . my_("Create a new Network Area") . "|{$BASE_URL}/user/createarea.php\n...|" . my_("Create a new Network Range/Supernet") . "|{$BASE_URL}/user/createrange.php\t\n...|" . my_("Display/Modify/Delete Ranges/Supernets") . "|{$BASE_URL}/user/modifyarearangeform.php\n";
if (REGENABLED) {
    $ADMIN_MENU .= "\n..|" . my_("Registrar") . "\n...|" . my_("Display Registrar Information") . "|{$BASE_URL}/user/displayswipform.php\n";
}
$ADMIN_MENU .= "\n..|" . my_("Subnets") . "\n...|" . my_("Create Subnet") . "|{$BASE_URL}/user/createsubnetform.php\n...|" . my_("Create from Routing Table") . "|{$BASE_URL}/user/displayrouterform.php\n...|" . my_("Delete/Edit/Modify/Split/Join Subnet") . "|{$BASE_URL}/user/modifybaseform.php\n...|" . my_("Display Subnet Information") . "|{$BASE_URL}/user/displaybaseform.php\n...|" . my_("Display Subnet Information - Tree") . "|{$BASE_URL}/user/treeview.php\n...|" . my_("Search All Subnets") . "|{$BASE_URL}/user/searchallform.php\n...|" . my_("Find Free Space") . "|{$BASE_URL}/user/findfreeform.php\n...|" . my_("Display Subnet Overlap") . "|{$BASE_URL}/user/displayoverlapform.php\n..|" . my_("Request an IP address") . "|{$BASE_URL}/user/requestip.php\n";
if (DNSENABLED) {
    $ADMIN_MENU .= "\n.|" . my_("DNS") . "\n..|" . my_("Create/Modify/Export Zone Domains") . "|{$BASE_URL}/user/modifydns.php\n..|" . my_("Create/Modify Zone DNS Records") . "|{$BASE_URL}/user/modifydnsrecord.php\n..|" . my_("Create/Modify Reverse DNS Records") . "|{$BASE_URL}/user/modifyzone.php\n";
}
$ADMIN_MENU .= "\n.|" . my_("Options") . "\n..|" . my_("Settings") . "|{$BASE_URL}/user/changesettings.php\n..|" . my_("Change my Password") . "|{$BASE_URL}/admin/changepassword.php\n.|" . my_("Admin") . "\n..|" . my_("Users") . "\n...|" . my_("Create a new User") . "|{$BASE_URL}/admin/usermanager.php?action=newuserform\n...|" . my_("Add a user to Group") . "|{$BASE_URL}/admin/usermanager.php\n...|" . my_("Display/Edit Users") . "|{$BASE_URL}/admin/usermanager.php\n..|" . my_("Groups") . "\n...|" . my_("Create a new Group") . "|{$BASE_URL}/admin/usermanager.php?action=newgroupform\n...|" . my_("Add Authority Bounderies to Group") . "|{$BASE_URL}/admin/usermanager.php\n...|" . my_("Display/Modify Authority Boundary Info") . "|{$BASE_URL}/admin/displayboundsform.php\n..|" . my_("Import") . "\n...|" . my_("Import Subnet Descriptions") . "|{$BASE_URL}/admin/importbaseform.php\n...|" . my_("Import IP Address Detail Records") . "|{$BASE_URL}/admin/importipform.php\n..|" . my_("Export") . "\n...|" . my_("Export Subnet Descriptions") . "|{$BASE_URL}/admin/exportbaseform.php\n...|" . my_("Export IP Address Detail Records") . "|{$BASE_URL}/admin/exportipform.php\n..|" . my_("Maintenance") . "|{$BASE_URL}/admin/maintenance.php\n..|" . my_("Display Audit Log") . "|{$BASE_URL}/admin/displayauditlog.php\n.|" . my_("Help") . "\n..|" . my_("Online Manual") . "|http://iptrack.sourceforge.net/ \n..|" . my_("Support Groups") . "|http://sourceforge.net/forum/?group_id=32122\n..|" . my_("Home Page") . "|http://sourceforge.net/projects/iptrack/\n..|" . my_("License") . "|{$BASE_URL}/license.php\n";
// add menu extensions
if (MENU_PRIV) {
    $ADMIN_MENU .= MENU_EXTENSION;
}
if (AUTH_LOGOUT) {
    $ADMIN_MENU .= ".|" . my_("Logout") . "|{$BASE_URL}/user/logout.php\n";
}
Example #27
0
    if ($totcnt % MAXTABLESIZE == MAXTABLESIZE - 1) {
        break;
    }
    $cnt++;
    $totcnt++;
}
insert($w, block("<p>"));
$vars = "";
$printed = 0;
while ($row = $result->FetchRow()) {
    $totcnt++;
    $vars = DisplayBlock($w, $row, $totcnt, "&domain=" . urlencode($domain) . "&cust=" . $cust . "&expr={$expr}&descrip=" . urlencode($descrip), "domain");
    if (!empty($vars) and !$printed) {
        insert($ck, anchor($vars, ">>"));
        $printed = 1;
    }
}
insert($w, block("<p>"));
if ($cnt) {
    insert($w, anchor($_SERVER["PHP_SELF"] . "?cust={$cust}&dataid=0&action=export", my_("Export all changed DNS Zones"), $ipplanParanoid ? array("onclick" => "return confirm('" . my_("Are you sure to Export?") . "')") : FALSE));
} else {
    myError($w, $p, my_("Search found no DNS Zone entries"), FALSE);
}
insert($w, $f = form(array("method" => "post", "action" => "modifydnsform.php?cust={$cust}&action=add")));
insert($f, submit(array("value" => my_("Add a DNS Zone"))));
$result->Close();
// create the export view form
$expression = $export->translateExpr($expr);
$export->setInfo(array(array("customer_ID", "customer_description", "search_criterion", "search_expression"), array($cust, $ds->getCustomerDescrip($cust), $expression, $descrip)));
$export->createExportForm($w, $template);
printhtml($p);
Example #28
0
                $menustring = $menustring . "...|" . htmlspecialchars(inet_ntoa($rangerow["rangeaddr"]) . " (" . $rangerow["descrip"] . ")") . "|displaybase.php?cust=" . $custrow["customer"] . "&areaindex=" . $arearow["areaindex"] . "&rangeindex=" . $rangerow["rangeindex"] . "&descrip=&sortby=Base+Address" . "||||\n";
                $baseresult = $ds->GetBase($rangerow["rangeaddr"], $rangerow["rangeaddr"] + $rangerow["rangesize"] - 1, "", $custrow["customer"]);
                //subnet (base)
                while ($baserow = $baseresult->Fetchrow()) {
                    $menustring = $menustring . "....|" . htmlspecialchars(inet_ntoa($baserow["baseaddr"]) . " /" . inet_bits($baserow["subnetsize"]) . " (" . $baserow["descrip"] . ")") . "|displaysubnet.php?baseindex=" . $baserow["baseindex"] . "||||\n";
                }
            }
        }
    }
    $mid = new TreeMenu();
    $mid->setDirroot('../menus');
    $mid->setLibjsdir('../menus/libjs/');
    $mid->setImgdir('../menus/menuimages/');
    $mid->setImgwww('../menus/menuimages/');
    $mid->setIcondir('../menus/menuicons/');
    $mid->setIconwww('../menus/menuicons/');
    if (!$menustring) {
        myError($w, $p, my_("No customers"));
    }
    $mid->setMenuStructureString($menustring);
    $mid->setIconsize(16, 16);
    $mid->parseStructureForMenu('treemenu1');
    $mid->newTreeMenu('treemenu1');
    insert($leftmenu, block('<br><br>'));
    insert($leftmenu, block($mid->getTreeMenu('treemenu1')));
    insert($leftmenu, block('<br><br>'));
}
printhtml($p);
?>
 
Example #29
0
require_once "../adodb/adodb.inc.php";
require_once "../class.dbflib.php";
require_once "../auth.php";
require_once "../class.templib.php";
$auth = new BasicAuthenticator(ADMINREALM, REALMERROR);
$auth->addUser(ADMINUSER, ADMINPASSWD);
// And now perform the authentication
$auth->authenticate();
// save the last customer used
// must set path else Netscape gets confused!
setcookie("ipplanCustomer", "{$cust}", time() + 10000000, "/");
// basic sequence is connect, search, interpret search
// result, close connection
// explicitly cast variables as security measure against SQL injection
list($cust) = myRegister("I:cust");
$ds = new IPplanDbf() or die(my_("Could not connect to database"));
// force file download due to bad mime type
header("Content-Type: bad/type");
header("Content-Disposition: attachment; filename=base.txt");
header("Pragma: no-cache");
header("Expires: 0");
$startnum = inet_aton(DEFAULTROUTE);
$endnum = inet_aton(ALLNETS);
// if a specific network template exists, use that, else use generic template
$template = new IPplanIPTemplate("basetemplate", $cust);
$err = $template->is_error();
$result = $ds->GetBase($startnum, $endnum, '', $cust);
while ($row = $result->FetchRow()) {
    echo inet_ntoa($row["baseaddr"]) . FIELDS_TERMINATED_BY . $row["descrip"] . FIELDS_TERMINATED_BY . inet_ntoa(inet_aton(ALLNETS) + 1 - $row["subnetsize"]) . FIELDS_TERMINATED_BY;
    if (!$err) {
        $result_template =& $ds->ds->Execute("SELECT info, infobin\n                FROM baseadd\n                WHERE baseindex=" . $row["baseindex"]);
Example #30
0
function UpdateLnk($ds, $w, $cust, $baseindex, $lnk, $ip)
{
    /*
    // got link address, see if there is a subnet for this link
    // if no subnet found, do nothing
    $result=$ds->GetBaseFromIndex($baseindex);
    $row = $result->FetchRow();
    $cust=$row["customer"];
    */
    $result = $ds->GetBaseFromIP(inet_aton($lnk), $cust);
    // yep found one, now see if a record exists
    if ($row = $result->FetchRow()) {
        $lnkidx = $row["baseindex"];
        if (!$ds->TestCustomerGrp($lnkidx, getAuthUsername())) {
            return sprintf(my_("Destination linked address %s IP record not created as you are not a member of the customers admin group"), $lnk) . "\n";
        }
        if (!($result = $ds->GetIPDetails($lnkidx, inet_aton($lnk)))) {
            // no row in subnet, then add one
            // NEED TO CHECK DESTINATION OWNERSHIP BEFORE ADDING RECORD
            $ds->ModifyIP(inet_aton($lnk), $lnkidx, "", "", "", "", "Linked address from " . inet_ntoa($ip), "", "");
            insert($w, textbr(sprintf(my_("Destination linked address %s IP record created"), $lnk)));
        }
    }
}