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 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
|
<?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("../config.php");
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 BasicAuthenticator(ADMINREALM, REALMERROR);
$auth->addUser(ADMINUSER, ADMINPASSWD);
// And now perform the authentication
$grps=$auth->authenticate();
// 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
WHERE customer=$cust") and
$result=&$ds->ds->Execute("DELETE FROM custinfo
WHERE customer=$cust") and
$result=&$ds->ds->Execute("DELETE FROM ipaddr
WHERE baseindex IN (SELECT baseindex FROM base WHERE customer=$cust)") and
$result=&$ds->ds->Execute("DELETE FROM ipaddradd
WHERE baseindex IN (SELECT baseindex FROM base WHERE customer=$cust)") and
$result=&$ds->ds->Execute("DELETE FROM base
WHERE customer=$cust") and
$result=&$ds->ds->Execute("DELETE FROM custadd
WHERE customer=$cust") and
$result=&$ds->ds->Execute("DELETE FROM revdns
WHERE customer=$cust") and
$result=&$ds->ds->Execute("DELETE FROM area
WHERE customer=$cust") and
$result=&$ds->ds->Execute("DELETE FROM netrange
WHERE customer=$cust") and
$result=&$ds->ds->Execute("DELETE FROM fwdzone
WHERE customer=$cust") and
$result=&$ds->ds->Execute("DELETE FROM fwdzoneadd
WHERE customer=$cust") and
$result=&$ds->ds->Execute("DELETE FROM fwdzonerec
WHERE customer=$cust") and
$result=&$ds->ds->Execute("DELETE FROM zones
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"));
if ($result) {
$ds->DbfTransactionEnd();
insert($w,text(my_("Requested IP addresses cleared!")));
}
else {
insert($w,text(my_("Requested IP addresses could not be cleared.")));
}
}
// delete one requested ip address
if ($action=="deleterequestidx") {
$ds->DbfTransactionStart();
$result=&$ds->ds->Execute("DELETE FROM requestip
WHERE requestindex=$requestindex");
$ds->AuditLog(my_("Requested IP address deleted").": ".$requestdesc);
if ($result) {
$ds->DbfTransactionEnd();
insert($w,textbr(my_("Requested IP address deleted!")));
}
else {
insert($w,textbr(my_("Requested IP address could not be deleted.")));
}
$action="reqindex";
}
if ($action=="deleteaudit") {
$ds->DbfTransactionStart();
$result=&$ds->ds->Execute("DELETE FROM auditlog");
$ds->AuditLog(my_("Audit log cleared"));
if ($result) {
$ds->DbfTransactionEnd();
insert($w,text(my_("Audit log cleared!")));
}
else {
insert($w,text(my_("Audit log could not be cleared.")));
}
}
if ($action=="custindex") {
$result=$ds->GetCustomer();
$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, "&action=custindex", "custdescrip");
$totcnt++;
}
// create a table
insert($w,$t = table(array("cols"=>"4",
"class"=>"outputtable")));
// draw heading
setdefault("cell",array("class"=>"heading"));
insert($t,$c = cell());
if (!empty($vars))
insert($c,anchor($vars, "<<"));
insert($c,text(my_("Customer description")));
insert($t,$c = cell());
insert($c,text(my_("Group name")));
insert($t,$c = cell());
insert($c,text(my_("Customer index")));
insert($t,$ck = cell());
insert($ck,text(my_("Action")));
//capture data for the export view functionality
$export = new exportForm();
$export->addRow(array("customer_description", "group_name", "customer_ID"));
$export->saveRow();
$cnt=0;
while($row = $result->FetchRow()) {
if (strtolower($row["custdescrip"]) == "all") {
continue;
}
$export->addRow(NULL);
setdefault("cell",array("class"=>color_flip_flop()));
insert($t,$c = cell());
insert($c,text($row["custdescrip"]));
$export->addCell($row["custdescrip"]);
insert($t,$c = cell());
insert($c,text($row["admingrp"]));
$export->addCell($row["admingrp"]);
insert($t,$c = cell());
insert($c,text($row["customer"]));
$export->addCell($row["customer"]);
$export->saveRow();
insert($t,$c = cell());
insert($c,block("<small>"));
insert($c,anchor($_SERVER["PHP_SELF"]."?action=deletecustomer&cust=".$row["customer"],
my_("Delete customer/AS"),
array("onclick"=>"return confirm('".my_("Are you sure? THIS ACTION WILL DELETE ALL TRACES OF THE CUSTOMER INCLUDING ALL SUBNETS, AREAS, RANGES AND DNS ZONES!")."')")));
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, "&action=custindex", "custdescrip" );
if (!empty($vars) and !$printed) {
insert($ck,anchor($vars, ">>"));
$printed=1;
}
}
// create the export view form
$export->setInfo(array(array("maintenance_page"),
array("customer index")));
$export->createExportForm($w, NULL);
}
if ($action=="reqindex") {
$result=&$ds->ds->Execute("SELECT requestip.requestindex, requestip.requestdesc,
requestip.lastmod, requestip.userinf, requestip.descrip, customer.custdescrip
FROM requestip, customer
WHERE customer.customer=requestip.customer
ORDER BY customer.custdescrip");
$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, "&action=reqindex", "requestdesc");
$totcnt++;
}
// create a table
insert($w,$t = table(array("cols"=>"6",
"class"=>"outputtable")));
// draw heading
setdefault("cell",array("class"=>"heading"));
insert($t,$c = cell());
if (!empty($vars))
insert($c,anchor($vars, "<<"));
insert($c,text(my_("Customer description")));
insert($t,$c = cell());
insert($c,text(my_("Request description")));
insert($t,$c = cell());
insert($c,text(my_("User")));
insert($t,$c = cell());
insert($c,text(my_("User description")));
insert($t,$c = cell());
insert($c,text(my_("Request date")));
insert($t,$ck = cell());
insert($ck,text(my_("Action")));
//capture data for the export view functionality
$export = new exportForm();
$export->addRow(array("customer_description", "request_description", "user", "user_description", "request_date"));
$export->saveRow();
$cnt=0;
while($row = $result->FetchRow()) {
$export->addRow(NULL);
setdefault("cell",array("class"=>color_flip_flop()));
insert($t,$c = cell());
insert($c,text($row["custdescrip"]));
$export->addCell($row["custdescrip"]);
insert($t,$c = cell());
insert($c,text($row["requestdesc"]));
$export->addCell($row["requestdesc"]);
insert($t,$c = cell());
insert($c,text($row["userinf"]));
$export->addCell($row["userinf"]);
insert($t,$c = cell());
insert($c,text($row["descrip"]));
$export->addCell($row["descrip"]);
insert($t,$c = cell());
insert($c,block($result->UserTimeStamp($row["lastmod"], "M d Y H:i:s")));
$export->addCell($row["lastmod"]);
$export->saveRow();
insert($t,$c = cell());
insert($c,block("<small>"));
insert($c,anchor($_SERVER["PHP_SELF"]."?action=deleterequestidx&block=$block&requestindex=".$row["requestindex"]."&requestdesc=".urlencode($row["requestdesc"]),
my_("Delete request")));
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, "&action=reqindex", "requestdesc" );
if (!empty($vars) and !$printed) {
insert($ck,anchor($vars, ">>"));
$printed=1;
}
}
//create the export view form
$export->setInfo(array(array("maintenance_page"),
array("request index")));
$export->createExportForm($w, NULL);
}
// display opening text
insert($w,heading(3, "$title."));
insert($w,textbr(my_("Perform the selected IPplan database maintenance.")));
// start form
insert($w, $f = form(array("method"=>"post",
"action"=>$_SERVER["PHP_SELF"])));
insert($f,hidden(array("name"=>"action",
"value"=>"custindex")));
insert($f,generic("p"));
insert($f,submit(array("value"=>my_("Display list of customer indexes"))));
// start form
insert($w, $f = form(array("method"=>"post",
"action"=>$_SERVER["PHP_SELF"])));
insert($f,hidden(array("name"=>"action",
"value"=>"reqindex")));
insert($f,generic("p"));
insert($f,submit(array("value"=>my_("View request list"))));
// start form
insert($w, $f = form(array("method"=>"post",
"action"=>$_SERVER["PHP_SELF"])));
insert($f,hidden(array("name"=>"action",
"value"=>"deleterequest")));
insert($f,submit(array("value"=>my_("Clear IP address request list"))));
// start form
insert($w, $f = form(array("method"=>"post",
"action"=>$_SERVER["PHP_SELF"])));
insert($f,hidden(array("name"=>"action",
"value"=>"deleteaudit")));
insert($f,generic("p"));
insert($f,submit(array("value"=>my_("Clear Audit Log"))));
printhtml($p);
?>
|