コード例 #1
0
ファイル: func.occi.php プロジェクト: swkim85/EGIFedCloudWeb
 function Update_Resource_Template($siteid, $lists)
 {
     $this->_debug("Update_Resource_Template....");
     $ctype = 'RES';
     $qry = "DELETE FROM {$this->tbl} WHERE siteid='{$siteid}' AND ctype='{$ctype}'";
     $this->_debug($qry);
     $ret = myQuery($qry);
     foreach ($lists as $uri) {
         list($prefix, $uuid) = preg_split("/#/", $uri);
         //$flag = false;
         //if (preg_match("/os_tpl/", $prefix)) $flag = true;
         //if (preg_match("/template.os/", $prefix)) $flag = true;
         //if (!$flag) continue;
         $s = array();
         $s[] = "siteid='{$siteid}'";
         $s[] = "uri='{$uri}'";
         $s[] = "hash='{$hash}'";
         $s[] = "ctype='{$ctype}'";
         $s[] = "idate=now()";
         $s[] = "udate=now()";
         $sql_set = " SET " . join(",", $s);
         $qry = "INSERT INTO {$this->tbl} {$sql_set}";
         $ret = myQuery($qry);
         $err = myError();
         if ($err) {
             print $qry . $err;
         }
     }
 }
コード例 #2
0
ファイル: create.php プロジェクト: swkim85/EGIFedCloudWeb
function _insert_vminfo($siteid, $osid, $resid, $name, $vmurl, $title)
{
    $qry = "INSERT INTO vminfo" . " SET siteid='{$siteid}', osid='{$osid}', resid='{$resid}', vmname='{$name}', vmurl='{$vmurl}', title='{$title}', createTime=NOW()";
    //dd($qry);
    $ret = myQuery($qry);
    print myError();
}
コード例 #3
0
ファイル: displayrouter.php プロジェクト: hetznerZA/ipplan
function GetRoutingTable($host, $community, $rtrtype)
{
    global $w, $p;
    $OID = array("generic" => ".1.3.6.1.2.1.4.21.1.11", "riverstone" => ".1.3.6.1.2.1.4.24.4", "juniper" => ".1.3.6.1.2.1.4.24.4.1");
    if (!extension_loaded("snmp")) {
        myError($w, $p, "no snmp!!! - compile php with --with-snmp --enable-ucd-snmp-hack");
        exit;
    }
    if (strpos(strtoupper(PHP_OS), 'WIN') !== false) {
        // Windows snmp different
    } else {
        // Unix snmp different - need to set quickprint to be compatible
        // with Windows format. Windows does not have long print format
        // must test for os version as undefined function generates error
        // even with @
        snmp_set_quick_print(1);
    }
    // protect against bad users!
    if (!array_key_exists($rtrtype, $OID)) {
        $rtrtype = "generic";
    }
    $routes = @snmpwalkoid($host, $community, $OID[$rtrtype]);
    if (!$routes) {
        return 0;
    }
    for (reset($routes); $network = key($routes); next($routes)) {
        //here is the way to do it with RFC 2096 using ipCidrRouteMask
        //this is what we get back from the riverstone
        //meaning:  subnet IP, subnet mask, destination = ip destination ip
        if ($rtrtype == "riverstone") {
            //kill the destination
            list($oc1, $oc2, $oc3, $oc4, $oc5, $rest) = explode(".", strrev($network), 6);
            //take the subnetmask
            list($oc1, $oc2, $oc3, $oc4, $rest) = explode(".", $rest, 5);
            $mask = strrev(sprintf("%s.%s.%s.%s", $oc1, $oc2, $oc3, $oc4));
            //take the subnet addr
            list($oc1, $oc2, $oc3, $oc4, $rest) = explode(".", $rest, 5);
            $netaddr = strrev(sprintf("%s.%s.%s.%s", $oc1, $oc2, $oc3, $oc4));
        } else {
            // The Old way to do it with RFC 1213 MIBv2 (which is deprecated)
            // do some magic to obtain a unique, sortable array index to force the results
            // into ip address order. index will be x0000000000 where the digits are the
            // integer representation of the ip address padded with zeros.
            $mask = $routes[$network];
            // strip out last 4 octets from mib value - lots of .'s
            // complicate matters
            list($oc1, $oc2, $oc3, $oc4, $rest) = explode(".", strrev($network), 5);
            $netaddr = strrev(sprintf("%s.%s.%s.%s", $oc1, $oc2, $oc3, $oc4));
        }
        // $ind='x'.str_pad(inet_aton(substr($netaddr, strpos($netaddr, '.')+1)), 10, "0", STR_PAD_LEFT);
        $ind = 'x' . str_pad(inet_aton($netaddr), 10, "0", STR_PAD_LEFT);
        $result["{$ind}"] = array("rtrbase" => $netaddr, "rtrmask" => $mask);
    }
    //"rtrmask"=>substr($mask, strpos($mask, ' ')+1));
    return $result;
}
コード例 #4
0
ファイル: deletecustomer.php プロジェクト: hetznerZA/ipplan
// set language
isset($_COOKIE["ipplanLanguage"]) && myLanguage($_COOKIE['ipplanLanguage']);
//setdefault("window",array("bgcolor"=>"white"));
$title = my_("Delete customer/autonomous system results");
newhtml($p);
$w = myheading($p, $title, true);
// explicitly cast variables as security measure against SQL injection
list($cust) = myRegister("I:cust");
if (!$_GET) {
    myError($w, $p, my_("You cannot reload or bookmark this page!"));
}
// basic sequence is connect, search, interpret search
// result, close connection
$ds = new IPplanDbf() or myError($w, $p, my_("Could not connect to database"));
if (!$ds->TestCustomerCreate(getAuthUsername())) {
    myError($w, $p, my_("You may not delete customers as you are not a member a group that can delete customers"));
}
// check if customer has subnets assigned
$result =& $ds->ds->SelectLimit("SELECT baseaddr, descrip\n                           FROM base\n                           WHERE customer={$cust}\n                           ORDER BY baseaddr", 100);
if ($row = $result->FetchRow()) {
    insert($w, text(my_("Cannot delete customer because the following subnets are assigned to the customer (limited to first 100):")));
    insert($w, block("<p>"));
    // create a table
    insert($w, $t = table(array("cols" => "2", "class" => "outputtable")));
    // draw heading
    setdefault("cell", array("class" => "heading"));
    insert($t, $c = cell());
    insert($c, text(my_("Base address")));
    insert($t, $c = cell());
    insert($c, text(my_("Subnet description")));
    do {
コード例 #5
0
ファイル: importipform.php プロジェクト: hetznerZA/ipplan
// display opening text
insert($w, heading(3, "{$title}."));
insert($w, block("<br>" . my_("Import IP details data in XML format. The data is in the same format generated by <a HREF=\"http://www.insecure.org\">NMAP's</a> -oX parameter. This is useful to scan and obtain records for sites that have no previous information.")));
insert($w, block("<p>"));
insert($w, text(my_("Import IP details data from flat ascii files.  The file should contain a minimum of seven columns each delimited by TAB: ")));
insert($w, text(my_("The columns are imported in the following order: IP address, user, location, description, hostname, telephone number and mac address.")));
insert($w, block("<p>"));
insert($w, text(my_("If the import file has more than seven columns, each additional column will be added to the user defined fields defined in the iptemplate.xml file in the order specified in the template.")));
insert($w, block("<p>"));
insert($w, text(my_("If an error occurs during the import, the process will stop. Records that have been successfully imported should be deleted from the import file, the error corrected and the import resumed.")));
insert($w, block("<p>"));
insert($w, text(my_("NOTE: Any number of IP address records for various subnets can be in the file.  Any existing information will be overwritten.") . " "));
insert($w, text(my_("Imported addresses will only be added to existing subnets.") . " "));
insert($w, textbr(my_("If the merge flag is set, any fields that are empty or contain NULL will not be overwritten.")));
$ds = new IPplanDbf() or myError($w, $p, my_("Could not connect to database"));
// start form
insert($w, $f = form(array("method" => "post", "enctype" => "multipart/form-data", "action" => "importip.php")));
$cust = myCustomerDropDown($ds, $f, 0, 0, FALSE) or myError($w, $p, my_("No customers"));
insert($f, textbrbr(my_("File name")));
insert($f, hidden(array("name" => "MAX_FILE_SIZE", "value" => MAXUPLOADSIZE)));
insert($f, inputfile(array("name" => "userfile")));
insert($f, textbrbr(my_("Format")));
insert($f, selectbox(array("text" => my_("Standard fields - text format"), "xml" => my_("Standard fields - NMAP XML format")), array("name" => "format")));
insert($f, generic("br"));
insert($f, generic("br"));
insert($f, checkbox(array("NAME" => "append"), " " . my_("Merge"), $c = ""));
insert($f, generic("br"));
insert($f, generic("br"));
insert($f, submit(array("value" => my_("Submit"))));
insert($f, freset(array("value" => my_("Clear"))));
printhtml($p);
コード例 #6
0
ファイル: changepassword.php プロジェクト: hetznerZA/ipplan
            $userid = getAuthUsername();
        }
        $password = crypt($password1, 'xq');
        $ds->DbfTransactionStart();
        $result =& $ds->ds->Execute("UPDATE users\n                              SET password="******"\n                              WHERE userid=" . $ds->ds->qstr($userid));
        $ds->AuditLog(sprintf(my_("User %s changed password"), $userid));
        if ($result) {
            $ds->DbfTransactionEnd();
            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!):")));
コード例 #7
0
function controller($user, $request, $response)
{
    try {
        $functions = array('login', 'connect', 'sendMove', 'win');
        $data = json_decode($request, true);
        if (empty($data)) {
            myError($user, $request, $response, 'invalidJSON');
        } else {
            if (!in_array($data['funct'], $functions)) {
                myError($user, $request, $response, 'notFound');
            } else {
                call_user_func($data['funct'], $user, $data, $response);
            }
        }
    } catch (Exception $e) {
        myError($user, $request, $response, 'unknownError');
    }
}
コード例 #8
0
ファイル: modifydns.php プロジェクト: hetznerZA/ipplan
    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);
