1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#!/usr/bin/env php
<?php
// Red pconfig utility
if(!file_exists('include/cli_startup.php')) {
echo 'Run pconfig from the top level Hubzilla web directory, as util/pconfig <args>' . PHP_EOL;
exit(1);
}
require_once('include/cli_startup.php');
require_once('include/zot.php');
cli_startup();
$helpArgs = getopt('h', array('help'));
if (count($helpArgs) === 1) {
echo <<<'EndOfOutput'
adds, removes, or lists admins
Usage: util/admins
util/admins list
util/admins add <account_id>
util/admins remove <account_id>
EndOfOutput;
return;
}
if($argc == 1) {
$r = q("select account_id, account_roles, account_email from account");
if($r) {
foreach($r as $rr) {
echo sprintf('%4u %s %s', $rr['account_id'], $rr['account_email'],(($rr['account_roles'] & 4096) ? '*' : '')) . PHP_EOL;
}
}
}
if($argc > 1 && $argv[1] === 'list') {
$r = q("select account_id, account_roles, account_email from account where (account_roles & 4096) > 0");
if($r) {
foreach($r as $rr) {
echo sprintf('%4u %s %s', $rr['account_id'], $rr['account_email'],(($rr['account_roles'] & 4096) ? '*' : '')) . PHP_EOL;
}
}
}
if($argc > 2 && $argv[1] === 'add' && intval($argv[2])) {
$r = q("update account set account_roles = (account_roles | 4096) where account_id = %d",
intval($argv[2])
);
}
if($argc > 2 && $argv[1] === 'remove' && intval($argv[2])) {
$r = q("update account set account_roles = (account_roles - 4096) where account_id = %d and (account_roles & 4096) > 0",
intval($argv[2])
);
}
|