9178c0f
9178c0f
9178c0f
#
9178c0f
# strip.php /path/to/file key_name
9178c0f
# 
9178c0f
# Takes a file as input and a string prefix; reads
9178c0f
# the file as a serialized data blob and removes a
9178c0f
# key with name key_name from the hash.
9178c0f
# Serializes again and writes output to stdout.
9178c0f
# 
9178c0f
9178c0f
$file = $_SERVER['argv'][1];
9178c0f
$key = $_SERVER['argv'][2];
9178c0f
9178c0f
function remove_key($array, $name) {
9178c0f
    if (array_key_exists($name, $array)) {
9178c0f
        unset($array[$name]);
9178c0f
    }
9178c0f
9178c0f
    return $array;
9178c0f
}
9178c0f
9178c0f
$input = file_get_contents($file);
9178c0f
9178c0f
# Special case for /etc/pear.conf.
9178c0f
if (strncmp($input, "#PEAR_Config 0.9\n", 17) == 0) {
9178c0f
    echo substr($input, 0, 17);
9178c0f
    $s = substr($input, 17);
9178c0f
} else {
9178c0f
    $s = $input;
9178c0f
}
9178c0f
9178c0f
echo serialize(remove_key(unserialize($s), $key));
9178c0f
9178c0f
?>