From c4122b3a6d2777e2f2b22b2e7952f29518d8fe97 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Mon, 20 Apr 2015 11:52:19 +0200 Subject: NMS: Add comment field for switches --- web/nms.gathering.org/switch-comment.pl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 web/nms.gathering.org/switch-comment.pl (limited to 'web/nms.gathering.org/switch-comment.pl') diff --git a/web/nms.gathering.org/switch-comment.pl b/web/nms.gathering.org/switch-comment.pl new file mode 100755 index 0000000..262d625 --- /dev/null +++ b/web/nms.gathering.org/switch-comment.pl @@ -0,0 +1,25 @@ +#! /usr/bin/perl +use CGI qw(fatalsToBrowser); +use DBI; +use lib '../../include'; +use utf8; +use nms; +use strict; +use warnings; +use Data::Dumper; + +my $cgi = CGI->new; + +my $dbh = nms::db_connect(); + +my $data = $dbh->quote($cgi->param('comment') || die ); +my $switch = $dbh->quote($cgi->param('switch') || die ); +my $user = $dbh->quote($cgi->remote_user() || "undefined"); + + +my $q = $dbh->prepare("INSERT INTO switch_comments (time,username,switch,comment) values (now(),$user,(select switch from switches where sysname = $switch limit 1),$data)"); +$q->execute(); + +print $cgi->header(-type=>'text/json; charset=utf-8'); +print "{ 'state': 'ok' }"; + -- cgit v1.2.3