Revision f2cc3344
Added by Renato Botelho almost 12 years ago
etc/inc/upgrade_config.inc | ||
---|---|---|
2898 | 2898 |
foreach ($config['virtualip']['vip'] as $vip) { |
2899 | 2899 |
if ($vip['mode'] != "carp") |
2900 | 2900 |
continue; |
2901 |
$vipchg[] = "s/\\([^_]\\)vip{$vip['vhid']}\\([^0-9]\\)/\\1{$vip['interface']}_vip{$vip['vhid']}\\2/g\n"; |
|
2902 |
} |
|
2903 |
if (!empty($vipchg)) { |
|
2904 |
file_put_contents("{$g['tmp_path']}/vipreplace", $vipchg); |
|
2905 |
write_config(); |
|
2906 |
mwexec("/usr/bin/sed -I \"\" -f {$g['tmp_path']}/vipreplace {$g['conf_path']}/config.xml"); |
|
2907 |
require_once("config.lib.inc"); |
|
2908 |
unset($config); |
|
2909 |
$config = parse_config(true); |
|
2910 |
@unlink("{$g['tmp_path']}/vipreplace"); |
|
2901 |
$config = array_replace_values_recursive( |
|
2902 |
$config, |
|
2903 |
'^vip' . $vip['vhid'] . '$', |
|
2904 |
"{$vip['interface']}_vip{$vip['vhid']}" |
|
2905 |
); |
|
2911 | 2906 |
} |
2912 | 2907 |
} |
2913 | 2908 |
} |
etc/inc/util.inc | ||
---|---|---|
1826 | 1826 |
return false; |
1827 | 1827 |
} |
1828 | 1828 |
|
1829 |
/* |
|
1830 |
* Replace a value on a deep associative array using regex |
|
1831 |
*/ |
|
1832 |
function array_replace_values_recursive($data, $match, $replace) { |
|
1833 |
if (empty($data)) |
|
1834 |
return $data; |
|
1835 |
|
|
1836 |
if (is_string($data)) |
|
1837 |
$data = preg_replace("/{$match}/", $replace, $data); |
|
1838 |
else if (is_array($data)) |
|
1839 |
foreach ($data as $k => $v) |
|
1840 |
$data[$k] = array_replace_values_recursive($v, $match, $replace); |
|
1841 |
|
|
1842 |
return $data; |
|
1843 |
} |
|
1844 |
|
|
1829 | 1845 |
/* |
1830 | 1846 |
This function was borrowed from a comment on PHP.net at the following URL: |
1831 | 1847 |
http://www.php.net/manual/en/function.array-merge-recursive.php#73843 |
Also available in: Unified diff
Fix #3004:
. Create a function to replace strings on deep associative arrays
. Use the recent created function array_replace_values_recursive to fix
VIP interface names instead of touch config.xml directly