From de584bed994024371f89bce200298139f3615296 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Thu, 3 Jan 2019 17:42:03 +0100 Subject: First step to major cleanup Fixes #150 Fixe #88 Closes #3 Probably lots of bugs introduced, will fix ASAP. --- web/api/write/linknet-add | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100755 web/api/write/linknet-add (limited to 'web/api/write/linknet-add') diff --git a/web/api/write/linknet-add b/web/api/write/linknet-add deleted file mode 100755 index 13ccd17..0000000 --- a/web/api/write/linknet-add +++ /dev/null @@ -1,32 +0,0 @@ -#! /usr/bin/perl -# vim:ts=8:sw=8 -use lib '/opt/gondul/include'; -use utf8; -use nms::web qw($dbh db_safe_quote get_input finalize_output); -use strict; -use warnings; - -my $in = get_input(); -my %tmp = %{JSON::XS::decode_json($in)}; - -my $q = $nms::web::dbh->prepare("INSERT INTO linknets (switch1, switch2) VALUES((SELECT switch FROM switches WHERE sysname = ? LIMIT 1), (SELECT switch FROM switches WHERE sysname = ? LIMIT 1));"); -my $sth = $nms::web::dbh->prepare("SELECT linknet FROM linknets WHERE switch1 = (SELECT switch FROM switches WHERE sysname = ? LIMIT 1) and switch2 = (SELECT switch FROM switches WHERE sysname = ? LIMIT 1);"); - -$sth->execute($tmp{'switch1'}, $tmp{'switch2'}); -my $affected = 0; -while ( my @row = $sth->fetchrow_array ) { - $affected += 1; -} - -print "X-affected: $affected\n"; -if ($affected eq 0) { - $q->execute($tmp{'switch1'}, $tmp{'switch2'}); -} - -$dbh->commit; -$nms::web::cc{'max-age'} = '0'; -$nms::web::cc{'stale-while-revalidate'} = '0'; -$nms::web::json{'state'} = 'ok'; - -print "X-ban: /api/public/.*\n"; -finalize_output(); -- cgit v1.2.3