2015-08-23 22:38:18 +02:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
// Red config utility
|
|
|
|
|
|
|
|
require_once('include/cli_startup.php');
|
|
|
|
|
|
|
|
cli_startup();
|
|
|
|
|
|
|
|
if($argc > 3) {
|
2016-03-20 08:06:33 +01:00
|
|
|
|
|
|
|
|
2015-08-23 22:38:18 +02:00
|
|
|
set_config($argv[1],$argv[2],$argv[3]);
|
2016-03-20 08:06:33 +01:00
|
|
|
echo "config[{$argv[1]}][{$argv[2]}] = " . printable_config(get_config($argv[1],$argv[2])) . "\n";
|
2015-08-23 22:38:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if($argc == 3) {
|
2016-03-20 08:06:33 +01:00
|
|
|
echo "config[{$argv[1]}][{$argv[2]}] = " . printable_config(get_config($argv[1],$argv[2])) . "\n";
|
2015-08-23 22:38:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if($argc == 2) {
|
|
|
|
load_config($argv[1]);
|
|
|
|
foreach($a->config[$argv[1]] as $k => $x) {
|
|
|
|
echo "config[{$argv[1]}][{$k}] = " . $x . "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($argc == 1) {
|
|
|
|
$r = q("select * from config where 1");
|
|
|
|
if($r) {
|
|
|
|
foreach($r as $rr) {
|
2016-03-20 08:06:33 +01:00
|
|
|
echo "config[{$rr['cat']}][{$rr['k']}] = " . printable_config($rr['v']) . "\n";
|
2015-08-23 22:38:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-20 08:06:33 +01:00
|
|
|
function printable_config($x) {
|
|
|
|
$s = '';
|
|
|
|
if(is_array($x)) {
|
|
|
|
foreach($x as $v) {
|
|
|
|
$s .= $v . "\n";
|
|
|
|
}
|
|
|
|
return $s;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return $x;
|
|
|
|
}
|