1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
|
<?php
// IPplan v4.92a
// Aug 24, 2001
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
require_once("../ipplanlib.php");
require_once("../adodb/adodb.inc.php");
require_once("../class.dbflib.php");
require_once("../layout/class.layout");
require_once("../auth.php");
require_once("../class.xptlib.php");
$auth = new SQLAuthenticator(REALM, REALMERROR);
// And now perform the authentication
$auth->authenticate();
// save the last customer used
// must set path else Netscape gets confused!
setcookie("ipplanCustomer","$cust",time() + 10000000, "/");
// 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_("Results of your search for areas");
newhtml($p);
$w=myheading($p, $title, true);
// explicitly cast variables as security measure against SQL injection
list($cust, $ipplanParanoid) = myRegister("I:cust I:ipplanParanoid");
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"));
$custdescrip=$ds->GetCustomerDescrip($cust);
insert($w,heading(3, sprintf(my_("Search for areas and ranges for customer '%s'"), $custdescrip)));
$result=&$ds->ds->Execute("SELECT area.areaaddr, area.descrip AS adescrip,
netrange.rangeaddr,
netrange.rangesize, netrange.descrip AS rdescrip,
netrange.rangeindex, area.areaindex
FROM netrange
LEFT JOIN area
ON netrange.areaindex=area.areaindex
WHERE netrange.customer=$cust
ORDER BY area.areaaddr, netrange.rangeaddr, netrange.rangesize");
// create a table
insert($w,$t = table(array("cols"=>"8",
"class"=>"outputtable")));
// draw heading
setdefault("cell",array("class"=>"heading"));
insert($t,$c = cell());
insert($c,text(my_("Area address")));
insert($t,$c = cell());
insert($c,text(my_("Description")));
insert($t,$c = cell());
insert($c,text(my_("Action")));
insert($t,$c = cell());
insert($c,text(my_("Range address")));
insert($t,$c = cell());
insert($c,text(my_("Range size")));
insert($t,$c = cell());
insert($c,text(my_("Range mask")));
insert($t,$c = cell());
insert($c,text(my_("Description")));
insert($t,$c = cell());
insert($c,text(my_("Action")));
$export = new exportForm();
$export->addRow(array("area_addr", "area_description", "range_addr", "range_size", "range_mask", "range_description"));
$export->saveRow();
$cnt=0;
$savearea=0;
while($row=$result->FetchRow()) {
$export->addRow(Null);
setdefault("cell",array("class"=>color_flip_flop()));
// first record could be NULL due to left join
if ($savearea==$row["areaaddr"] and $cnt!=0) {
insert($t,$c = cell());
insert($t,$c = cell());
insert($t,$c = cell());
$export->addCell(inet_ntoa($row["areaaddr"]));
$export->addCell($row["adescrip"]);
}
else {
if (is_numeric($row["areaaddr"])) {
insert($t,$c = cell());
insert($c,anchor("displaybase.php?&cust=".$cust."&rangeindex=0".
"&areaindex=".$row["areaindex"]."&ipaddr=&descrip=&size=0",
inet_ntoa($row["areaaddr"])));
$export->addCell(inet_ntoa($row["areaaddr"]));
insert($t,$c = cell());
insert($c,text($row["adescrip"]));
$export->addCell($row["adescrip"]);
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>"));
}
else {
insert($t,$c = cell());
insert($c,text(my_("No area")));
$export->addCell(my_("No area"));
insert($t,$c = cell());
insert($c,text(my_("Range not part of area")));
$export->addCell(my_("Range not part of area"));
insert($t,$c = cell());
}
}
insert($t,$c = cell());
insert($c,anchor("displaybase.php?&cust=".$cust."&areaindex=0".
"&rangeindex=".$row["rangeindex"]."&ipaddr=&descrip=&size=0",
inet_ntoa($row["rangeaddr"])));
$export->addCell(inet_ntoa($row["rangeaddr"]));
insert($t,$c = cell());
insert($c,text($row["rangesize"]));
$export->addCell($row["rangesize"]);
insert($t,$c = cell());
insert($c,text(inet_ntoa(inet_aton(ALLNETS)+1 -
$row["rangesize"])."/".inet_bits($row["rangesize"])));
$export->addCell(inet_ntoa(inet_aton(ALLNETS)+1 - $row["rangesize"])."/".inet_bits($row["rangesize"]));
insert($t,$c = cell());
insert($c,text($row["rdescrip"]));
$export->addCell($row["rdescrip"]);
$export->saveRow();
insert($t,$c = cell());
insert($c,block("<small>"));
insert($c,anchor("deleterange.php?rangeindex=".$row["rangeindex"]."&cust=".$cust,
my_("Delete Range"),
$ipplanParanoid ? array("onclick"=>"return confirm('".my_("Are you sure?")."')") : FALSE));
insert($c,block(" | "));
insert($c,anchor("createrange.php?action=modify&rangeindex=".$row["rangeindex"].
"&areaindex=".$row["areaindex"].
"&size=".$row["rangesize"].
"&ipaddr=".inet_ntoa($row["rangeaddr"]).
"&cust=".$cust."&descrip=".urlencode($row["rdescrip"]),
my_("Modify Range")));
insert($c,block("</small>"));
$savearea=$row["areaaddr"];
$cnt++;
}
insert($w,block("<p>"));
insert($w,textb(sprintf(my_("Total records: %u"), $cnt)));
$temp1 = $cnt;
$result=&$ds->ds->Execute("SELECT area.areaaddr,
area.descrip AS adescrip, area.areaindex
FROM area
LEFT JOIN netrange
ON area.areaindex=netrange.areaindex
WHERE area.customer=$cust AND
netrange.areaindex IS NULL
ORDER BY area.areaaddr");
insert($w,heading(3, my_("Areas that have no ranges defined")));
setdefault("cell", FALSE);
// create a table
insert($w,$t = table(array("cols"=>"3",
"class"=>"outputtable")));
// draw heading
setdefault("cell",array("class"=>"heading"));
insert($t,$c = cell());
insert($c,text(my_("Area address")));
insert($t,$c = cell());
insert($c,text(my_("Description")));
insert($t,$c = cell());
insert($c,text(my_("Action")));
$cnt=0;
while($row=$result->FetchRow()) {
$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);
?>
|