]> git.mxchange.org Git - friendica.git/blob - util/global_community_block.php
Merge pull request #4552 from tobiasd/20180305-messagespo
[friendica.git] / util / global_community_block.php
1 #!/usr/bin/env php
2 <?php
3 /**
4  * @brief tool to block an account from the node
5  *
6  * With this tool, you can block an account in such a way, that no postings
7  * or comments this account writes are accepted to the node.
8  *
9  * Usage: pass the URL of the to be blocked account as only parameter
10  *        at the command line when running this tool. E.g.
11  *
12  *        $> util/global_community_block.php http://example.com/profile/bob
13  *
14  *        will block bob@example.com.
15  *
16  * Author: Tobias Diekershoff
17  *
18  * License: AGPLv3 or later, same as Friendica
19  */
20 if ($argc != 2 || $argv[1] == "-h" || $argv[1] == "--help" || $argv[1] == "-?") {
21         echo "Usage: " . $argv[0] . " [-h|profile_url]\r\n";
22         echo "    -h, -?, --help ... show this help\r\n";
23         echo "    profile_url ...... The URL of the profile you want to silence\r\n";
24         echo "\r\n";
25         echo "Example: block bob@example.com\r\n";
26         echo "$> " . $argv[0] . " https://example.com/profiles/bob\r\n";
27         echo "\r\n";
28         exit(0);
29 }
30
31 use Friendica\BaseObject;
32 use Friendica\Core\L10n;
33 use Friendica\Model\Contact;
34
35 require_once 'boot.php';
36 require_once 'include/dba.php';
37 require_once 'include/text.php';
38
39 $a = get_app();
40 BaseObject::setApp($a);
41
42 require_once '.htconfig.php';
43 dba::connect($db_host, $db_user, $db_pass, $db_data);
44 unset($db_host, $db_user, $db_pass, $db_data);
45
46 $contact_id = Contact::getIdForURL($argv[1]);
47 if (!$contact_id) {
48         echo L10n::t('Could not find any contact entry for this URL (%s)', $nurl);
49         echo "\r\n";
50         exit(1);
51 }
52 Contact::block($contact_id);
53 echo L10n::t('The contact has been blocked from the node');
54 echo "\r\n";
55 exit(0);