5 * @brief tool to silence accounts on the global community page
7 * With this tool, you can silence an account on the global community page.
8 * Postings from silenced accounts will not be displayed on the community
9 * page. This silencing does only affect the display on the community page,
10 * accounts following the silenced accounts will still get their postings.
12 * Usage: pass the URL of the profile to be silenced account as only parameter
13 * at the command line when running this tool. E.g.
15 * $> util/global_community_silence.php http://example.com/profile/bob
17 * will silence bob@example.com so that his postings won't appear at
18 * the global community page.
20 * Author: Tobias Diekershoff
22 * License: AGPLv3 or later, same as Friendica
25 if ($argc != 2 || $argv[1] == "-h" || $argv[1] == "--help" || $argv[1] == "-?") {
26 echo "Usage: ".$argv[0]." [-h|profile_url]\r\n";
27 echo " -h, -?, --help ... show this help\r\n";
28 echo " profile_url ...... The URL of the profile you want to silence\r\n";
30 echo "Example: Silence bob@example.com\r\n";
31 echo "$> ".$argv[0]." https://example.com/profiles/bob\r\n";
36 use Friendica\Database\DBM;
37 use Friendica\Network\Probe;
39 require_once 'boot.php';
40 require_once 'include/dba.php';
41 require_once 'include/text.php';
43 require_once '.htconfig.php';
45 dba::connect($db_host, $db_user, $db_pass, $db_data);
46 unset($db_host, $db_user, $db_pass, $db_data);
49 * 1. make nurl from last parameter
50 * 2. check DB (contact) if there is a contact with uid=0 and that nurl, get the ID
51 * 3. set the flag hidden=1 for the contact entry with the found ID
53 $net = Probe::uri($argv[1]);
54 if (in_array($net['network'], [NETWORK_PHANTOM, NETWORK_MAIL])) {
55 echo "This account seems not to exist.";
59 $nurl = normalise_link($net['url']);
60 $contact = dba::selectFirst("contact", ["id"], ["nurl" => $nurl, "uid" => 0]);
61 if (DBM::is_result($contact)) {
62 dba::update("contact", ["hidden" => true], ["id" => $contact["id"]]);
63 echo "NOTICE: The account should be silenced from the global community page\r\n";
65 echo "NOTICE: Could not find any entry for this URL (".$nurl.")\r\n";