Changeset 507 for branches/stable/cgi-bin
- Timestamp:
- 11/15/11 18:08:14 (13 years ago)
- Location:
- branches/stable/cgi-bin
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/cgi-bin/CommonWeb.pm
r445 r507 52 52 sub printHeader { 53 53 my $title = shift; 54 my $webpath = shift; 54 55 print "Content-type: text/html\n\n"; 55 56 # This doesn't work well. Must investigate. … … 62 63 63 64 $html =~ s/\$\$TITLE\$\$/$title/; 65 $html =~ s/\$\$WEBPATH\$\$/$webpath/g; 64 66 # Necessary for mangling arbitrary bits of the header 65 67 my $i=0; -
branches/stable/cgi-bin/MyIPDB.pm
r445 r507 8 8 # Last update by $Author$ 9 9 ### 10 # Copyright (C) 2004-201 0- Kris Deugau10 # Copyright (C) 2004-2011 - Kris Deugau 11 11 12 12 # don't remove! required for GNU/FHS-ish install from tarball … … 23 23 my $dbhost = 'ipdb-db'; 24 24 25 # Quick workaround for fixed web path. Set this to the absolute web path to 26 # your IPDB install, or leave blank for installation at the webroot. 27 $IPDB::webpath = ''; 28 25 29 # Set some globals declared in IPDB.pm. Most of these only affect mailNotify(). 26 30 # Note that while you *can* leave these at defaults, it's probably a Really Bad Idea. 27 #$IPDB::org_name = " Bob's Big Bonaza";31 #$IPDB::org_name = "Example Corp"; 28 32 #$IPDB::smtphost = '127.0.0.1'; 29 #$IPDB::domain = ' bob.com';33 #$IPDB::domain = 'example.com'; 30 34 #$IPDB::defcustid = '5554242'; 31 35 # Globals for db2rwhois.pl -
branches/stable/cgi-bin/admin.cgi
r506 r507 10 10 # Last update by $Author$ 11 11 ### 12 # Copyright (C) 2004-201 0- Kris Deugau12 # Copyright (C) 2004-2011 - Kris Deugau 13 13 14 14 use strict; … … 54 54 print "Content-Type: text/html\n\n". 55 55 "<html>\n<head>\n\t<title>Access denied</title>\n". 56 qq(\t<link rel="stylesheet" type="text/css" href=" /ip/ipdb.css">\n).57 qq(\t<link rel="stylesheet" type="text/css" href=" /ip/local.css">\n).56 qq(\t<link rel="stylesheet" type="text/css" href="$IPDB::webpath/ipdb.css">\n). 57 qq(\t<link rel="stylesheet" type="text/css" href="$IPDB::webpath/local.css">\n). 58 58 "</head>\n<body>\n". 59 59 qq(Access to this tool is restricted. Contact the <a href="mailto:ipdbadmin\@example.com">IPDB administrator</a> \n). … … 67 67 print "Content-type: text/html\n\n". 68 68 "<html>\n<head>\n\t<title>[IPDB admin tools]</title>\n". 69 qq(\t<link rel="stylesheet" type="text/css" href=" /ip/ipdb.css">\n).70 qq(\t<link rel="stylesheet" type="text/css" href=" /ip/local.css">\n).69 qq(\t<link rel="stylesheet" type="text/css" href="$IPDB::webpath/ipdb.css">\n). 70 qq(\t<link rel="stylesheet" type="text/css" href="$IPDB::webpath/local.css">\n). 71 71 "</head>\n<body>\n". 72 72 "<h2>IPDB - Administrative Tools</h2>\n<hr>\n"; … … 125 125 ); 126 126 } else { 127 print '<a href="/ip/cgi-bin/admin.cgi">Back</a> to main<hr>';127 print qq(<a href="$IPDB::webpath/cgi-bin/admin.cgi">Back</a> to main<hr>); 128 128 } 129 129 … … 213 213 $cities 214 214 </select> 215 <a href="javascript:popNotes(' /ip/newcity.html')">Add new location</a>215 <a href="javascript:popNotes('$IPDB::webpath/newcity.html')">Add new location</a> 216 216 </td> 217 217 </tr> … … 651 651 # 652 652 653 print qq(<hr><a href=" /ip/">Back</a> to main interface</a>\n);653 print qq(<hr><a href="$IPDB::webpath/">Back</a> to main interface</a>\n); 654 654 655 655 printFooter; -
branches/stable/cgi-bin/ipdb.psql
r445 r507 1 DROP DATABASE ipdb; 2 3 CREATE USER ipdb WITH PASSWORD 'ipdbpwd'; 4 5 CREATE DATABASE ipdb; 6 7 -- Need to do this or our triggers don't work. Why do we need to do this? 8 CREATE FUNCTION "plpgsql_call_handler" () RETURNS language_handler AS '$libdir/plpgsql' LANGUAGE C; 9 CREATE TRUSTED LANGUAGE "plpgsql" HANDLER "plpgsql_call_handler"; 10 11 UPDATE pg_database SET datdba=(SELECT usesysid FROM pg_shadow WHERE usename='ipdb') 12 WHERE datname='ipdb'; 13 14 \connect ipdb ipdb 1 -- Initial table setup for IP Database 15 2 16 3 CREATE TABLE "customers" ( … … 32 19 ); 33 20 34 REVOKE ALL on "customers" from PUBLIC;35 GRANT ALL on "customers" to "ipdb";36 37 21 CREATE TABLE "masterblocks" ( 38 22 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY, … … 41 25 "rwhois" character(1) DEFAULT 'n' NOT NULL 42 26 ); 43 44 REVOKE ALL on "masterblocks" from PUBLIC;45 GRANT ALL on "masterblocks" to "ipdb";46 27 47 28 CREATE TABLE "routed" ( … … 52 33 ); 53 34 54 REVOKE ALL on "routed" from PUBLIC;55 GRANT ALL on "routed" to "ipdb";56 GRANT SELECT on "routed" to "ipdb";57 58 35 CREATE TABLE "temp" ( 59 36 "ofs" integer 60 37 ); 61 62 REVOKE ALL on "temp" from PUBLIC;63 GRANT ALL on "temp" to "ipdb";64 38 65 39 CREATE TABLE "freeblocks" ( … … 69 43 "routed" character(1) DEFAULT 'n' 70 44 ); 71 72 REVOKE ALL on "freeblocks" from PUBLIC;73 GRANT ALL on "freeblocks" to "ipdb";74 45 75 46 CREATE TABLE "poolips" ( … … 90 61 ); 91 62 92 REVOKE ALL on "poolips" from PUBLIC;93 GRANT ALL on "poolips" to "ipdb";94 95 63 CREATE TABLE "allocations" ( 96 64 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY, … … 109 77 ); 110 78 111 REVOKE ALL on "allocations" from PUBLIC;112 GRANT ALL on "allocations" to "ipdb";113 114 79 CREATE VIEW "searchme" as SELECT allocations.cidr, allocations.custid, allocations."type", allocations.city, allocations.description, allocations.notes, allocations.oldcustid, allocations.circuitid FROM allocations UNION SELECT poolips.ip, poolips.custid, poolips.type, poolips.city, poolips.description, poolips.notes, poolips.oldcustid, poolips.circuitid FROM poolips; 115 116 REVOKE ALL on "searchme" from PUBLIC;117 GRANT ALL on "searchme" to "ipdb";118 80 119 81 CREATE TABLE "alloctypes" ( … … 167 129 \. 168 130 169 REVOKE ALL on "alloctypes" from PUBLIC;170 GRANT ALL on "alloctypes" to "ipdb";171 172 131 CREATE TABLE "cities" ( 173 132 "id" serial NOT NULL PRIMARY KEY, … … 175 134 "routing" character(1) DEFAULT 'n' NOT NULL 176 135 ); 177 178 REVOKE ALL on "cities" from PUBLIC;179 GRANT ALL on "cities" to "ipdb";180 136 181 137 -- -
branches/stable/cgi-bin/main.cgi
r506 r507 7 7 # Last update by $Author$ 8 8 ### 9 # Copyright (C) 2004-201 0- Kris Deugau9 # Copyright (C) 2004-2011 - Kris Deugau 10 10 11 11 use strict; … … 50 50 51 51 # Headerize! Make sure we replace the $$EXTRA0$$ bit as needed. 52 printHeader('', ($IPDBacl{$authuser} =~ /a/ ?53 '<td align=right><a href=" /ip/cgi-bin/main.cgi?action=assign">Add new assignment</a>' : ''52 printHeader('', $IPDB::webpath, ($IPDBacl{$authuser} =~ /a/ ? 53 '<td align=right><a href="'.$IPDB::webpath.'/cgi-bin/main.cgi?action=assign">Add new assignment</a>' : '' 54 54 )); 55 55 … … 73 73 } else { 74 74 open HTML, "<../addmaster.html"; 75 print while <HTML>; 75 my $html = join('',<HTML>); 76 close HTML; 77 $html =~ s/\$\$WEBPATH\$\$/$IPDB::webpath/g; 78 print $html; 76 79 } 77 80 } elsif ($webvar{action} eq 'newmaster') { … … 136 139 my $html = join('',<HTML>); 137 140 close HTML; 141 $html =~ s/\$\$WEBPATH\$\$/$IPDB::webpath/g; 138 142 139 143 $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id"); … … 168 172 169 173 print qq(<div align=right style="position: absolute; right: 30px;">). 170 qq(<a href=" /ip/cgi-bin/admin.cgi">Admin tools</a></div><br>\n)174 qq(<a href="$IPDB::webpath/cgi-bin/admin.cgi">Admin tools</a></div><br>\n) 171 175 if $IPDBacl{$authuser} =~ /A/; 172 176 … … 263 267 my $count=0; 264 268 foreach my $master (@masterblocks) { 265 my @row = ("<a href=\" /ip/cgi-bin/main.cgi?action=showmaster&block=$master\">$master</a>",269 my @row = ("<a href=\"$IPDB::webpath/cgi-bin/main.cgi?action=showmaster&block=$master\">$master</a>", 266 270 $routed{"$master"}, $allocated{"$master"}, $free{"$master"}, 267 271 ( ($bigfree{"$master"} eq '') ? ("<NONE>") : ("/".$bigfree{"$master"}) ) … … 274 278 print "</table>\n"; 275 279 if ($IPDBacl{$authuser} =~ /a/) { 276 print qq(<a href=" /ip/cgi-bin/main.cgi?action=addmaster">Add new master block</a><br><br>\n);280 print qq(<a href="$IPDB::webpath/cgi-bin/main.cgi?action=addmaster">Add new master block</a><br><br>\n); 277 281 } 278 282 print "Note: Free blocks noted here include both routed and unrouted blocks.\n"; … … 348 352 my $count=0; 349 353 foreach my $master (@localmasters) { 350 my @row = ("<a href=\" /ip/cgi-bin/main.cgi?action=showrouted&block=$master\">$master</a>",354 my @row = ("<a href=\"$IPDB::webpath/cgi-bin/main.cgi?action=showrouted&block=$master\">$master</a>", 351 355 $routed{"$master"}, $allocated{"$master"}, 352 356 $free{"$master"}, … … 363 367 qq($master.</div>\n). 364 368 ($IPDBacl{$authuser} =~ /d/ ? 365 qq(<form action=" /ip/cgi-bin/main.cgi" method=POST>\n).369 qq(<form action="$IPDB::webpath/cgi-bin/main.cgi" method=POST>\n). 366 370 qq(<input type=hidden name=action value="delete">\n). 367 371 qq(<input type=hidden name=block value="$master">\n). … … 437 441 # Prefix subblocks with "Sub " 438 442 my @row = ( (($data[2] =~ /^.r$/) ? 'Sub ' : ''). 439 qq(<a href=" /ip/cgi-bin/main.cgi?action=edit&block=$data[0]&reallyblock=1">$data[0]</a>),443 qq(<a href="$IPDB::webpath/cgi-bin/main.cgi?action=edit&block=$data[0]&reallyblock=1">$data[0]</a>), 440 444 $data[1], $disp_alloctypes{$data[2]}, $data[3], 441 445 ($data[4] eq 'y' ? ($ncust == 0 ? 'Yes<small>*</small>' : 'Yes') : 'No'), $data[5]); 442 446 # If the allocation is a pool, allow listing of the IPs in the pool. 443 447 if ($data[2] =~ /^.[pd]$/) { 444 $row[0] .= ' <a href=" /ip/cgi-bin/main.cgi?action=listpool'.448 $row[0] .= ' <a href="$IPDB::webpath/cgi-bin/main.cgi?action=listpool'. 445 449 "&pool=$data[0]\">List IPs</a>"; 446 450 } … … 459 463 qq($master.</div></center>\n). 460 464 ($IPDBacl{$authuser} =~ /d/ ? 461 qq(<form action=" /ip/cgi-bin/main.cgi" method=POST>\n).465 qq(<form action="$IPDB::webpath/cgi-bin/main.cgi" method=POST>\n). 462 466 qq(<input type=hidden name=action value="delete">\n). 463 467 qq(<input type=hidden name=block value="$master">\n). … … 484 488 # Include some HairyPerl(TM) to prefix subblocks with "Sub " 485 489 my @row = ((($data[1] ne 'y' && $data[1] ne 'n') ? 'Sub ' : ''). 486 ($IPDBacl{$authuser} =~ /a/ ? qq(<a href=" /ip/cgi-bin/main.cgi?action=assign&block=$cidr&fbtype=$data[1]">$cidr</a>) : $cidr),490 ($IPDBacl{$authuser} =~ /a/ ? qq(<a href="$IPDB::webpath/cgi-bin/main.cgi?action=assign&block=$cidr&fbtype=$data[1]">$cidr</a>) : $cidr), 487 491 $cidr->range); 488 492 printRow(\@row, 'color1') if ($count%2 == 0); … … 540 544 # -> if $data[2] (aka poolips.available) == 'n' then we print the unassign link 541 545 # else we print a blank space 542 my @row = ( qq(<a href=" /ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>),546 my @row = ( qq(<a href="$IPDB::webpath/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 543 547 $data[1],$data[2],$data[3], 544 548 ( (($data[2] eq 'n') && ($IPDBacl{$authuser} =~ /d/)) ? 545 ("<a href=\" /ip/cgi-bin/main.cgi?action=delete&block=$data[0]&".549 ("<a href=\"$IPDB::webpath/cgi-bin/main.cgi?action=delete&block=$data[0]&". 546 550 "alloctype=$data[4]\">Unassign this IP</a>") : 547 551 (" ") ) … … 577 581 $html =~ s|\$\$MASKBITS\$\$|$block->masklen|; 578 582 my $typelist = ''; 583 584 $html =~ s|\$\$WEBPATH\$\$|$IPDB::webpath|g; 579 585 580 586 # This is a little dangerous, as it's *theoretically* possible to … … 607 613 $html = join('',<HTML>); 608 614 close HTML; 615 $html =~ s|\$\$WEBPATH\$\$|$IPDB::webpath|g; 609 616 my $masterlist = "<select name=allocfrom><option selected>-</option>\n"; 610 617 foreach my $master (@masterblocks) { … … 1218 1225 1219 1226 # Link back to browse-routed or list-pool page on "Update complete" page. 1220 my $backlink = " /ip/cgi-bin/main.cgi?action=";1227 my $backlink = "$IPDB::webpath/cgi-bin/main.cgi?action="; 1221 1228 my $cblock; # to contain the CIDR of the container block we're retrieving. 1222 1229 my $sql; … … 1406 1413 sub exitError { 1407 1414 my $errStr = $_[0]; 1408 printHeader('', '');1415 printHeader('', $IPDB::webpath, ''); 1409 1416 print qq(<center><p class="regular"> $errStr </p> 1410 1417 <input type="button" value="Back" onclick="history.go(-1)"> -
branches/stable/cgi-bin/search.cgi
r445 r507 9 9 # Last update by $Author$ 10 10 ### 11 # Copyright 2005-201 0- Kris Deugau11 # Copyright 2005-2011 - Kris Deugau 12 12 13 13 use strict; … … 64 64 65 65 # Headerize! Make sure we replace the $$EXTRA0$$ bit as needed. 66 printHeader('', ($IPDBacl{$authuser} =~ /a/ ?67 '<td align=right><a href=" /ip/cgi-bin/main.cgi?action=assign">Add new assignment</a></td>' : ''66 printHeader('', $IPDB::webpath, ($IPDBacl{$authuser} =~ /a/ ? 67 '<td align=right><a href="'.$IPDB::webpath.'/cgi-bin/main.cgi?action=assign">Add new assignment</a></td>' : '' 68 68 )); 69 69 … … 244 244 $html = join('',<HTML>); 245 245 close HTML; 246 $html =~ s/\$\$WEBPATH\$\$/$IPDB::webpath/g; 246 247 247 248 # Generate table of types … … 446 447 # Another bit of HairyPerl(TM) to prefix subblocks with "Sub" 447 448 my @row = (($data[2] =~ /^.r$/ ? 'Sub ' : ''). 448 qq(<a href=" /ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>),449 qq(<a href="$IPDB::webpath/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 449 450 $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]); 450 451 # Allow listing of pool if desired/required. 451 452 if ($data[2] =~ /^.[pd]$/) { 452 $row[0] .= ' <a href=" /ip/cgi-bin/main.cgi?action=listpool'.453 $row[0] .= ' <a href="'.$IPDB::webpath.'/cgi-bin/main.cgi?action=listpool'. 453 454 "&pool=$data[0]\">List IPs</a>"; 454 455 } … … 474 475 print "<b>$i </b>\n"; 475 476 } else { 476 print qq(<a href=" /ip/cgi-bin/search.cgi?page=$i&stype=$webvar{stype}&);477 print qq(<a href="$IPDB::webpath/cgi-bin/search.cgi?page=$i&stype=$webvar{stype}&); 477 478 if ($webvar{stype} eq 'c') { 478 479 print "cidr=$webvar{cidr}&custid=$webvar{custid}&desc=$webvar{desc}&". -
branches/stable/cgi-bin/snCalc.cgi
r360 r507 8 8 9 9 #file snCalc.cgi little subnet calculator app 10 use MyIPDB; 10 11 11 12 my %webvar = parse_post(); … … 17 18 my $start = join('', <HTML>); 18 19 close(HTML); 20 $start =~ s/\$\$WEBPATH\$\$/$IPDB::webpath/g; 19 21 print $start; 20 22
Note:
See TracChangeset
for help on using the changeset viewer.