diff options
author | khoff <khoff> | 2004-11-24 18:28:08 +0000 |
---|---|---|
committer | khoff <khoff> | 2004-11-24 18:28:08 +0000 |
commit | 6c6fb883997516b5369fe697ed79079a38f6c742 (patch) | |
tree | 353188fecb7e2f91b4f09cedc122e4444383efd3 | |
parent | 0613949cb9bf987f49114a42a74a9d8b68a31fc1 (diff) |
Added IP address search.
-rw-r--r-- | httemplate/index.html | 1 | ||||
-rwxr-xr-x | httemplate/search/svc_broadband.cgi | 96 |
2 files changed, 97 insertions, 0 deletions
diff --git a/httemplate/index.html b/httemplate/index.html index 0b968cf65..5189df97e 100644 --- a/httemplate/index.html +++ b/httemplate/index.html @@ -34,6 +34,7 @@ <FORM ACTION="search/cust_main.cgi" METHOD="POST"><INPUT TYPE="hidden" NAME="phone_on" VALUE="1">Phone # <INPUT TYPE="text" NAME="phone_text"><INPUT TYPE="submit" VALUE="Search"></FORM> <BR><FORM ACTION="search/svc_acct.cgi" METHOD="POST">Username <INPUT TYPE="text" NAME="username"><SELECT NAME="username_type"><OPTION VALUE="All">(all)</OPTION><OPTION>Fuzzy</OPTION><OPTION>Substring</OPTION><OPTION SELECTED>Exact</OPTION></SELECT><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/svc_acct.cgi?username">all accounts by username</A> or <A HREF="search/svc_acct.cgi?uid">uid</A></FORM> <BR><FORM ACTION="search/svc_domain.cgi" METHOD="POST">Domain <INPUT TYPE="text" NAME="domain"><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/svc_domain.cgi?domain">all domains</A></FORM> + <BR><FORM ACTION="search/svc_broadband.cgi" METHOD="POST">IP Address <INPUT TYPE="text" NAME="ip_addr"><INPUT TYPE="submit" VALUE="Search"> or <A HREF="search/svc_broadband.cgi?svcnum">all services by svcnum</A> or <A HREF="search/svc_broadband.cgi?blocknum">address block</A></FORM> <BR><A HREF="search/svc_forward.cgi?svcnum">all mail forwards by svcnum</A><BR> <BR><A HREF="search/svc_www.cgi?svcnum">all virtual hosts by svcnum</A><BR> <BR><A HREF="search/svc_external.cgi?svcnum">all external services by svcnum</A><BR> diff --git a/httemplate/search/svc_broadband.cgi b/httemplate/search/svc_broadband.cgi new file mode 100755 index 000000000..efadce600 --- /dev/null +++ b/httemplate/search/svc_broadband.cgi @@ -0,0 +1,96 @@ +<% + +my $conf = new FS::Conf; + +my($query)=$cgi->keywords; +$query ||= ''; #to avoid use of unitialized value errors +my(@svc_broadband,$sortby); +if ( $query eq 'svcnum' ) { + $sortby=\*svcnum_sort; + @svc_broadband=qsearch('svc_broadband',{}); +} elsif ( $query eq 'blocknum' ) { + $sortby=\*blocknum_sort; + @svc_broadband=qsearch('svc_broadband',{}); +} else { + $cgi->param('ip_addr') =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/; + my($ip_addr)=$1; + @svc_broadband = qsearchs('svc_broadband',{'ip_addr'=>$ip_addr}); +} + +my %routerbyblock = (); +foreach my $router (qsearch('router', {})) { + foreach ($router->addr_block) { + $routerbyblock{$_->blocknum} = $router; + } +} + +if ( scalar(@svc_broadband) == 1 ) { + print $cgi->redirect(popurl(2). "view/svc_broadband.cgi?". $svc_broadband[0]->svcnum); + #exit; +} elsif ( scalar(@svc_broadband) == 0 ) { +%> +<!-- mason kludge --> +<% + eidiot "No matching ip address found!\n"; +} else { +%> +<!-- mason kludge --> +<% + my($total)=scalar(@svc_broadband); + print header("IP Address Search Results",''), <<END; + + $total matching broadband services found + <TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0> + <TR> + <TH>Service #</TH> + <TH>Router</TH> + <TH>IP Address</TH> + </TR> +END + + foreach my $svc_broadband ( + sort $sortby (@svc_broadband) + ) { + my($svcnum,$ip_addr,$routername,$routernum)=( + $svc_broadband->svcnum, + $svc_broadband->ip_addr, + $routerbyblock{$svc_broadband->blocknum}->routername, + $routerbyblock{$svc_broadband->blocknum}->routernum, + ); + + my $rowspan = 1; + + print <<END; + <TR> + <TD ROWSPAN=$rowspan><A HREF="${p}view/svc_broadband.cgi?$svcnum">$svcnum</A></TD> + <TD ROWSPAN=$rowspan><A HREF="${p}view/router.cgi?$routernum">$routername</A></TD> + <TD ROWSPAN=$rowspan><A HREF="${p}view/svc_broadband.cgi?$svcnum">$ip_addr</A></TD> +END + + #print @rows; + print "</TR>"; + + } + + print <<END; + </TABLE> + </BODY> +</HTML> +END + +} + +sub svcnum_sort { + $a->getfield('svcnum') <=> $b->getfield('svcnum'); +} + +sub blocknum_sort { + if ($a->getfield('blocknum') == $b->getfield('blocknum')) { + $a->getfield('ip_addr') cmp $b->getfield('ip_addr'); + } else { + $a->getfield('blocknum') cmp $b->getfield('blocknum'); + } +} + + +%> |