servnest/pg-act/ns/loc.php

71 lines
2.1 KiB
PHP
Raw Normal View History

<?php
$values = nsParseCommonRequirements();
if (empty($_POST['lat-min']))
$_POST['lat-min'] = 0;
if (empty($_POST['lat-sec']))
$_POST['lat-sec'] = 0;
if (empty($_POST['lon-min']))
$_POST['lon-min'] = 0;
if (empty($_POST['lon-sec']))
$_POST['lon-sec'] = 0;
if (empty($_POST['size']))
$_POST['size'] = 1;
if (empty($_POST['hp']))
$_POST['hp'] = 10000;
if (empty($_POST['vp']))
$_POST['vp'] = 10;
if (!($_POST['lat-deg'] >= 0 AND $_POST['lat-deg'] <= 90))
output(403, 'Wrong value for <code>lat-deg</code>.');
if (!($_POST['lat-min'] >= 0 AND $_POST['lat-min'] <= 59))
output(403, 'Wrong value for <code>lat-min</code>.');
if (!($_POST['lat-sec'] >= 0 AND $_POST['lat-sec'] <= 59.999))
output(403, 'Wrong value for <code>lat-sec</code>.');
if ($_POST['lat-dir'] !== 'N' AND $_POST['lat-dir'] !== 'S')
output(403, 'Wrong value for <code>lat-dir</code>.');
if (!($_POST['lon-deg'] >= 0 AND $_POST['lon-deg'] <= 180))
output(403, 'Wrong value for <code>lon-deg</code>.');
if (!($_POST['lon-min'] >= 0 AND $_POST['lon-min'] <= 59))
output(403, 'Wrong value for <code>lon-min</code>.');
if (!($_POST['lon-sec'] >= 0 AND $_POST['lon-sec'] <= 59.999))
output(403, 'Wrong value for <code>lon-sec</code>.');
if ($_POST['lon-dir'] !== 'E' AND $_POST['lon-dir'] !== 'W')
output(403, 'Wrong value for <code>lon-dir</code>.');
if (!($_POST['alt'] >= -100000 AND $_POST['alt'] <= 42849672.95))
output(403, 'Wrong value for <code>alt</code>.');
if (!($_POST['size'] >= 0 AND $_POST['size'] <= 90000000))
output(403, 'Wrong value for <code>size</code>.');
if (!($_POST['hp'] >= 0 AND $_POST['hp'] <= 90000000))
output(403, 'Wrong value for <code>hp</code>.');
if (!($_POST['vp'] >= 0 AND $_POST['vp'] <= 90000000))
output(403, 'Wrong value for <code>vp</code>.');
knotcZoneExec($_POST['zone'], [
$values['domain'],
$values['ttl'],
'LOC',
$_POST['lat-deg'],
$_POST['lat-min'],
$_POST['lat-sec'],
$_POST['lat-dir'],
$_POST['lon-deg'],
$_POST['lon-min'],
$_POST['lon-sec'],
$_POST['lon-dir'],
$_POST['alt'] . 'm',
$_POST['size'] . 'm',
$_POST['hp'] . 'm',
$_POST['vp'] . 'm',
]);
output(200, 'Enregistrement ajouté/retiré.');