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


PHP my_函数代码示例

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


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

示例1: CheckSchema

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;
}
开发者ID:hetznerZA,项目名称:ipplan,代码行数:52,代码来源:schema.php

示例2: searchRangeDropDown

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;
}
开发者ID:hetznerZA,项目名称:ipplan,代码行数:23,代码来源:searchallform.php

示例3: insert

            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);
开发者ID:hetznerZA,项目名称:ipplan,代码行数:31,代码来源:changepassword.php

示例4: fputs

    // 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);
?>
 
开发者ID:hetznerZA,项目名称:ipplan,代码行数:29,代码来源:exportdhcp.php

示例5: insert

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);
开发者ID:hetznerZA,项目名称:ipplan,代码行数:31,代码来源:modifyipformmul.php

示例6: setcookie

    // 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);
开发者ID:hetznerZA,项目名称:ipplan,代码行数:31,代码来源:deleterange.php

示例7: ProcessRow

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")));
    }
}
开发者ID:hetznerZA,项目名称:ipplan,代码行数:87,代码来源:importip.php

示例8: insert

        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)));
开发者ID:hetznerZA,项目名称:ipplan,代码行数:31,代码来源:displaybase.php

示例9: myError

$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);
开发者ID:hetznerZA,项目名称:ipplan,代码行数:31,代码来源:emailswip.php

示例10: setcookie

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);
开发者ID:hetznerZA,项目名称:ipplan,代码行数:31,代码来源:deletearea.php

示例11: parseDeleteBounds

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);
}
开发者ID:hetznerZA,项目名称:ipplan,代码行数:12,代码来源:usermanager.php

示例12: insert

    $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);
开发者ID:hetznerZA,项目名称:ipplan,代码行数:31,代码来源:findfree.php

示例13: SQLAuthenticator

$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;
开发者ID:hetznerZA,项目名称:ipplan,代码行数:31,代码来源:ping.php

示例14: setdefault

    $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);
开发者ID:hetznerZA,项目名称:ipplan,代码行数:31,代码来源:modifyarearange.php

示例15: searchOverlap

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++;
//.........这里部分代码省略.........
开发者ID:hetznerZA,项目名称:ipplan,代码行数:101,代码来源:displayoverlap.php


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