aboutsummaryrefslogtreecommitdiffstats
path: root/web/api/public/config
blob: 0f0d3229c5b60f3c5be17ffa28c246a9f163e896 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! /usr/bin/perl
# vim:ts=8:sw=8

use DBI;
use lib '/opt/gondul/include';
use nms;
use nms::web;
use strict;
use warnings;
use Data::Dumper;

$nms::web::cc{'max-age'} = "3600";

my $hostname = $ENV{'HTTP_HOST'} || "";
my $q2 = $nms::web::dbh->prepare('select id, publicvhost, shortname, data from config order by id desc limit 1;');

$q2->execute();
$nms::web::json{'config'}{'data'} = 0;
$nms::web::json{'config'}{'shortname'} = "notset";
$nms::web::json{'config'}{'publicvhost'} = "notset";
while (my $ref = $q2->fetchrow_hashref()) {
	$nms::web::json{'config'} = $ref;
	$nms::web::json{'config'}{'data'} = JSON::XS::decode_json($ref->{'data'});
	if ($ref->{'publicvhost'} eq $hostname) {
		$nms::web::json{'config'}{'public'} = "true";
	} else {
		$nms::web::json{'config'}{'public'} = "false";
	}
}

finalize_output();