fix php serialization

This commit is contained in:
Doug Bird 2018-06-14 14:58:20 -07:00
parent d93ed6109d
commit 6fe182313e
4 changed files with 21 additions and 20 deletions

View File

@ -89,8 +89,6 @@ new class() {
echo "done\n"; echo "done\n";
} }
//echo "new TldDesc.php: $newTldDescFile\n";
echo "generating new 'TldDesc.php' file..."; echo "generating new 'TldDesc.php' file...";
if (false === file_put_contents($newTldDescFile,static::TLD_DESC_SOURCE_START_CLASS)) { if (false === file_put_contents($newTldDescFile,static::TLD_DESC_SOURCE_START_CLASS)) {
@ -102,9 +100,9 @@ new class() {
} }
$tldDescExport = var_export($tldDesc, true); $tldDescExport = var_export($tldDesc, true);
$tldDescExport = str_replace('array','',$tldDescExport); $tldDescExport = substr($tldDescExport,strlen("array ("));
$tldDescExport = str_replace('(','[',$tldDescExport); $tldDescExport = substr($tldDescExport,0,-1);
$tldDescExport = str_replace(')',']',$tldDescExport); $tldDescExport = ' ['.$tldDescExport.']';
if (false === file_put_contents($newTldDescFile, $tldDescExport,\FILE_APPEND)) { if (false === file_put_contents($newTldDescFile, $tldDescExport,\FILE_APPEND)) {
static::_echo_error("(FATAL) failed to write to new 'TldDesc.php' file",1); static::_echo_error("(FATAL) failed to write to new 'TldDesc.php' file",1);

View File

@ -103,9 +103,9 @@ new class() {
]; ];
$tldInfoElem = var_export($tldInfoElem, true); $tldInfoElem = var_export($tldInfoElem, true);
$tldInfoElem = str_replace('array','',$tldInfoElem); $tldInfoElem = substr($tldInfoElem,strlen("array ("));
$tldInfoElem = str_replace('(','[',$tldInfoElem); $tldInfoElem = substr($tldInfoElem,0,-1);
$tldInfoElem = str_replace(')',']',$tldInfoElem); $tldInfoElem = ' ['.$tldInfoElem.']';
if ($i!=0) { if ($i!=0) {
$tldInfoElem = ",\n$tldInfoElem"; $tldInfoElem = ",\n$tldInfoElem";

View File

@ -98,15 +98,18 @@ new class() {
} }
$tldEnumExport = var_export($tldEnum,true); $tldEnumExport = var_export($tldEnum,true);
$tldEnumExport = str_replace('array','',$tldEnumExport); $tldEnumExport = substr($tldEnumExport,strlen("array ("));
$tldEnumExport = str_replace('(','[',$tldEnumExport); $tldEnumExport = substr($tldEnumExport,0,-1);
$tldEnumExport = str_replace(')',']',$tldEnumExport); $tldEnumLine = [];
$tldEnumExport = str_replace('=>','',$tldEnumExport); $i=0;
$tldEnumExport = preg_replace('/[0-9]+/', '', $tldEnumExport); foreach(explode("\n",$tldEnumExport) as $line) {
$filteredLine = preg_replace('/[0-9]+ => \'/', "'", $line);
$tldEnumLine []= $filteredLine;
$i++;
}
unset($line);
//$tldEnumExport = json_encode($tldEnum,\JSON_PRETTY_PRINT); if (false === file_put_contents($newTldEnumFile, " [".implode("\n",$tldEnumLine)."]",\FILE_APPEND)) {
if (false === file_put_contents($newTldEnumFile, $tldEnumExport,\FILE_APPEND)) {
static::_echo_error("(FATAL) failed to write to new 'TldList.php' file",1); static::_echo_error("(FATAL) failed to write to new 'TldList.php' file",1);
} }

View File

@ -102,9 +102,9 @@ new class() {
} }
$tldTypeExport = var_export($tldType, true); $tldTypeExport = var_export($tldType, true);
$tldTypeExport = str_replace('array','',$tldTypeExport); $tldTypeExport = substr($tldTypeExport,strlen("array ("));
$tldTypeExport = str_replace('(','[',$tldTypeExport); $tldTypeExport = substr($tldTypeExport,0,-1);
$tldTypeExport = str_replace(')',']',$tldTypeExport); $tldTypeExport = ' ['.$tldTypeExport.']';
if (false === file_put_contents($newTldTypeFile, $tldTypeExport,\FILE_APPEND)) { if (false === file_put_contents($newTldTypeFile, $tldTypeExport,\FILE_APPEND)) {
static::_echo_error("(FATAL) failed to write to new 'TldType.php' file",1); static::_echo_error("(FATAL) failed to write to new 'TldType.php' file",1);