lib: add constants.php to hold ALL constants. Instead of stuffing contants into define.php

This commit is contained in:
netravnen 2019-01-05 22:55:25 +00:00
parent 88ae0edd07
commit 9c783336e6
4 changed files with 20 additions and 7 deletions

13
lib/constants.php Normal file
View file

@ -0,0 +1,13 @@
<?php
/*
File ONLY used to define contstants with 'define' php function.
*/
define ("MAX_LEN_IPV4", 28);
define ("MAX_LEN_IPV6", 64);
define ("MAX_LEN_IPV4_AS0", 32);
define ("MAX_LEN_IPV6_AS0", 128);
?>

View file

@ -9,8 +9,5 @@ $files4 = scandir ("../registry/data/route/");
// Define array() we are gonna store data inside. // Define array() we are gonna store data inside.
$roas = array(); $roas = array();
define ("MAX_LEN_IPV4", 28);
define ("MAX_LEN_IPV6", 64);
$web_registry_url = 'https://git.dn42.us/dn42/registry/src/master'; $web_registry_url = 'https://git.dn42.us/dn42/registry/src/master';
?> ?>

View file

@ -1,6 +1,7 @@
<?php <?php
// Load lib files. // Load lib files.
require ("lib/constants.php");
require ("lib/define.php"); require ("lib/define.php");
require ("lib/functions.php"); require ("lib/functions.php");
@ -111,7 +112,7 @@ foreach ($raw_array as $sub_array)
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["asn"] = trim ($_asn[0], "AS"); $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["asn"] = trim ($_asn[0], "AS");
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["prefix"] = $_prefix; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["prefix"] = $_prefix;
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["maxPrefixLength"] = ($_asn[0] != "AS0" ? $_maxlength : 128); $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["maxPrefixLength"] = ($_asn[0] != "AS0" ? $_maxlength : MAX_LEN_IPV6_AS0);
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["comment"] = "$web_registry_url/data/inet6num/$prefix[1]_$prefix[2]"; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["comment"] = "$web_registry_url/data/inet6num/$prefix[1]_$prefix[2]";
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["source"] = "$_ta"; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["source"] = "$_ta";
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["mnt-by"] = "$_mnt"; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["mnt-by"] = "$_mnt";
@ -212,7 +213,7 @@ foreach ($raw_array as $sub_array)
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["asn"] = trim ($_asn[0], "AS"); $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["asn"] = trim ($_asn[0], "AS");
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["prefix"] = $_prefix; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["prefix"] = $_prefix;
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["maxPrefixLength"] = ($_asn[0] != "AS0" ? $_maxlength : 32); $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["maxPrefixLength"] = ($_asn[0] != "AS0" ? $_maxlength : MAX_LEN_IPV4_AS0);
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["comment"] = "$web_registry_url/data/inetnum/$prefix[1]_$prefix[2]"; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["comment"] = "$web_registry_url/data/inetnum/$prefix[1]_$prefix[2]";
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["source"] = "$_ta"; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["source"] = "$_ta";
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["mnt-by"] = "$_mnt"; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["mnt-by"] = "$_mnt";

View file

@ -1,5 +1,7 @@
<?php <?php
// Load lib files.
require ("lib/constants.php");
require ("lib/define.php"); require ("lib/define.php");
require ("lib/functions.php"); require ("lib/functions.php");
@ -97,7 +99,7 @@ foreach ($raw_array as $sub_array)
$roas["roas"][$k]["asn"] = $_asn[0]; $roas["roas"][$k]["asn"] = $_asn[0];
$roas["roas"][$k]["prefix"] = $_prefix; $roas["roas"][$k]["prefix"] = $_prefix;
$roas["roas"][$k]["maxLength"] = ($_asn[0] != "AS0" ? $_maxlength : 128); $roas["roas"][$k]["maxLength"] = ($_asn[0] != "AS0" ? $_maxlength : MAX_LEN_IPV6_AS0);
$roas["roas"][$k]["ta"] = $_ta; $roas["roas"][$k]["ta"] = $_ta;
$k++; $k++;
@ -187,7 +189,7 @@ foreach ($raw_array as $sub_array)
$roas["roas"][$k]["asn"] = $_asn[0]; $roas["roas"][$k]["asn"] = $_asn[0];
$roas["roas"][$k]["prefix"] = $_prefix; $roas["roas"][$k]["prefix"] = $_prefix;
$roas["roas"][$k]["maxLength"] = ($_asn[0] != "AS0" ? $_maxlength : 32); $roas["roas"][$k]["maxLength"] = ($_asn[0] != "AS0" ? $_maxlength : MAX_LEN_IPV4_AS0);
$roas["roas"][$k]["ta"] = $_ta; $roas["roas"][$k]["ta"] = $_ta;
$k++; $k++;