コード例 #9
0
ファイル: vmlist.php プロジェクト: swkim85/EGIFedCloudWeb
}
function _update_vm_status($id, $stat)
{
    $qry = "UPDATE vminfo SET state='{$stat}' WHERE id='{$id}'";
    $ret = myQuery($qry);
}
### }}}
### {{{
if ($mode == 'do_change_name') {
    $id = $form['id'];
    $vmname = $form['vmname'];
    $memo = $form['memo'];
    $memo = myEscapeString($memo);
    $qry = "UPDATE vminfo SET vmname='{$vmname}', memo='{$memo}' where id='{$id}'";
    $ret = myQuery($qry);
    print myError();
    print <<<EOS
<script>
window.opener.document.location.reload();
window.close();
</script>
EOS;
    exit;
}
if ($mode == 'change_name') {
    $id = $form['id'];
    $row = _query_vm($id);
    //dd($row);
    pagehead($pgtitle, true);
    ParagraphTitle("VM Information");
    ParagraphTitle("Change Name", 1);
コード例 #10
0
ファイル: modifyzone.php プロジェクト: hetznerZA/ipplan
    insert($c, block("</small>"));
    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, "&zone=" . urlencode($zone) . "&cust=" . $cust . "&expr={$expr}&descrip=" . urlencode($descrip), "zone");
    if (!empty($vars) and !$printed) {
        insert($ck, anchor($vars, ">>"));
        $printed = 1;
    }
}
if ($cnt) {
    insert($w, anchor($_SERVER["PHP_SELF"] . "?cust={$cust}&zoneid=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 Zone entries") . "\n", FALSE);
}
insert($w, $f = form(array("method" => "post", "action" => "modifyzoneform.php?cust={$cust}&action=add")));
insert($f, submit(array("value" => my_("Add a 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, NULL);
printhtml($p);
コード例 #11
0
ファイル: ping.php プロジェクト: hetznerZA/ipplan
$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;
コード例 #12
0
ファイル: usermanager.php プロジェクト: hetznerZA/ipplan
$mid->setImgdir('../menus/menuimages/');
$mid->setImgwww('../menus/menuimages/');
$mid->setIcondir('../menus/menuicons/');
$mid->setIconwww('../menus/menuicons/');
$mid->SetMenuStructureString($MENU);
$mid->setIconsize(16, 16);
$mid->parseStructureForMenu('treemenu1');
$mid->newTreeMenu('treemenu1');
insert($view, block($mid->getTreeMenu('treemenu1')));
insert($view, block('<br><br>'));
// If any of the parsing generates an error, we insert that error and then reinsert the form that generated the error.
// The two group functions can come from multiple forms so we don't bother.
// Since all the possible inputs are generated by the code this should rarely happen anyways
// (assuming this is all bug free ;)
if ($formerror != "") {
    myError($editor, $p, $formerror, FALSE);
    if ($action == "parsecreateuserform") {
        insertCreateUserForm($editor, $ds);
    }
    if ($action == "parsecreategroupform") {
        insertCreateGroupForm($editor, $ds);
    }
    if ($action == "deleteuser") {
        insertEditUserForm($editor, $ds);
    }
    if ($action == "deletegroup") {
        insetrEditGroupForm($editor, $ds);
    }
    if ($action == "deleteuserfromgroup") {
        /* done in function with ref var */
    }
コード例 #13
0
ファイル: displaysubnet.php プロジェクト: hetznerZA/ipplan
 insert($t, $c = cell());
 insert($c, text($row["location"]));
 $export->addCell($row["location"]);
 insert($t, $c = cell());
 insert($c, block(linkURL(htmlspecialchars($row["descrip"]))));
 $export->addCell($row["descrip"]);
 if ($showdns) {
     // gethostbyaddr returns ip address back if no DNS entry
     // this will probably fail on windows!
     $tmp = time();
     $dnsdescrip = gethostbyaddr($ip);
     // are DNS queries taking too long?
     if (time() - $tmp > DNS_DELTA_TIME) {
         $showdns = 0;
         // stop doing DNS queries
         myError($w, $p, sprintf(my_("DNS queries taking too long - stopped doing queries at %s, time taken for last query was %s seconds"), $ip, time() - $tmp), FALSE);
     }
     if ($dnsdescrip != $ip and $dnsdescrip != $row["hname"]) {
         if (!empty($row["descrip"])) {
             insert($c, textbr());
         }
         insert($c, text($dnsdescrip, array("color" => "#FF0000")));
     } else {
         if ($dnsdescrip == $ip and !empty($row["hname"])) {
             if (!empty($row["descrip"])) {
                 insert($c, textbr());
             }
             insert($c, text(my_("No DNS entry defined"), array("color" => "#FF0000")));
         }
     }
 }
コード例 #14
0
ファイル: control.php プロジェクト: Nikya/voicify
function myErrorException($e)
{
    // Redirect to the error Handler
    myError(18000, $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTrace());
}
コード例 #15
0
ファイル: createsubnet.php プロジェクト: hetznerZA/ipplan
                    // remember to skip broadcast and network addresses!
                    for ($i_dns = 1; $i_dns < $size - 1; $i_dns++) {
                        $hname = gethostbyaddr(inet_ntoa($base + $i_dns));
                        if ($hname != inet_ntoa($base + $i_dns)) {
                            $ds->AddIP($base + $i_dns, $id, "", "", "", "", "", $hname, "");
                        }
                    }
                }
            }
            if (!empty($info)) {
                $result =& $ds->ds->Execute("INSERT INTO baseadd\n                        (info, baseindex)\n                        VALUES\n                        (" . $ds->ds->qstr($info) . ", {$id})");
            }
            $ds->DbfTransactionEnd();
            insert($w, textbr());
        } else {
            myError($w, $p, sprintf(my_("Subnet %s could not be created"), inet_ntoa($base)));
        }
    }
}
// end of for loop for multiple subnet creation
// add link if script was called from findfree
// only if all subnets created without error or warning
if (!$warn and $findfree) {
    // $findfree contains HTTP_REFERER which is a full URI already - OK
    header("Location: " . base64_decode($findfree));
    exit;
}
if (!$warn and $num == 1) {
    header("Location: " . location_uri("displaybase.php?cust={$cust}&ipaddr={$ipaddr}"));
    exit;
}
コード例 #16
0
ファイル: displaybase.php プロジェクト: hetznerZA/ipplan
        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)));
