RE: NetReg: Possible NetReg 1.3rc2 bug + suggestions..

New Message Reply Date view Thread view Subject view Author view Attachment view

From: Nathan Lloyd (nlloyd@smumn.edu)
Date: Fri May 16 2003 - 12:48:45 CDT


>===== Original Message From Nathan Lloyd <nlloyd@smumn.edu> =====
Sorry for any confustion, when I originally composed that message it was going
to be for Peter Valian, and I didn't figure he would need an explaination of
how to use this code..

When we wrote this it was just to get something we wanted into the code, I
expect that someone who actually knows perl could clean this up a lot..

There are 2 other parts of this that I failed to mention:
add a line near the beginning of the admin.cgi where it checks the action
field.
(mine looks like this:)
#----------------------------------------------------------------------------\
# Main Function
#----------------------------------------------------------------------------\
  get_input();
  print_header();
  if ($FORM{'action'} eq "SM") { server_manager(); }
  elsif ($FORM{'action'} eq "FC") { find_conf(); }
  elsif ($FORM{'action'} eq "FL") { find_lease(); }
  elsif ($FORM{'action'} eq "SO") { subnet_overview(); }
  elsif ($FORM{'action'} eq "VS") { view_subnet(); }
#---- added form action AR to call our add reserv function
  elsif ($FORM{'action'} eq "AR") { add_reserv(); }
#---- there also has to be a link somewhere with action set to AR
  elsif (!$FORM{'action'}) { subnet_overview(); }
  print_footer();
#----------------------------------------------------------------------------/

also, somewhere in your page you need to make a link that will call the admin
script with action=AR, so yo might add a line like this
printf "<A HREF=$ADMINPATH/admin.cgi?action=AR><b> Add Reservation(s)</A><P>";
to one of your subroutines.. perhapse print_header or print_footer.. it all
depends on where you want the link to show up..

>#-------------SMU-----------------------------------------------------------\
># inserts a "reservation" record (originally written for 1.2)
>#-------------SMU-----------------------------------------------------------\
> sub add_reserv {
> if (($FORM{'host_name'}) && ($FORM{'mac_addy'}) && ($FORM{'platform'})) {
> #User entered host name, mac address, and platform note, check info and
> #add the record (modified from register.cgi::append_host_entry())
> ($SEC,$MIN,$HOUR,$DAY,$MO,$YR) = localtime;
> $YR+=1900; $MO++;
> if ($DAY<10) { $DAY="0$DAY"; }
> if ($MO<10) { $MO="0$MO"; }
> if ($HOUR<10) { $HOUR="0$HOUR"; }
> if ($MIN<10) { $MIN="0$MIN"; }
> if ($SEC<10) { $SEC="0$SEC"; }
> $TIME="$HOUR:$MIN:$SEC";
> #check if MAC_ADDY is already registered
> open (DHCPDCONFNEW, "$DHCPDCONFPATH/dhcpd.conf.new");
> while (<DHCPDCONFNEW>) {
> if ($_ =~ /$FORM{'mac_addy'}/) {
> printf "$FORM{'mac_addy'} Already Exists in DHCPD.CONF.NEW!";
> exit;
> }
> if ($_ =~ /$FORM{'host_name'}/) {
> printf "$FORM{'host_name'} Already Exists in DHCPD.CONF.NEW!";
> exit;
> }
> if (($FORM{'ip_addy'} ne "") && ($_ =~ $FORM{'ip_addy'})) {
> printf "$FORM{'ip_addy'} Already Exists in DHCPD.CONF.NEW!";
> exit;
> }
> }
> close(DHCPDCONFNEW);
> open(LEASES, "$LEASESPATH/dhcpd.leases");
> while (<LEASES>) {
> if (($FORM{'ip_addy'} ne "") && ($_ =~ $FORM{'ip_addy'})) {
> printf "$FORM{'ip_addy'} Already Exists in DHCPD.LEASES!";
> exit;
> }
> }
> close(LEASES);
> $_ = $FORM{'host_name'} ;
> tr/'//d;
> $GOODHOSTNAME = $_;
> open (DHCPDCONFNEW, ">>$DHCPDCONFPATH/dhcpd.conf.new");
> print DHCPDCONFNEW "host $GOODHOSTNAME { hardware ethernet ";
> print DHCPDCONFNEW "$FORM{'mac_addy'} \; ";
> if ($FORM{'ip_addy'} ne "") {
> print DHCPDCONFNEW "fixed-address $FORM{'ip_addy'} \; ";
> }
> print DHCPDCONFNEW "}\#$FORM{'platform'}";
> print DHCPDCONFNEW "\#$YR$MO$DAY $TIME\n";
> close(DHCPDCONFNEW);
> printf "$FORM{'host_name'} $FORM{'mac_addy'} $FORM{'ip_addy'}";
> }
> else {
> #no form data entered, print the entry form
> printf "<form method=get action=$ADMINPATH/admin.cgi>";
> printf "<input type=hidden name=action value=AR>";
> printf "<ul><b> Enter information for Static IP Reservation/Registration
>without an IP Address</b><p>";
> printf "<pre>";
> printf " Hostname: <input type=text name=host_name><P>";
> printf "Mac Address: <input type=text name=mac_addy><P>";
> printf " IP Address: <input type=text name=ip_addy><P>";
> printf "Description: <input type=text name=platform><P>";
> printf "</pre></ul>";
> printf "<input type=submit>";
> }
> }
>#-------------SMU-----------------------------------------------------------/

-Nathan Lloyd
-(nlloyd@smumn.edu)/(507-457-1748)
-Uniface/Cold Fusion Programmer
-Assistant Network Administrator
=Saint Mary's University of Minnesota
=700 Terrace Heights #17
=Winona, MN 55987

**********************************************************************
To unsubscribe from this list, send an e-mail message to
majordomo@southwestern.edu containing a single line with the words:
unsubscribe netreg
Send requests for assistance to: owner-netreg@southwestern.edu
**********************************************************************


New Message Reply Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.4 : Thu Aug 12 2004 - 12:01:39 CDT