<?php
$file = 'admin.php';
$content = file_get_contents($file);

$oldLogic = '    $orbital_dominance = $_POST[\'orbital_dominance\'] ?: null;
    $terrestrial_dominance = $_POST[\'terrestrial_dominance\'] ?: null;';

$newLogic = <<<'EOD'
    $orbital_dominance = isset($_POST['orbital_dominance']) ? implode(',', (array)$_POST['orbital_dominance']) : null;
    $terrestrial_dominance = isset($_POST['terrestrial_dominance']) ? implode(',', (array)$_POST['terrestrial_dominance']) : null;
EOD;

$content = str_replace($oldLogic, $newLogic, $content);

file_put_contents($file, $content);
echo "Handler patched";
?>