]> git.mxchange.org Git - friendica.git/blob - util/config
Merge pull request #4614 from annando/dir-own-contact
[friendica.git] / util / config
1 #!/usr/bin/env php
2 <?php
3
4 /**
5  * @brief tool to access the system config from the CLI
6  *
7  * With this script you can access the system configuration of your node from
8  * the CLI. You can do both, reading current values stored in the database and
9  * set new values to config variables.
10  *
11  * Usage:
12  *   If you specify no parameters at the CLI, the script will list all config
13  *   variables defined.
14  *
15  *   If you specify one parameter, the scipt will list all config variables
16  *   defined in this section of the configuration (e.g. "system").
17  *
18  *   If you specify two parameters, the scipt will show you the current value
19  *   of the named configuration setting. (e.g. "system loglevel")
20  *
21  *   If you specify three parameters, the named configuration setting will be
22  *   set to the value of the last parameter. (e.g. "system loglevel 0" will
23  *   disable logging)
24  **/
25
26 use Friendica\Core\Config;
27
28 require_once 'boot.php';
29 require_once 'include/dba.php';
30 require_once 'include/text.php';
31 $a = get_app();
32 require_once '.htconfig.php';
33
34 dba::connect($db_host, $db_user, $db_pass, $db_data);
35 unset($db_host, $db_user, $db_pass, $db_data);
36
37 if($argc > 3) {
38         Config::set($argv[1],$argv[2],$argv[3]);
39         echo "config[{$argv[1]}][{$argv[2]}] = " . Config::get($argv[1],$argv[2]) . "\n";
40 }
41
42 if($argc == 3) {
43         echo "config[{$argv[1]}][{$argv[2]}] = " . Config::get($argv[1],$argv[2]) . "\n";
44 }
45
46 if($argc == 2) {
47         Config::load($argv[1]);
48         if (!is_null($a->config[$argv[1]])) {
49                 foreach($a->config[$argv[1]] as $k => $x) {
50                         echo "config[{$argv[1]}][{$k}] = " . $x . "\n";
51                 }
52         } else {
53                 echo "config section '$argv[1]' returned nothing.\n";
54         }
55 }
56
57 if($argc == 1) {
58         $r = q("select * from config where 1");
59         if($r) {
60                 foreach($r as $rr) {
61                         echo "config[{$rr['cat']}][{$rr['k']}] = " . $rr['v'] . "\n";
62                 }
63         }
64 }
65