Created
June 17, 2026 00:44
-
-
Save SpareSimian/34d3c7a4d0615d1c178cf53d2b53fc32 to your computer and use it in GitHub Desktop.
Extract differences between an old default RoundCube config and its custom one, for pasting to the end of a much newer custom config file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| define("RCMAIL_VERSION", "RCMAIL_VERSION"); | |
| require 'defaults.inc.php'; | |
| $default_config = $config; | |
| unset($config); | |
| require 'config.inc.php'; | |
| $custom_config = $config; | |
| unset($config); | |
| // return elements of 1st array that are not in the 2nd or don't | |
| // match it | |
| function array_diff_assoc_recursive($array1, $array2) { | |
| $difference = []; | |
| foreach ($array1 as $key => $value) { | |
| if (is_array($value)) { | |
| // If the key doesn't exist or | |
| // isn't an array in the second | |
| // array | |
| if (!isset($array2[$key]) || !is_array($array2[$key])) { | |
| $difference[$key] = $value; | |
| } else { | |
| // Recursively find | |
| // differences in | |
| // nested arrays | |
| $new_diff = array_diff_assoc_recursive($value, $array2[$key]); | |
| if (!empty($new_diff)) { | |
| $difference[$key] = $new_diff; | |
| } | |
| } | |
| } elseif (!array_key_exists($key, $array2) || $array2[$key] !== $value) { | |
| $difference[$key] = $value; | |
| } | |
| } | |
| return $difference; | |
| } | |
| $result = array_diff_assoc_recursive($custom_config, $default_config); | |
| foreach ($result as $key => $value) { | |
| if (is_string($value)) { | |
| $value = "'" . $value . "'"; | |
| } | |
| elseif (is_array($value) || is_bool($value)) { | |
| $value = var_export($value, true); | |
| } | |
| print('$config[' . "'" . $key . "'] = " . $value . ";\n"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment