diff options
author | Remi Collet <fedora@famillecollet.com> | 2014-08-24 17:39:38 +0200 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2014-08-24 17:39:38 +0200 |
commit | f564b500ca718e735ed72530a52c4fe57d2c3ea6 (patch) | |
tree | f0acc2aab644f1eb105bb140d52887f0fdbc24bd /php-pear/strip.php | |
parent | 9bbb50b3a32511baadb6bfdcb464a4eca526a413 (diff) |
php-pear: for SCL
Diffstat (limited to 'php-pear/strip.php')
-rw-r--r-- | php-pear/strip.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/php-pear/strip.php b/php-pear/strip.php new file mode 100644 index 0000000..5c5216b --- /dev/null +++ b/php-pear/strip.php @@ -0,0 +1,35 @@ +<?php + +# +# strip.php /path/to/file key_name +# +# Takes a file as input and a string prefix; reads +# the file as a serialized data blob and removes a +# key with name key_name from the hash. +# Serializes again and writes output to stdout. +# + +$file = $_SERVER['argv'][1]; +$key = $_SERVER['argv'][2]; + +function remove_key($array, $name) { + if (array_key_exists($name, $array)) { + unset($array[$name]); + } + + return $array; +} + +$input = file_get_contents($file); + +# Special case for /etc/pear.conf. +if (strncmp($input, "#PEAR_Config 0.9\n", 17) == 0) { + echo substr($input, 0, 17); + $s = substr($input, 17); +} else { + $s = $input; +} + +echo serialize(remove_key(unserialize($s), $key)); + +?>
\ No newline at end of file |