2003-06-22 15:48:44 +00:00
|
|
|
<?php
|
|
|
|
|
2004-05-10 17:26:03 +00:00
|
|
|
/** @file dba_array.php
|
|
|
|
* @brief Program DBA array utility
|
|
|
|
* @ingroup Examples
|
|
|
|
* @author Marcus Boerger
|
|
|
|
* @date 2003 - 2004
|
2003-06-22 15:48:44 +00:00
|
|
|
*
|
2004-05-10 17:26:03 +00:00
|
|
|
* Usage php dba_array.php \<file\> \<handler\> \<key\> [\<value\>]
|
2003-06-22 15:48:44 +00:00
|
|
|
*
|
2004-05-10 17:26:03 +00:00
|
|
|
* If \<value\> is specified then \<key\> is set to \<value\> in \<file\>.
|
|
|
|
* Else the value of \<key\> is printed only.
|
2003-06-22 15:48:44 +00:00
|
|
|
*
|
|
|
|
* Note: configure with --enable-dba
|
|
|
|
*/
|
|
|
|
|
2003-12-04 19:39:46 +00:00
|
|
|
if ($argc < 4) {
|
|
|
|
echo <<<EOF
|
|
|
|
Usage: php ${_SERVER['PHP_SELF']} <file> <handler> <key> [<value>]
|
|
|
|
|
|
|
|
If <value> is specified then <key> is set to <value> in <file>.
|
|
|
|
Else the value of <key> is printed only.
|
|
|
|
|
|
|
|
|
|
|
|
EOF;
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2004-05-08 12:24:15 +00:00
|
|
|
if (!class_exists("DbaReader", false)) require_once("dbareader.inc");
|
2003-06-22 15:48:44 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
if ($argc > 2) {
|
2003-11-22 20:51:15 +00:00
|
|
|
$dba = new DbaArray($argv[1], $argv[2]);
|
2003-06-22 15:48:44 +00:00
|
|
|
if ($dba && $argc > 3) {
|
|
|
|
if ($argc > 4) {
|
|
|
|
$dba[$argv[3]] = $argv[4];
|
|
|
|
}
|
|
|
|
var_dump(array('Index' => $argv[3], 'Value' => $dba[$argv[3]]));
|
|
|
|
}
|
2003-11-22 20:51:15 +00:00
|
|
|
unset($dba);
|
2003-06-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "Not enough parameters\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (exception $err) {
|
|
|
|
var_dump($err);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
?>
|