function genSWIP($ds, $baseindex, $start, $end, $cust, $descrip, $swipmod, $filename) { global $ntnameopt; //************ now process customer standard fields ************// $result1 =& $ds->ds->Execute("SELECT *\n FROM custinfo\n WHERE customer={$cust}"); // should only be one row here, none if SWIP turned off during creation // of customer $row1 = $result1->FetchRow(); $result2 =& $ds->ds->Execute("SELECT hname, ipaddr\n FROM revdns\n WHERE customer={$cust}\n ORDER BY horder"); $fields = array(); $fields["ntsnum"] = $start; $fields["ntenum"] = $end; $fields = array_merge($fields, $row1); // use subnet description field? then only a-z, 0-9 max 21 chars allowed if ($ntnameopt and preg_match("/^[A-Za-z0-9\\-]{1,21}\$/", $descrip)) { $ntname = $descrip; } else { $ntname = MAINTAINERID . "-" . str_replace(".", "-", $start); } $fields["ntname"] = $ntname; $fields["maint"] = MAINTAINERID; if ($row2 = $result2->FetchRow()) { $fields["hname1"] = $row2["hname"]; $fields["ipaddr1"] = $row2["ipaddr"]; } else { $fields["hname1"] = ""; $fields["ipaddr1"] = ""; } if ($row2 = $result2->FetchRow()) { $fields["hname2"] = $row2["hname"]; $fields["ipaddr2"] = $row2["ipaddr"]; } else { $fields["hname1"] = ""; $fields["ipaddr1"] = ""; } if ($row2 = $result2->FetchRow()) { $fields["hname3"] = $row2["hname"]; $fields["ipaddr3"] = $row2["ipaddr"]; } else { $fields["hname1"] = ""; $fields["ipaddr1"] = ""; } $cnt = 3; while ($row2 = $result2->FetchRow()) { $fields["hname{$cnt}"] = $row2["hname"]; $fields["ipaddr{$cnt}"] = $row2["ipaddr"]; $cnt++; } $fields["regid"] = REGID; $fields["password"] = REGPASS; $fields["source"] = REGISTRY; // add a UTC format date $now = getdate(); $fields["date"] = $now["year"] . str_pad($now["mon"], 2, '0', STR_PAD_LEFT) . str_pad($now["mday"], 2, '0', STR_PAD_LEFT); $fields["swipmod"] = $swipmod; //************ now process customer template fields ************// // if a specific customer template exists $err = TRUE; $template = new IPplanIPTemplate("custtemplate", $cust); $err = $template->is_error(); // process fields form the user defined template if (!$err) { $restmp =& $ds->ds->Execute("SELECT info\n FROM custadd\n WHERE customer={$cust}"); if ($rowadd = $restmp->FetchRow()) { $template->Merge($template->decode($rowadd["info"])); foreach ($template->userfld as $key => $arr) { $fields[$key] = $arr["value"]; } } } //************ now process base template fields ************// // if a specific base template exists, use that, else use generic template $err = TRUE; $template = new IPplanIPTemplate("basetemplate", $cust); $err = $template->is_error(); if (!$err) { $result_template =& $ds->ds->Execute("SELECT info, infobin\n FROM baseadd\n WHERE baseindex={$baseindex}"); if ($rowadd = $result_template->FetchRow()) { $template->Merge($template->decode($rowadd["info"])); foreach ($template->userfld as $key => $arr) { $fields[$key] = $arr["value"]; } } } $rep = new myTemplate(); if ($rep->get("../templates/{$filename}") == FALSE) { return FALSE; } $swip = $rep->process($fields); return $swip; }
} if (!checkdate($createmonth, $createday, $createyear)) { myError($w, $p, my_("Invalid create date")); } if (!checkdate($regmonth, $regday, $regyear)) { myError($w, $p, my_("Invalid registration date")); } if (!checkdate($expiremonth, $expireday, $expireyear)) { myError($w, $p, my_("Invalid expire date")); } if (sprintf("%04u%02u%02u", $expireyear, $expiremonth, $expireday) >= sprintf("%04u%02u%02u", $regyear, $regmonth, $regday) and sprintf("%04u%02u%02u", $regyear, $regmonth, $regday) >= sprintf("%04u%02u%02u", $createyear, $createmonth, $createday)) { } else { myError($w, $p, my_("Invalid date combination. Expire date must be greater than last registration date which must be greater than creation date")); } // use base template (for additional subnet information) $template = new IPplanIPTemplate("fwdzonetemplate", $cust); $info = ""; if ($template->is_error() == FALSE) { // PROBLEM HERE: if template create suddenly returns error (template file // permissions, xml error etc), then each submit thereafter will erase // previous contents - this is not good $template->Merge($userfld); $err = $template->Verify($w); if ($template->is_blank() == FALSE) { $info = $template->encode(); } } } // ##################### Start OF Add ############################## if ($action == "add") { // loop through array - each element is a domain to add
// 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"]); if ($rowadd = $result_template->FetchRow()) { $template->Merge($template->decode($rowadd["info"])); foreach ($template->userfld as $arr) { $tmpfield = csv_escape($arr["value"]); echo FIELDS_TERMINATED_BY . $arr["value"]; } } } echo "\n";
insert($f, checkbox(array("name" => "dhcp", "value" => "1", "onclick" => "location.href='" . location_uri("createsubnetform.php?cust={$cust}&size={$size}&ipplanGroup={$ipplanGroup}&dhcp=1" . "'")), my_("Is this a DHCP subnet?"), $dhcp)); if ($dhcp) { insert($f, block("<p>")); insert($f, textb(my_("Creating a new DHCP subnet"))); } insert($f, textbr()); // if called from findfree, save find results if (isset($_SERVER['HTTP_REFERER']) and stristr($_SERVER['HTTP_REFERER'], "findfree.php")) { insert($f, hidden(array("name" => "findfree", "value" => base64_encode($_SERVER['HTTP_REFERER'])))); } // Requires new default template: basetemplate.xml // Start of template support [FE] if ($dhcp) { // use dhcp template (for additional subnet information) $template = new IPplanIPTemplate("basetemplate-dhcp", $cust); } else { // use base template (for additional subnet information) $template = new IPplanIPTemplate("basetemplate", $cust); } if ($template->is_error() == FALSE) { insert($f, $con = container("fieldset", array("class" => "fieldset"))); insert($con, $legend = container("legend", array("class" => "legend"))); insert($legend, text(my_("Additional information"))); //$template->Merge($template->decode($dbfinfo)); $template->DisplayTemplate($con); } insert($f, submit(array("value" => my_("Submit")))); insert($f, freset(array("value" => my_("Clear")))); myCopyPaste($f, "ipplanCPcreateform", "ENTRY"); $result->Close(); printhtml($p);
} $data[5] = ""; ProcessRow($ds, $cust, $w, $p, $data, FALSE, $append); } } } else { // open uploaded file for read $fp = @fopen($filename, "r"); // no real portable way to check if file was uploaded - php version // dependent if (!$fp) { myError($w, $p, my_("File could not be opened.")); } // can we read the template? $template = FALSE; $template = new IPplanIPTemplate("iptemplate", $cust); if ($template->is_error() == TRUE) { myError($w, $p, my_("Template could not be opened."), FALSE); $template = FALSE; // use is_object later } while ($data = fgetcsv($fp, 4098, FIELDS_TERMINATED_BY)) { $rowcnt++; insert($w, textbr()); insert($w, text(my_("Importing row:") . " {$rowcnt} ")); ProcessRow($ds, $cust, $w, $p, $data, $template, $append); } fclose($fp); } $ds->DbfTransactionEnd(); printhtml($p);
insert($f, $con = container("fieldset", array("class" => "fieldset"))); insert($con, $legend = container("legend", array("class" => "legend"))); insert($legend, text(my_("User information"))); insert($con, textbr(my_("User"))); insert($con, input_text(array("name" => "user", "value" => $user, "size" => "80", "maxlength" => "80"))); insert($con, textbrbr(my_("Location"))); insert($con, input_text(array("name" => "location", "value" => $location, "size" => "80", "maxlength" => "80"))); insert($con, textbrbr(my_("Device description"))); insert($con, input_text(array("name" => "descrip", "value" => $descrip, "size" => "80", "maxlength" => "80"))); insert($con, textbrbr(my_("Device hostname"))); insert($con, input_text(array("name" => "hname", "value" => $hname, "size" => "80", "maxlength" => "100"))); insert($con, textbrbr(my_("Telephone number"))); insert($con, input_text(array("name" => "telno", "value" => $telno, "size" => "15", "maxlength" => "15"))); insert($con, textbrbr(my_("MAC address"))); insert($con, input_text(array("name" => "macaddr", "value" => $macaddr, "size" => "17", "maxlength" => "17"))); $template = new IPplanIPTemplate("iptemplate", $cust); if ($template->is_error() == FALSE) { //insert($f,block("<hr>")); insert($f, $con = container("fieldset", array("class" => "fieldset"))); insert($con, $legend = container("legend", array("class" => "legend"))); insert($legend, text(my_("Additional information"))); //insert($f,textbr(my_("Additional information"), array("b"=>1))); if (isset($userfld)) { $template->Merge($userfld); } $template->DisplayTemplate($con); } insert($f, generic("br")); insert($f, submit(array("value" => my_("Submit")))); insert($f, freset(array("value" => my_("Clear")))); printhtml($p);
insert($con, textbr(my_("Technical contact email address"))); insert($con, span(my_("No @ allowed - replace with ."), array("class" => "textSmall"))); insert($con, input_text(array("name" => "responsiblemail", "value" => "{$responsiblemail}", "size" => "64", "maxlength" => "64"))); insert($con, textbrbr(my_("TTL"))); insert($con, input_text(array("name" => "ttl", "value" => "{$ttl}", "size" => "10", "maxlength" => "10"))); insert($con, textbrbr(my_("Refresh"))); insert($con, input_text(array("name" => "refresh", "value" => "{$refresh}", "size" => "5", "maxlength" => "10"))); insert($con, textbrbr(my_("Retry"))); insert($con, input_text(array("name" => "retry", "value" => "{$retry}", "size" => "5", "maxlength" => "10"))); insert($con, textbrbr(my_("Expire"))); insert($con, input_text(array("name" => "expire", "value" => "{$expire}", "size" => "5", "maxlength" => "10"))); insert($con, textbrbr(my_("Minimum TTL"))); insert($con, input_text(array("name" => "minimum", "value" => "{$minimum}", "size" => "5", "maxlength" => "10"))); $dbfinfo = $ds->ds->GetOne("SELECT info FROM fwdzoneadd \n WHERE customer={$cust} AND data_id={$dataid}"); // use base template (for additional subnet information) $template = new IPplanIPTemplate("fwdzonetemplate", $cust); if ($template->is_error() == FALSE) { insert($f, $con = container("fieldset", array("class" => "fieldset"))); insert($con, $legend = container("legend", array("class" => "legend"))); insert($legend, text(my_("Additional information"))); $template->Merge($template->decode($dbfinfo)); $template->DisplayTemplate($con); } insert($f, $con = container("fieldset", array("class" => "fieldset"))); insert($con, $legend = container("legend", array("class" => "legend"))); insert($legend, text(my_("Forward zone location"))); insert($con, textbr(my_("Zone File Path"))); insert($con, span(my_("The path where the zone file will be written once exported and processed. Examples:"), array("class" => "textSmall"))); insert($con, span(my_("ftp://myhost.com/var/named/test.zone - if you want to transfer the zone using ncftput"), array("class" => "textSmall"))); insert($con, span(my_("user@myhost.com:/var/named/test.zone - if you want to transfer the zone using scp"), array("class" => "textSmall"))); insert($con, input_text(array("name" => "zonepath", "value" => "{$zonepath}", "size" => "80", "maxlength" => "254")));
myError($w, $p, my_("Possible file upload attack")); } } $filename = $_FILES['userfile']['tmp_name']; // basic sequence is connect, search, interpret search // result, close connection $ds = new IPplanDbf() or myError($w, $p, my_("Could not connect to database")); // open uploaded file for read $fp = @fopen($filename, "r"); if (!$fp) { myError($w, $p, my_("File could not be opened.")); } // Changed - Begin [FE] // Start of template support for base. // can we read the template? $template = new IPplanIPTemplate("basetemplate", $cust); if ($template->is_error() == TRUE) { myError($w, $p, my_("Template could not be opened."), FALSE); } // Changed - End [FE] $cnt = 0; $ds->DbfTransactionStart(); while ($data = fgetcsv($fp, 4098, FIELDS_TERMINATED_BY)) { $cnt++; insert($w, textbr()); insert($w, text(my_("Importing row:") . " {$cnt} ")); $num = count($data); // blank row if (empty($data[0])) { insert($w, block("<b>" . my_("Row is blank - ignoring") . "</b>")); continue;
$displayall = TRUE; $cust = myCustomerDropDown($ds, $f1, $cust, $grps) or myError($w, $p, my_("No customers")); $areaindex = myAreaDropDown($ds, $f1, $cust, $areaindex); $rangeindex = searchRangeDropDown($ds, $f1, $cust, $areaindex, $rangeindex); //$rangeindex=myRangeDropDown($ds, $f1, $cust, $areaindex); insert($f1, block("<p>")); insert($f1, $con2 = container("fieldset", array("class" => "fieldset"))); insert($con2, $legend = container("legend", array("class" => "legend"))); insert($legend, text(my_("Search field"))); insert($con2, text(my_("Field to search"))); if (empty($field)) { $field = "userinf"; } $lst = array("userinf" => my_("User"), "location" => my_("Location"), "descrip" => my_("Description"), "hname" => my_("Host Name"), "telno" => my_("Telephone Number"), "macaddr" => my_("MAC Address"), "template" => my_("Search in Template")); insert($con2, selectbox($lst, array("name" => "field", "onChange" => "submit()"), $field)); $template = new IPplanIPTemplate("iptemplate", $cust); if ($template->is_error() == FALSE) { // The function retruns part of the template definietions $tmpldef = $template->return_templ_name(); if ($field == "template") { // Search for specific template fields only with regex support if (DBF_TYPE == "mysql" or DBF_TYPE == "maxsql" or DBF_TYPE == "postgres7") { if (empty($tmplfield)) { $tmplfield = "any"; } insert($con2, selectbox($tmpldef, array("name" => "tmplfield", "onChange" => "submit()"), $tmplfield)); } } } insert($w, $f2 = form(array("name" => "ENTRY", "method" => "get", "action" => "searchall.php"))); // save customer name for actual post of data
insert($f, hidden(array("name" => "origcust", "value" => "{$origcust}"))); insert($f, textbrbr(my_("Admin Group"))); insert($f, textbr(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"))); insert($f, selectbox($lst, array("name" => "grp"), $grp)); // Changed - Begin [FE] // Requires new default template: basetemplate.xml // Start of template support [FE] $result =& $ds->ds->Execute("SELECT info, infobin\n FROM baseadd\n WHERE baseindex={$baseindex}"); $rowadd = $result->FetchRow(); $dbfinfo = $rowadd["info"]; if ($dhcp) { // use dhcp template (for additional subnet information) $template = new IPplanIPTemplate("basetemplate-dhcp", $cust); } else { // use base template (for additional subnet information) $template = new IPplanIPTemplate("basetemplate", $cust); } if ($template->is_error() == FALSE) { insert($f, $con = container("fieldset", array("class" => "fieldset"))); insert($con, $legend = container("legend", array("class" => "legend"))); insert($legend, text(my_("Additional information"))); $template->Merge($template->decode($dbfinfo)); $template->DisplayTemplate($con); } // Changed - End [FE] insert($f, generic("br")); insert($f, submit(array("value" => my_("Submit")))); insert($f, freset(array("value" => my_("Clear")))); myCopyPaste($f, "ipplanCPmodsubnet", "ENTRY"); } printhtml($p);
function FwdZoneExport($cust, $dataid) { // use local function variables as they may change $this->cust = $cust; $this->Serial(); // Update DNS Database Serial Count. Update Serial Count only when we export. $result = $this->ds->Execute("UPDATE fwdzone " . "set serialdate=" . $this->ds->qstr($this->serialdate) . ", userid=" . $this->ds->qstr(getAuthUsername()) . ", error_message=" . $this->ds->qstr("") . ", lastexp=" . $this->ds->DBTimeStamp(time()) . ", serialnum={$this->serialnum}" . " WHERE customer={$cust} AND data_id=" . $dataid); if ($result) { $sqllastmod = $this->ds->SQLDate("M d Y H:i:s", 'lastmod'); $result = $this->ds->Execute("SELECT data_id, domain, engineer, error_message, \n responsiblemail, serialdate, serialnum, ttl, refresh, retry, expire, \n minimum, zonefilepath1, zonefilepath2, customer, admingrp, \n {$sqllastmod} AS lastmod, userid, slaveonly\n FROM fwdzone \n WHERE customer={$cust} AND data_id={$dataid}"); $row = $result->FetchRow(); $this->domain = $row["domain"]; $info = $this->ds->GetOne("SELECT info\n FROM fwdzoneadd\n WHERE customer={$cust} AND data_id={$dataid}"); $tmpfname = tempnam(DNSEXPORTPATH, "zone_" . $this->domain . "_"); if (!$tmpfname) { $this->err = 80; $this->errstr .= my_("Could not create temporary file!"); return; } $fp = fopen("{$tmpfname}", "w"); // header of document $output = '<?xml version="1.0" ?>'; fputs($fp, $output); fputs($fp, "\n"); fputs($fp, sprintf('<zone domain="%s" slaveonly="%s">', $row["domain"], empty($row["slaveonly"]) ? "N" : $row["slaveonly"])); fputs($fp, "\n"); fputs($fp, sprintf("<path>\n<primary>\n%s\n</primary>\n", htmlspecialchars($row["zonefilepath1"]))); fputs($fp, sprintf("<primaryfile>\n%s\n</primaryfile>\n", htmlspecialchars(basename($row["zonefilepath1"])))); fputs($fp, sprintf("<primarydir>\n%s\n</primarydir>\n", htmlspecialchars(dirname($row["zonefilepath1"])))); fputs($fp, sprintf("<secondary>\n%s\n</secondary>\n", htmlspecialchars($row["zonefilepath2"]))); fputs($fp, sprintf("<secondaryfile>\n%s\n</secondaryfile>\n", htmlspecialchars(basename($row["zonefilepath2"])))); fputs($fp, sprintf("<secondarydir>\n%s\n</secondarydir>\n", htmlspecialchars(dirname($row["zonefilepath2"])))); fputs($fp, "</path>\n"); // SOA portion fputs($fp, sprintf('<soa serialdate="%s" serialnum="%02d" ttl="%s" retry="%s" refresh="%s" expire="%s" minimumttl="%s" email="%s" />', $this->serialdate, $this->serialnum, $row["ttl"], $row["retry"], $row["refresh"], $row["expire"], $row["minimum"], $row["responsiblemail"])); fputs($fp, "\n"); // additional fields if (!empty($info)) { $template = new IPplanIPTemplate("fwdzonetemplate", $cust); if ($template->is_error() == FALSE) { $template->Merge($template->decode($info)); fputs($fp, "<additional>\n"); foreach ($template->userfld as $field => $val) { fputs($fp, sprintf("\t<%s>%s</%s>\n", htmlspecialchars($field), htmlspecialchars($val["value"]), htmlspecialchars($field))); } fputs($fp, "</additional>\n"); } } // nameservers $result1 = $this->ds->Execute("SELECT hname\n FROM fwddns\n WHERE id={$dataid}\n ORDER BY horder"); $cnt = 0; while ($row1 = $result1->FetchRow()) { fputs($fp, '<record><NS>'); fputs($fp, sprintf('<iphostname>%s</iphostname>', $row1["hname"])); fputs($fp, '</NS></record>'); fputs($fp, "\n"); $cnt++; } if ($cnt < 2) { fclose($fp); unlink($tmpfname); $this->err = 70; $this->errstr .= my_("Invalid zone - zone should have at least two name servers defined") . "\n"; return; } $sqllastmod = $this->ds->SQLDate("M d Y H:i:s", 'lastmod'); $result = $this->ds->Execute("SELECT recidx, data_id, host, recordtype, ip_hostname, \n error_message, sortorder, customer, {$sqllastmod} AS lastmod, userid\n FROM fwdzonerec\n WHERE customer={$cust} AND data_id={$dataid}\n ORDER BY sortorder"); // loop through each host record while ($row = $result->FetchRow()) { fputs($fp, sprintf('<record><%s>', $row["recordtype"])); fputs($fp, sprintf('<host>%s</host>', $row["host"])); // MX records are in format "10 hostname.com" in database field ip_hostname if ($row["recordtype"] == "MX" or $row["recordtype"] == "AFSDB") { list($preference, $iphost) = explode(" ", $row["ip_hostname"], 2); if (is_numeric($preference) and $preference >= 0) { fputs($fp, sprintf('<preference>%s</preference>', $preference)); fputs($fp, sprintf('<iphostname>%s</iphostname>', $iphost)); } else { fputs($fp, '<preference>10</preference>'); fputs($fp, sprintf('<iphostname>%s</iphostname>', $row["ip_hostname"])); } } else { if ($row["recordtype"] == "SRV") { list($priority, $weight, $port, $iphost) = explode(" ", $row["ip_hostname"], 4); if (is_numeric($priority) and is_numeric($weight) and is_numeric($port) and $priority >= 0 and $weight >= 0 and $port >= 0) { fputs($fp, sprintf('<preference>%s %s %s</preference>', $priority, $weight, $port)); fputs($fp, sprintf('<iphostname>%s</iphostname>', $iphost)); } else { fputs($fp, '<preference> Invalid SRV record </preference>'); fputs($fp, sprintf('<iphostname>%s</iphostname>', $row["ip_hostname"])); } } else { fputs($fp, sprintf('<iphostname>%s</iphostname>', $row["ip_hostname"])); } } fputs($fp, sprintf('</%s></record>', $row["recordtype"])); fputs($fp, "\n"); } // close zone fputs($fp, '</zone>'); fputs($fp, "\n"); fclose($fp); // give file proper extension rename($tmpfname, $tmpfname . ".xml"); @chmod($tmpfname . ".xml", 0644); $this->err = 0; return $tmpfname . ".xml"; } //return $tmpfname; // database error? }
function requestip(&$p, &$w, $ds, $cust) { // get all request records $sqllastmod = $ds->ds->SQLDate("M d Y H:i:s", 'lastmod'); $result = $ds->ds->Execute("SELECT requestindex, requestdesc, userinf, location, telno, \n descrip, hname, macaddr, {$sqllastmod} AS lastmod, info\n FROM requestip\n WHERE customer={$cust}"); // emulate for databases that do not have RecordCount // not records, do nothing if (!$result->PO_RecordCount("requestip", "customer={$cust}")) { return; } // if a specific network template exists, use that, else use generic template $savtemplate = new IPplanIPTemplate("iptemplate", $cust); $err = $savtemplate->is_error(); $lst = array(); $jsarr = ""; $lst["0"] = "No request"; $cnt = 0; while ($row = $result->FetchRow()) { $template = $savtemplate; // reset template - additional fields could have been added $col = $row["requestindex"]; $lst["{$col}"] = $row["requestdesc"]; $jsarr .= " dbf[{$col}]=new Array();\n"; $jsarr .= " dbf[{$col}][1]=\"" . jsAddSlashes($row["userinf"]) . "\";\n"; $jsarr .= " dbf[{$col}][2]=\"" . jsAddSlashes($row["location"]) . "\";\n"; $jsarr .= " dbf[{$col}][3]=\"" . jsAddSlashes($row["descrip"]) . "\";\n"; $jsarr .= " dbf[{$col}][4]=\"" . jsAddSlashes($row["hname"]) . "\";\n"; $jsarr .= " dbf[{$col}][5]=\"" . jsAddSlashes($row["telno"]) . "\";\n"; $jsarr .= " dbf[{$col}][6]=\"" . jsAddSlashes(substr(chunk_split($row["macaddr"], 2, ':'), 0, -1)) . "\";\n"; // no template error if (!$err) { $template->Update($template->decode($row["info"])); $cnt2 = ADD_INFO; $jsset = ""; foreach ($template->userfld as $arr) { $jsarr .= " dbf[{$col}][{$cnt2}]=\"" . jsAddSlashes(preg_replace('/(\\r\\n)|\\n|\\r/m', '\\n', isset($arr["value"]) ? $arr["value"] : "")) . "\";\n"; $jsset .= " parent.document.MODIFY.elements[{$cnt2}].value=dbf[idx][{$cnt2}];\n"; $cnt2++; } } $cnt++; } insert($p, script(' function modifyipform() { dbf=new Array(); ' . $jsarr . ' idx=document.REQUESTIP.request.value; document.MODIFY.request.value=idx; if ((idx) == 0) return; document.MODIFY.user.value=dbf[idx][1]; document.MODIFY.location.value=dbf[idx][2]; document.MODIFY.descrip.value=dbf[idx][3]; document.MODIFY.hname.value=dbf[idx][4]; document.MODIFY.telno.value=dbf[idx][5]; document.MODIFY.macaddr.value=dbf[idx][6]; ' . $jsset . ' } ', array("language" => "JavaScript", "type" => "text/javascript"))); insert($w, $f = form(array("name" => "REQUESTIP", "method" => "get", "action" => $_SERVER["PHP_SELF"]))); insert($f, $con = container("fieldset", array("class" => "fieldset"))); insert($con, $legend = container("legend", array("class" => "legend"))); insert($legend, text(my_("Requested addresses"))); insert($con, selectbox($lst, array("name" => "request", "onChange" => "modifyipform()"))); }