aboutsummaryrefslogtreecommitdiffstats
path: root/include/nms/web.pm
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2016-03-13 22:04:00 +0100
committerKristian Lyngstol <kristian@bohemians.org>2016-03-13 22:04:00 +0100
commita57fe6b9a707222e0ca1b4e18a542b5b179e6b72 (patch)
treed342d858c8e142dafb76bb5d326ec1ebb3e040b3 /include/nms/web.pm
parent8a89ee32f56e37848ad29be033b095c46b7ce9e3 (diff)
parentfe776bbc6f2e62436acea72f2f3bf027a6138ed8 (diff)
Merge branch 'master' of github.com:tech-server/tgmanage
Diffstat (limited to 'include/nms/web.pm')
-rwxr-xr-xinclude/nms/web.pm14
1 files changed, 10 insertions, 4 deletions
diff --git a/include/nms/web.pm b/include/nms/web.pm
index 74f40c1..0f37a59 100755
--- a/include/nms/web.pm
+++ b/include/nms/web.pm
@@ -7,12 +7,15 @@ use DBI;
use Data::Dumper;
use JSON;
use nms;
+use Digest::SHA;
+use FreezeThaw;
+use URI::Escape;
package nms::web;
use base 'Exporter';
our %get_params;
our %json;
-our @EXPORT = qw(finalize_output json dbh db_safe_quote %get_params get_input %json);
+our @EXPORT = qw(finalize_output json $dbh db_safe_quote %get_params get_input %json);
our $dbh;
our $now;
our $when;
@@ -62,10 +65,12 @@ sub setwhen {
sub finalize_output {
my $query;
- $query = $dbh->prepare ('select ' . $now . ' as time;');
+ my $hash = Digest::SHA::sha512_base64(FreezeThaw::freeze(%json));
+ $query = $dbh->prepare('select to_char(' . $now . ', \'YYYY-MM-DD"T"HH24:MI:SS\') as time;');
$query->execute();
$json{'time'} = $query->fetchrow_hashref()->{'time'};
+ $json{'hash'} = $hash;
printcc;
print "Content-Type: text/jso; charset=utf-8\n\n";
@@ -74,9 +79,10 @@ sub finalize_output {
}
sub populate_params {
- foreach my $hdr (split("&",$ENV{'QUERY_STRING'} || "")) {
+ my $querystring = $ENV{'QUERY_STRING'} || "";
+ foreach my $hdr (split("&",$querystring)) {
my ($key, $value) = split("=",$hdr,"2");
- $get_params{$key} = $value;
+ $get_params{$key} = URI::Escape::uri_unescape($value);
}
}