コード例 #17
0
ファイル: deleterange.php プロジェクト: hetznerZA/ipplan
newhtml($p);
$w = myheading($p, $title, true);
// explicitly cast variables as security measure against SQL injection
list($cust, $rangeindex) = myRegister("I:cust I:rangeindex");
$ds = new IPplanDbf() or myError($w, $p, my_("Could not connect to database"));
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 ($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")));
コード例 #18
0
ファイル: maintenance.php プロジェクト: hetznerZA/ipplan
// set language
isset($_COOKIE["ipplanLanguage"]) && myLanguage($_COOKIE['ipplanLanguage']);
//setdefault("window",array("bgcolor"=>"white"));
//setdefault("table",array("cellpadding"=>"0"));
//setdefault("text",array("size"=>"2"));
$title = my_("IPplan Maintenance");
newhtml($p);
$w = myheading($p, $title);
// explicitly cast variables as security measure against SQL injection
list($action, $cust, $block, $requestindex, $requestdesc) = myRegister("S:action I:cust I:block I:requestindex S:requestdesc");
$ds = new IPplanDbf() or myError($w, $p, my_("Could not connect to database"));
if ($action == "deletecustomer") {
    if (DBF_TYPE == "mysql" or DBF_TYPE == "maxsql") {
        $version = $ds->ds->GetOne("SELECT version() AS version");
        if ($version < "4.0.0") {
            myError($w, $p, my_("You need MySQL v4.0.0 or higher for this function!"));
        }
    }
    $ds->DbfTransactionStart();
    $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 ipaddr \n                WHERE baseindex IN (SELECT baseindex FROM base WHERE customer={$cust})") and $result =& $ds->ds->Execute("DELETE FROM ipaddradd\n                WHERE baseindex IN (SELECT baseindex FROM base WHERE customer={$cust})") and $result =& $ds->ds->Execute("DELETE FROM base\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")));
    }
}
if ($action == "deleterequest") {
    $ds->DbfTransactionStart();
    $result =& $ds->ds->Execute("DELETE FROM requestip");
    $ds->AuditLog(my_("Requested IP addresses cleared"));
コード例 #19
0
ファイル: modifydnsrecord.php プロジェクト: hetznerZA/ipplan
    insert($f, anchor("javascript:checkAll(1)", my_("Check all")));
    insert($f, block(" | "));
    insert($f, anchor("javascript:checkAll(0)", my_("Clear all")));
    insert($f, block("<p>"));
    insert($f, submit(array("value" => my_("Delete multiple"))));
}
$vars = "";
$printed = 0;
while ($row = $result->FetchRow()) {
    $totcnt++;
    $vars = DisplayBlock($w, $row, $totcnt, "&domain=" . urlencode($domain) . "&cust=" . $cust . "&expr={$expr}&descrip=" . urlencode($descrip), "sortorder");
    if (!empty($vars) and !$printed) {
        insert($ck, anchor($vars, ">>"));
        $printed = 1;
    }
}
if ($domain) {
    insert($w, $f = form(array("method" => "post", "action" => "modifydnsrecordform.php?cust={$cust}&action=add&domain=" . urlencode($domain) . "&zoneid=" . $zoneid)));
    insert($f, submit(array("value" => my_("Add a Host"))));
}
if (!$cnt) {
    myError($w, $p, my_("No Records found.  Please choose a domain and try again."));
} else {
    insert($f, anchor($_SERVER["PHP_SELF"] . "?cust={$cust}&action=renumber&domain=" . urlencode($domain) . "&block={$block}", my_("Renumber SortOrder"), $ipplanParanoid ? array("onclick" => "return confirm('" . my_("Are you sure?") . "')") : FALSE));
}
$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, NULL);
printhtml($p);
コード例 #20
0
ファイル: importip.php プロジェクト: hetznerZA/ipplan
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")));
    }
}
コード例 #21
0
ファイル: importbase.php プロジェクト: hetznerZA/ipplan
 $info = "";
 if ($template->is_error() == FALSE) {
     // all columns over 3 are considered for adding to template fields
     $position = 4;
     $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[$position]) ? $data[$position] : "";
         $position++;
     }
     $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();
         // myError($w,$p, my_("info: $info"));
     }
 }
 // Changed - End [FE]
 if (strlen($descrip) == 0) {
     insert($w, text(my_("No description for the subnet")));
     break;
 } else {
     if (!$ipaddr) {
         insert($w, text(my_("IP address may not be blank")));
         break;
     } else {
コード例 #22
0
ファイル: modifyipformmul.php プロジェクト: hetznerZA/ipplan
isset($_COOKIE["ipplanLanguage"]) && myLanguage($_COOKIE['ipplanLanguage']);
//setdefault("window",array("bgcolor"=>"white"));
//setdefault("table",array("cellpadding"=>"0"));
//setdefault("text",array("size"=>"2"));
$title = my_("Modify IP address details (range)");
newhtml($p);
$w = myheading($p, $title, true);
// explicitly cast variables as security measure against SQL injection
list($baseindex, $block, $ip, $search, $expr, $ipplanParanoid) = myRegister("I:baseindex I:block A:ip S:search S:expr I:ipplanParanoid");
//$ip=array($ip);   // type array
if (!$_POST) {
    myError($w, $p, my_("You cannot reload or bookmark this page!"));
}
// basic sequence is connect, search, interpret search
// result, close connection
$ds = new IPplanDbf() or myError($w, $p, my_("Could not connect to database"));
// save md5str for check in displaysubnet.php to see if info has
// been modified since start of edit
$md5str = $ds->GetMD5($ip, $baseindex);
insert($w, block("<h3>"));
insert($w, text(my_("IP Addresses to modify: ")));
foreach ($ip as $value) {
    insert($w, text(inet_ntoa($value) . " "));
}
insert($w, block("<small>"));
if (isset($_SERVER['HTTP_REFERER']) and stristr($_SERVER['HTTP_REFERER'], "displaysubnet.php")) {
    insert($w, anchor($_SERVER['HTTP_REFERER'], my_("Back to subnet")));
}
insert($w, block("</small>"));
insert($w, block("</h3>"));
// start form
コード例 #23
0
ファイル: whois.php プロジェクト: hetznerZA/ipplan
        $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);
コード例 #24
0
ファイル: exportdhcp.php プロジェクト: hetznerZA/ipplan
    // 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);
?>
 
コード例 #25
0
ファイル: createsubnetform.php プロジェクト: hetznerZA/ipplan
insert($w, block("<p>"));
insert($w, text(my_("Unused subnets can be pre-allocated with a description of either 'free' or 'spare'. These can be searched for at a later stage using the 'Find Free' function.")));
insert($w, block("<p>"));
insert($w, textbr(my_("It may also be beneficial to give ASE (Autonomous System External, networks not local to yours) a special handle like EXTERNAL so that they can be searched for at a later stage. These networks often appear in routing tables as static routes to third parties (not via the Internet).")));
$ds = new IPplanDbf() or myError($w, $p, my_("Could not connect to database"));
// start form
insert($w, $f = form(array("name" => "ENTRY", "method" => "post", "action" => "createsubnet.php")));
$cust = myCustomerDropDown($ds, $f, $cust, $grps, FALSE) or myError($w, $p, my_("No customers"));
$result = $ds->GetGrps();
$lst = array();
while ($row = $result->FetchRow()) {
    $col = $row["grp"];
    $lst["{$col}"] = $row["grpdescrip"];
}
if (empty($lst)) {
    myError($w, $p, my_("You first need to create some groups!"));
}
insert($f, textbrbr(my_("Admin Group")));
insert($f, span(my_("WARNING: If you choose a group that you do not have access to, you will not be able to see or access the data"), array("class" => "textSmall")));
insert($f, selectbox($lst, array("name" => "admingrp"), "{$ipplanGroup}"));
insert($f, textbrbr(my_("Network address")));
myFocus($p, "ENTRY", "ipaddr");
insert($f, input_text(array("name" => "ipaddr", "value" => isset($ipaddr) ? $ipaddr : "", "size" => "15", "maxlength" => "15")));
insert($f, textbrbr(my_("Number of contiguous networks to create")));
insert($f, input_text(array("name" => "num", "value" => "1", "size" => "3", "maxlength" => "3")));
insert($f, textbrbr(my_("Description")));
insert($f, span(my_("Leave blank to automatically describe"), array("class" => "textSmall")));
insert($f, input_text(array("name" => "descrip", "size" => "80", "maxlength" => "80")));
insert($f, textbrbr(my_("Subnet size/mask")));
// size maybe set from router script!!!
insert($f, selectbox(array("1" => "255.255.255.255/32 - host", "2" => "255.255.255.254/31 - 2 hosts", "4" => "255.255.255.252/30 - 4 hosts", "8" => "255.255.255.248/29 - 8 hosts", "16" => "255.255.255.240/28 - 16 hosts", "32" => "255.255.255.224/27 - 32 hosts", "64" => "255.255.255.192/26 - 64 hosts", "128" => "255.255.255.128/25 - 128 hosts", "256" => "255.255.255.0/24 - 256 hosts (class C)", "512" => "255.255.254.0/23 - 512 hosts", "1024" => "255.255.252.0/22 - 1k hosts", "2048" => "255.255.248.0/21 - 2k hosts", "4096" => "255.255.240.0/20 - 4k hosts", "8192" => "255.255.224.0/19 - 8k hosts", "16384" => "255.255.192.0/18 - 16k hosts", "32768" => "255.255.128.0/17 - 32k hosts", "65536" => "255.255.0.0/16 - 64k hosts (class B)", "131072" => "255.254.0.0/15 - 128k hosts", "262144" => "255.252.0.0/14 - 256k hosts"), array("name" => "size"), $size));
コード例 #26
0
ファイル: modifybaseform.php プロジェクト: hetznerZA/ipplan
//setdefault("text",array("size"=>"2"));
$title = my_("Modify/Copy/Move/Delete/Split/Join subnets");
newhtml($p);
insert($p, $h = wheader("IPPlan - {$title}"));
insert($h, script("", array("type" => "text/javascript", "src" => "../cookies.js")));
insert($h, script("", array("type" => "text/javascript", "src" => "../phpserializer.js")));
insert($h, script("", array("type" => "text/javascript", "src" => "../ipplanlib.js")));
$w = myheading($p, $title, true);
// explicitly cast variables as security measure against SQL injection
list($cust, $areaindex) = myRegister("I:cust I:areaindex");
// display opening text
insert($w, heading(3, "{$title}."));
$ds = new IPplanDbf() or myError($w, $p, my_("Could not connect to database"));
// start form
insert($w, $f1 = form(array("name" => "THISFORM", "method" => "post", "action" => $_SERVER["PHP_SELF"])));
$cust = myCustomerDropDown($ds, $f1, $cust, $grps) or myError($w, $p, my_("No customers"));
$areaindex = myAreaDropDown($ds, $f1, $cust, $areaindex);
insert($w, $f2 = form(array("name" => "ENTRY", "method" => "get", "action" => "modifybase.php")));
// save customer name for actual post of data
insert($f2, hidden(array("name" => "cust", "value" => "{$cust}")));
insert($f2, hidden(array("name" => "areaindex", "value" => "{$areaindex}")));
myRangeDropDown($ds, $f2, $cust, $areaindex);
insert($f2, block("<p>"));
insert($f2, $con = container("fieldset", array("class" => "fieldset")));
insert($con, $legend = container("legend", array("class" => "legend")));
insert($legend, text(my_("Search criteria")));
myFocus($p, "ENTRY", "ipaddr");
insert($con, textbr(my_("Subnet address (leave blank if range selected)")));
insert($con, span(my_("Partial subnet addresses can be used eg. 172.20"), array("class" => "textSmall")));
insert($con, input_text(array("name" => "ipaddr", "size" => "15", "maxlength" => "15")));
if (DBF_TYPE == "mysql" or DBF_TYPE == "maxsql" or DBF_TYPE == "postgres7") {
コード例 #27
0
ファイル: treeview.php プロジェクト: hetznerZA/ipplan
                $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);
?>
 
コード例 #28
0
ファイル: displayoverlap.php プロジェクト: hetznerZA/ipplan
newhtml($p);
$w = myheading($p, $title, true);
// explicitly cast variables as security measure against SQL injection
list($cust1, $cust2, $block) = myRegister("A:cust1 A:cust2 I:block");
// could be array!
//$cust1=floor($cust1);
//$cust2=floor($cust2);
if (!$_GET) {
    myError($w, $p, my_("You cannot reload or bookmark this page!"));
}
// basic sequence is connect, search, interpret search
// result, close connection
$ds = new IPplanDbf() or myError($w, $p, my_("Could not connect to database"));
insert($w, heading(3, my_("Search for overlapping subnets between customers/autonomous systems")));
// reduce the two arrays to a single array, removing all duplicates
$arr = array_unique(array_merge($cust1, $cust2));
sort($arr);
if (count($arr) <= 1) {
    myError($w, $p, my_("Both customers selected are the same - all subnets will overlap!"));
}
// Loop through the list of customers doing an overlap search between
// the current customer and all of the following customers.
foreach ($arr as $ind1 => $id1) {
    foreach ($arr as $ind2 => $id2) {
        if ($id2 <= $id1) {
            continue;
        }
        searchOverlap($ds, $w, $id1, $id2);
    }
}
printhtml($p);
コード例 #29
0
ファイル: modifyipform.php プロジェクト: hetznerZA/ipplan
insert($con, submit(array("value" => my_("Upload file"))));
// --------------------------- end of upload section ----------------------------
// complete delete form - created earlier
insert($fdel, hidden(array("name" => "baseindex", "value" => "{$baseindex}")));
insert($fdel, hidden(array("name" => "ip", "value" => "{$ip}")));
insert($fdel, hidden(array("name" => "subnetsize", "value" => "{$subnetsize}")));
insert($fdel, hidden(array("name" => "action", "value" => "delete")));
insert($fdel, hidden(array("name" => "block", "value" => "{$block}")));
insert($fdel, hidden(array("name" => "search", "value" => "{$search}")));
insert($fdel, hidden(array("name" => "expr", "value" => "{$expr}")));
insert($fdel, hidden(array("name" => "md5str", "value" => "{$md5str}")));
insert($fdel, hidden(array("name" => "close", "value" => "{$close}")));
insert($fdel, submit(array("value" => my_("Delete record"))));
insert($fdel, text(my_("WARNING: Deleting an entry does not preserve the last modified information as the record is completely removed from the database to conserve space. ")));
if (is_array($files)) {
    myError($fdel, $p, my_("Deleting this record will delete all associated uploaded files!") . "\n", FALSE);
}
// end of delete form
// dummy form for "follow" function
$settings = array("name" => "DUMMY", "method" => "get", "action" => "displaybase.php");
insert($w, $f = form($settings));
insert($f, hidden(array("name" => "ipaddr", "value" => $lnk)));
insert($f, hidden(array("name" => "cust", "value" => $cust)));
insert($f, hidden(array("name" => "searchin", "value" => "1")));
insert($f, hidden(array("name" => "jump", "value" => "1")));
// create the export view form
$export = new exportForm();
$export->addRow(array("user", "location", "description", "hostname", "telephone", "mac_addr", "linked_addr"));
$export->saveRow();
$export->addRow(array($userinf, $location, $descrip, $hname, $telno, $macaddr, $lnk));
$export->saveRow();