]> git.mxchange.org Git - friendica.git/blob - util/global_community_silence.php
14cd06e7aa458ae5611f880f447a6b0d92c59503
[friendica.git] / util / global_community_silence.php
1 #!/usr/bin/env php
2 <?php
3
4 /**
5  * @brief tool to silence accounts on the global community page
6  *
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.
11  *
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.
14  *
15  *        $> util/global_community_silence.php http://example.com/profile/bob
16  *
17  *        will silence bob@example.com so that his postings won't appear at
18  *        the global community page.
19  *
20  * Author: Tobias Diekershoff
21  *
22  * License: AGPLv3 or later, same as Friendica
23  **/
24
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";
29         echo "\r\n";
30         echo "Example: Silence bob@example.com\r\n";
31         echo "$> ".$argv[0]." https://example.com/profiles/bob\r\n";
32         echo "\r\n";
33         exit(0);
34 }
35
36 use Friendica\Database\DBM;
37 use Friendica\Network\Probe;
38
39 require_once 'boot.php';
40 require_once 'include/dba.php';
41 require_once 'include/text.php';
42 $a = get_app();
43 require_once '.htconfig.php';
44
45 dba::connect($db_host, $db_user, $db_pass, $db_data);
46 unset($db_host, $db_user, $db_pass, $db_data);
47
48 /**
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
52  **/
53 $net = Probe::uri($argv[1]);
54 if (in_array($net['network'], array(NETWORK_PHANTOM, NETWORK_MAIL))) {
55         echo "This account seems not to exist.";
56         echo "\r\n";
57         exit(1);
58 }
59 $nurl = normalise_link($net['url']);
60 $r = dba::selectFirst("contact", ["id"], ["nurl" => $nurl, "uid" => 0]);
61 if (DBM::is_result($r)) {
62         dba::update("contact", array("hidden" => true), array("id" => $r["id"]));
63         echo "NOTICE: The account should be silenced from the global community page\r\n";
64 } else {
65         echo "NOTICE: Could not find any entry for this URL (".$nurl.")\r\n";
66 }
67
68 ?>