aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xweb/nms.gathering.org/api/private/which-switch-am-i-on23
1 files changed, 19 insertions, 4 deletions
diff --git a/web/nms.gathering.org/api/private/which-switch-am-i-on b/web/nms.gathering.org/api/private/which-switch-am-i-on
index 4adfb2b..82436ea 100755
--- a/web/nms.gathering.org/api/private/which-switch-am-i-on
+++ b/web/nms.gathering.org/api/private/which-switch-am-i-on
@@ -5,11 +5,26 @@ use lib '../../../../include';
use nms::web;
use strict;
use warnings;
+use Data::Dumper;
-my $query = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,state,username,id,comment from switch_comments natural join switches where state != \'delete\' order by time desc');
+#my $query = $nms::web::dbh->prepare("select * from switches where '185.110.150.7' << subnet4");
+my $query = $nms::web::dbh->prepare("select * from switches where '88.92.5.67' << subnet4");
$query->execute();
-while (my $ref = $query->fetchrow_hashref()) {
- push @{$nms::web::json{'comments'}{$ref->{'sysname'}}{'comments'}},$ref;
+
+print "Cache-Control: max-age=0";
+print "Content-Type: text/html";
+print "\n\n";
+
+# get user ip from somewhere.
+# HTTP_X_FORWARDED_FOR is set by varnish. When using varnish, the REMOTE_ADDR will always be localhost.
+my $addr = $ENV{HTTP_X_FORWARDED_FOR} // $ENV{REMOTE_ADDR};
+print "-:" . $addr ."\n";
+
+
+# add start html: header + body etc.
+
+while ( my $ref = $query->fetchrow_hashref() ) {
+ print $ref->{sysname}. " @ " . $ref->{distro};
}
-nms::web::finalize_output();
+# add end html