Ignore:
Timestamp:
08/25/10 15:16:21 (14 years ago)
Author:
Kris Deugau
Message:

/branches/htmlform

Convert finalDelete to template
Add missing node info on update page
Fix backlink on update page
Tweak edit page to use the right name for the node dropdown
See #3.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/htmlform/cgi-bin/main.cgi

    r474 r476  
    11021102mailNotify($ip_dbh, 's:swi', "SWIPed: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
    11031103        "$webvar{block} had SWIP status changed to \"Yes\" by $authuser") if $webvar{swip} eq 'on';
    1104   open (HTML, "../updated.html")
    1105         or croak "Could not open updated.html :$!";
    1106   my $html = join('', <HTML>);
     1104
     1105## node hack
     1106  if ($webvar{node} && $webvar{node} ne '-') {
     1107    $sth = $ip_dbh->prepare("SELECT node_name FROM nodes WHERE node_id=?");
     1108    $sth->execute($webvar{node});
     1109    my ($nodename) = $sth->fetchrow_array();
     1110    $page->param(nodename => $nodename);
     1111  }
     1112## end node hack
    11071113
    11081114  # Link back to browse-routed or list-pool page on "Update complete" page.
    1109   my $backlink = "/ip/cgi-bin/main.cgi?action=";
    11101115  my $cblock;   # to contain the CIDR of the container block we're retrieving.
    11111116  my $sql;
    11121117  if (my $pooltype = ($webvar{alloctype} =~ /^(.)i$/) ) {
     1118    $page->param(backpool => 1);
    11131119    $sql = "select pool from poolips where ip='$webvar{block}'";
    1114     $backlink .= "listpool&pool=";
    11151120  } else {
    11161121    $sql = "select cidr from routed where cidr >>= '$webvar{block}'";
    1117     $backlink .= "showrouted&block=";
    11181122  }
    11191123  # I define there to be no errors on this operation...  so we don't need to check for them.
     
    11231127  $sth->fetch();
    11241128  $sth->finish;
    1125   $backlink .= $cblock;
    1126 
    1127 my $swiptmp = ($webvar{swip} eq 'on' ? 'Yes' : 'No');
    1128   $html =~ s/\$\$BLOCK\$\$/$webvar{block}/g;
    1129   $webvar{city} = $q->escapeHTML($webvar{city});
    1130   $html =~ s/\$\$CITY\$\$/$webvar{city}/g;
    1131   $html =~ s/\$\$ALLOCTYPE\$\$/$webvar{alloctype}/g;
    1132   $html =~ s/\$\$TYPEFULL\$\$/$disp_alloctypes{$webvar{alloctype}}/g;
    1133   $html =~ s/\$\$CUSTID\$\$/$webvar{custid}/g;
    1134   $html =~ s/\$\$SWIP\$\$/$swiptmp/g;
    1135   $webvar{circid} = $q->escapeHTML($webvar{circid});
    1136   $html =~ s/\$\$CIRCID\$\$/$webvar{circid}/g;
    1137   $webvar{desc} = $q->escapeHTML($webvar{desc});
    1138   $html =~ s/\$\$DESC\$\$/$webvar{desc}/g;
    1139   $webvar{notes} = $q->escapeHTML($webvar{notes});
    1140   $html =~ s/\$\$NOTES\$\$/$webvar{notes}/g;
    1141   $html =~ s/\$\$BACKLINK\$\$/$backlink/g;
    1142   $html =~ s/\$\$BACKBLOCK\$\$/$cblock/g;
    1143 
    1144   if ($IPDBacl{$authuser} =~ /s/) {
    1145     $privdata = qq(<tr class="color2"><td valign="top">Restricted data:</td>).
    1146         qq(<td class="regular">).$q->escapeHTML($webvar{privdata}).qq(</td></tr>\n);
    1147   }
    1148   $html =~ s/\$\$PRIVDATA\$\$/$privdata/g;
    1149 
    1150   print $html;
     1129  $page->param(backblock => $cblock);
     1130
     1131  $page->param(cidr => $webvar{block});
     1132  $page->param(city => $webvar{city});
     1133  $page->param(disptype => $disp_alloctypes{$webvar{alloctype}});
     1134  $page->param(custid => $webvar{custid});
     1135  $page->param(swip => $webvar{swip} eq 'on' ? 'Yes' : 'No');
     1136  $page->param(circid => $q->escapeHTML($webvar{circid}));
     1137  $page->param(desc => $q->escapeHTML($webvar{desc}));
     1138  $page->param(notes => $q->escapeHTML($webvar{notes}));
     1139  $webvar{privdata} = ($webvar{privdata} ? $q->escapeHTML($webvar{privdata}) : "&nbsp;");
     1140  $page->param(privdata => $webvar{privdata})
     1141        if $IPDBacl{$authuser} =~ /s/;
    11511142
    11521143} # update()
     
    12411232sub finalDelete {
    12421233  if ($IPDBacl{$authuser} !~ /d/) {
    1243     printError("You shouldn't have been able to get here.  Access denied.");
     1234    $page->param(aclerr => 1);
    12441235    return;
    12451236  }
     
    12501241  my ($code,$msg) = deleteBlock($ip_dbh, $webvar{block}, $webvar{alloctype});
    12511242
     1243  $page->param(block => $webvar{block});
    12521244  if ($code eq 'OK') {
    1253     print "<div class=heading align=center>Success!  $webvar{block} deallocated.</div>\n";
    12541245    syslog "notice", "$authuser deallocated '$webvar{alloctype}'-type netblock $webvar{block}".
    12551246        " $custid, $city, desc='$description'";
     
    12581249        "CustID: $custid\nCity: $city\nDescription: $description\n");
    12591250  } else {
     1251    $page->param(failmsg => $msg);
    12601252    if ($webvar{alloctype} =~ /^.i$/) {
    12611253      syslog "err", "$authuser could not deallocate static IP '$webvar{block}': '$msg'";
    1262       printError("Could not deallocate static IP $webvar{block}: $msg");
    12631254    } else {
    12641255      syslog "err", "$authuser could not deallocate netblock '$webvar{block}': '$msg'";
    1265       printError("Could not deallocate netblock $webvar{block}: $msg");
     1256      $page->param(netblock => 1);
    12661257    }
    12671258  }
Note: See TracChangeset for help on using the changeset viewer.