Changeset 531 for trunk/cgi-bin/main.cgi
- Timestamp:
- 10/29/12 18:09:30 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/main.cgi
r530 r531 797 797 } 798 798 799 # Check to see if we can update restricted data800 my $privdata = '';801 if ($IPDBacl{$authuser} =~ /s/) {802 $privdata = ",privdata='$webvar{privdata}'";803 }804 805 799 # Make sure incoming data is in correct format - custID among other things. 806 800 return if !validateInput; 807 801 808 # SQL transaction wrapper 809 eval { 810 # Relatively simple SQL transaction here. 811 my $sql; 812 if (my $pooltype = ($webvar{alloctype} =~ /^(.)i$/) ) { 813 $sql = "UPDATE poolips SET custid='$webvar{custid}',". 814 "city=?,description=?,notes=?,". 815 "circuitid='$webvar{circid}',". 816 "$privdata where ip='$webvar{block}'"; 817 } else { 818 $sql = "UPDATE allocations SET custid='$webvar{custid}',". 819 "city=?,description=?,notes=?,". 820 "circuitid='$webvar{circid}'$privdata,". 821 "type='$webvar{alloctype}',". 822 "swip='".($webvar{swip} eq 'on' ? 'y' : 'n')."' ". 823 "where cidr='$webvar{block}'"; 824 } 825 # Log the details of the change. 826 syslog "debug", $sql; 827 $sth = $ip_dbh->prepare($sql); 828 $sth->execute($webvar{city}, $webvar{desc}, $webvar{notes}); 829 ## node hack 830 if ($webvar{node}) { 831 # done with delete/insert so we don't have to worry about funkyness updating a node ref that isn't there 832 $ip_dbh->do("DELETE FROM noderef WHERE block='$webvar{block}'"); 833 $sth = $ip_dbh->prepare("INSERT INTO noderef (block,node_id) VALUES (?,?)"); 834 $sth->execute($webvar{block},$webvar{node}); 835 } 836 ## end node hack 837 $ip_dbh->commit; 838 }; 839 if ($@) { 840 my $msg = $@; 841 eval { $ip_dbh->rollback; }; 802 my %updargs = ( 803 custid => $webvar{custid}, 804 city => $webvar{city}, 805 description => $webvar{desc}, 806 notes => $webvar{notes}, 807 circuitid => $webvar{circid}, 808 block => $webvar{block}, 809 type => $webvar{alloctype}, 810 ); 811 812 # Semioptional values 813 $updargs{privdata} = $webvar{privdata} if $IPDBacl{$authuser} =~ /s/; 814 $updargs{node} = $webvar{node} if $webvar{node}; 815 816 my ($code,$msg) = updateBlock($ip_dbh, %updargs); 817 818 if ($code eq 'FAIL') { 842 819 syslog "err", "$authuser could not update block/IP '$webvar{block}': '$msg'"; 843 820 $page->param(err => "Could not update block/IP $webvar{block}: $msg"); … … 847 824 # If we get here, the operation succeeded. 848 825 syslog "notice", "$authuser updated $webvar{block}"; 826 ##fixme: log details of the change? old way is in the .debug stream anyway. 849 827 ##fixme: need to wedge something in to allow "update:field" notifications 850 828 ## hmm. how to tell what changed? O_o
Note:
See TracChangeset
for help on using the changeset viewer.