diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/nms/util.pm | 33 | ||||
| -rwxr-xr-x | include/nms/web.pm | 14 | 
2 files changed, 26 insertions, 21 deletions
| diff --git a/include/nms/util.pm b/include/nms/util.pm index c97572b..79598d7 100644 --- a/include/nms/util.pm +++ b/include/nms/util.pm @@ -18,6 +18,7 @@ sub parse_switch {  		'mgtmt4' => "$mgtmt4",  		'mgtmt6' => "$mgtmt6",  		'lolid' => "$lolid", +		'ip' => "$mgtmt4",  		'distro' => "$distro"  	);  	%{$ret{'placement'}} = guess_placement($switch); @@ -62,13 +63,13 @@ sub guess_placement {  		my ($e, $s) = ($1, $2);  		$src = "main"; -		$x = int(232 + (($e-1)/2) * 31.1); +		$x = int(292 + (($e-1)/2) * 31.1);  		$y = undef; -		$x += 14 if ($e >= 17); -		$x += 14 if ($e >= 29); -		$x += 14 if ($e >= 45); -		$x += 14 if ($e >= 63); +		$x += 14 if ($e >= 13); +		$x += 14 if ($e >= 25); +		$x += 14 if ($e >= 41); +		$x += 14 if ($e >= 59);  		if ($s > 2) {  			$y = 405 - 120 * ($s-2); @@ -83,17 +84,18 @@ sub guess_placement {  		$y += 45 if $name eq "e1-4";  		$y += 20 if $name eq "e3-4";  		$y += 15 if $name eq "e5-4"; -		$yy -= 25 if $name eq "e11-1"; +		$yy -= 25 if $name eq "e7-1"; +		$y += 10 if $name eq "e5-2"; +		$yy -= 25 if $name eq "e5-2"; +		$y += 20 if ($e >= 81 and $s == 2); +		$yy -= 20 if ($e >= 79 and $s == 1); +		$yy -= 30 if ($e >= 81 and $s == 1); -		#$yy -= 14 if $name eq "e77-1"; -		#$yy -= 28 if $name eq "e79-1"; -		#$yy -= 15 if $name eq "e81-1"; -		#$yy -= 56 if $name eq "e83-1";  	} elsif ($name =~ /^sw(\d+)-creativia$/) {  		my ($s) = ($1);  		$src = "creativia";  		$x = 1535; -		$y = int(130 + 32.2 * $s); +		$y = int(160 + 32.2 * $s);  		$yy = $y + 20;  		if ($s == 1) {  			$xx = $x + 70; @@ -108,14 +110,11 @@ sub guess_placement {  	} elsif ($name =~ /^crew(\d+)-(\d+)$/) {  		my ($s, $n) = ($1, $2);  		$src = "crew"; -		$x = 1023 + 45 * $n; -		$y = int(329 + 20.5 * $s); -		$xx = $x + 45; +		$x = 550 + 65 * $n; +		$y = int(759 + 20.5 * $s); +		$xx = $x + 65;  		$yy = $y + 14; -		if ($s == 1 && $n == 1) { -			$xx += 25; -		}  	} else {  		# Fallback to have _some_ position  		$src = "random"; 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);  	}  } | 
