Updated roagen.php - Added inline comments

This commit is contained in:
netravnen 2018-12-10 18:54:30 +01:00 committed by Christoffer
parent 7b1699d3ec
commit 6a47400c31

View file

@ -1,13 +1,26 @@
<?php <?php
// Before we begin. Ensure registry repository is up-to-date
echo shell_exec("/usr/bin/git -C ../registry/ pull origin master:master 2>&1"); echo shell_exec("/usr/bin/git -C ../registry/ pull origin master:master 2>&1");
/*
* Function:
* startsWith( $string, 'word')
*
* Find lines beginning with 'word'.
*/
function startsWith($haystack, $needle) function startsWith($haystack, $needle)
{ {
$length = strlen($needle); $length = strlen($needle);
return (substr($haystack, 0, $length) === $needle); return (substr($haystack, 0, $length) === $needle);
} }
/*
* Function:
* endsWith( $string, 'word')
*
* Find lines ending with 'word'.
*/
function endsWith($haystack, $needle) function endsWith($haystack, $needle)
{ {
$length = strlen($needle); $length = strlen($needle);
@ -18,10 +31,20 @@ function endsWith($haystack, $needle)
return (substr($haystack, -$length) === $needle); return (substr($haystack, -$length) === $needle);
} }
// Create empty array $roas
$roas = array(); $roas = array();
/*
*
* IPv6 route objects
*
*/
// Set directory for which all files are to be scanned
$files = scandir('../registry/data/route6/'); $files = scandir('../registry/data/route6/');
$h = 0; // count up when reading new file $h = 0; // count up when reading new file
$i = 0; $i = 0; // used when loop through sub-arrays. I.e. when route objects have more than one listed origin asn
foreach($files as $file) foreach($files as $file)
{ {
@ -81,12 +104,22 @@ foreach($files as $file)
} }
} }
} }
fclose($handle); fclose($handle); // close $file when finished reading data
$h++; $h++;
} }
/*
*
* IPv4 route objects
*
*/
// Set directory for which all files are to be scanned
$files = scandir('../registry/data/route/'); $files = scandir('../registry/data/route/');
$h = 0; // count up when reading new file
$i = 0; // used when loop through sub-arrays. I.e. when route objects have more than one listed origin asn
foreach($files as $file) foreach($files as $file)
{ {
$handle = fopen("../registry/data/route/$file", "r"); $handle = fopen("../registry/data/route/$file", "r");
@ -142,7 +175,7 @@ foreach($files as $file)
} }
} }
} }
fclose($handle); fclose($handle); // close $file when finished reading data
$h++; $h++;
} }