1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47:
<?php
function updateConfigItem($item, $value, $zp_cfg, $quote = true) {
if ($quote) {
$value = '"' . $value . '"';
}
$i = strpos($zp_cfg, $item);
if ($i === false) {
$parts = preg_split('~\/\*.*Do not edit below this line.*\*\/~', $zp_cfg);
if (isset($parts[1])) {
$zp_cfg = $parts[0] . "\$conf['" . $item . "'] = " . $value . ";\n/** Do not edit below this line. **/" . $parts[1];
} else {
zp_error(gettext('The Zenphoto configuration file is corrupt. You will need to restore it from a backup.'));
}
} else {
$i = strpos($zp_cfg, '=', $i);
$j = strpos($zp_cfg, "\n", $i);
$zp_cfg = substr($zp_cfg, 0, $i) . '= ' . $value . ';' . substr($zp_cfg, $j);
}
return $zp_cfg;
}
function storeConfig($zp_cfg) {
$mod = fileperms(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE) & 0777;
@rename(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE, $backkup = SERVERPATH . '/' . DATA_FOLDER . '/' . stripSuffix(CONFIGFILE) . '.bak.php');
@chmod($backup, $mod);
file_put_contents(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE, $zp_cfg);
@chmod($backup, SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE, $mod);
}
?>