]> git.mxchange.org Git - friendica.git/blob - util/global_community_silence.php
b25c2af2238e50fca3d3843382805ec22158b27e
[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 displayes 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 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 wont 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://exaple.com/profiles/bob\r\n";
32         echo "\r\n";
33         exit(0);
34 }
35
36 use Friendica\Database\DBM;
37 require_once("boot.php");
38 require_once('include/dba.php');
39 require_once("include/text.php");
40 $a = get_app();
41 require_once ".htconfig.php";
42
43 dba::connect($db_host, $db_user, $db_pass, $db_data);
44 unset($db_host, $db_user, $db_pass, $db_data);
45
46 /**
47  * 1. make nurl from last parameter
48  * 2. check DB (contact) if there is a contact with uid=0 and that nurl, get the ID
49  * 3. set the flag hidden=1 for the contact entry with the found ID
50  **/
51
52 $nurl = normalise_link($argv[1]);
53 $r = dba::select("contact", array("id"), array("nurl" => $nurl, "uid" => 0), array("limit"=> 1));
54 if (DBM::is_result($r)) {
55         dba::update("contact", array("hidden"=>1), array("id"=>$r["id"]));
56         echo "NOTICE: The account should be silenced from the global community page\r\n";
57 } else {
58         echo "NOTICE: Could not find any entry for this URL (".$nurl.")\r\n";
59 }
60
61 ?>