]> git.mxchange.org Git - friendica.git/blob - util/global_community_block.php
Add missing doc in api.php
[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\Model\Contact;
33
34 require_once 'boot.php';
35 require_once 'include/dba.php';
36 require_once 'include/text.php';
37
38 $a = get_app();;
39 BaseObject::setApp($a);
40
41 require_once '.htconfig.php';
42 dba::connect($db_host, $db_user, $db_pass, $db_data);
43 unset($db_host, $db_user, $db_pass, $db_data);
44
45 $contact_id = Contact::getIdForURL($argv[1], 0);
46 if (!$contact_id) {
47         echo t('Could not find any contact entry for this URL (%s)', $nurl);
48         echo "\r\n";
49         exit(1);
50 }
51 Contact::block($contact_id);
52 echo t('The contact has been blocked from the node');
53 echo "\r\n";
54 exit(0);