From 690d942fc8317f296707e90012881d4585b8d00d Mon Sep 17 00:00:00 2001 From: Christoffer Date: Tue, 18 Dec 2018 13:21:26 +0000 Subject: [PATCH] Move JSON encoding of array() to _functions lib --- _functions.php | 12 +++++++++--- rfc8416.php | 5 +---- roagen.php | 7 ++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/_functions.php b/_functions.php index 5d98234..206a163 100755 --- a/_functions.php +++ b/_functions.php @@ -75,8 +75,10 @@ function commitPushToRemotes () echo shell_exec ("./update.sh 2>&1"); } -function writeBirdConfig ($json, $roas) +function writeBirdConfig ($roas) { + $json = json_encode($roas, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); + $fq = fopen ('roa/bird_roa_dn42.conf', 'w'); $fq4 = fopen ('roa/bird4_roa_dn42.conf', 'w'); $fq6 = fopen ('roa/bird6_roa_dn42.conf', 'w'); @@ -106,8 +108,10 @@ function writeBirdConfig ($json, $roas) fclose ($fq6); } -function writeRoutinatorExceptionFile ($json) +function writeRoutinatorExceptionFile ($roas) { + $json = json_encode($roas, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT|JSON_NUMERIC_CHECK); + $fp = fopen('roa/export_rfc8416_dn42.json', 'w'); fwrite($fp, $json); @@ -115,8 +119,10 @@ function writeRoutinatorExceptionFile ($json) fclose($fp); } -function writeExportJSON ($json) +function writeExportJSON ($roas) { + $json = json_encode($roas, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); + $fp = fopen ('roa/export_dn42.json', 'w'); fwrite ($fp, shell_exec ("/usr/bin/git -C ../registry/ show | sed 's/^/\/\/ /g'")); diff --git a/rfc8416.php b/rfc8416.php index 915abf5..d2d2d1c 100755 --- a/rfc8416.php +++ b/rfc8416.php @@ -214,10 +214,7 @@ foreach ($raw_array as $sub_array) } } -// Do JSON encoding before writing result to file -$json = json_encode($roas, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT|JSON_NUMERIC_CHECK); - -writeRoutinatorExceptionFile($json); +writeRoutinatorExceptionFile($roas); commitPushToRemotes(); diff --git a/roagen.php b/roagen.php index 9d73614..425f2de 100755 --- a/roagen.php +++ b/roagen.php @@ -189,11 +189,8 @@ foreach ($raw_array as $sub_array) } } -// Do JSON encoding before writing result to file -$json = json_encode ($roas, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); - -writeExportJSON($json); -writeBirdConfig($json, $roas); +writeExportJSON($roas); +writeBirdConfig($roas); commitPushToRemotes();