5 * @brief tool to block an account from the node
7 * With this tool, you can block an account in such a way, that no postings
8 * or comments this account writes are accepted to the node.
10 * Usage: pass the URL of the to be blocked account as only parameter
11 * at the command line when running this tool. E.g.
13 * $> util/global_community_block.php http://example.com/profile/bob
15 * will block bob@example.com.
17 * Author: Tobias Diekershoff
19 * License: AGPLv3 or later, same as Friendica
22 if ($argc!=2 || $argv[1]=="-h" || $argv[1]=="--help" || $argv[1]=="-?") {
23 echo "Usage: ".$argv[0]." [-h|profile_url]\r\n";
24 echo " -h, -?, --help ... show this help\r\n";
25 echo " profile_url ...... The URL of the profile you want to silence\r\n";
27 echo "Example: block bob@example.com\r\n";
28 echo "$> ".$argv[0]." https://example.com/profiles/bob\r\n";
33 use Friendica\Database\DBM;
34 use Friendica\Network\Probe;
36 require_once("boot.php");
37 require_once('include/dba.php');
38 require_once("include/text.php");
40 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);
46 * 1. make nurl from last parameter
47 * 2. check DB (contact) if there is a contact with uid=0 and that nurl, get the ID
48 * 3. set the flag hidden=1 for the contact entry with the found ID
50 $net = Probe::uri($argv[1]);
51 if (in_array($net['network'], array(NETWORK_PHANTOM, NETWORK_MAIL))) {
52 echo "This account seems not to exist.";
56 $nurl = normalise_link($net['url']);
57 $r = dba::select("contact", array("id"), array("nurl" => $nurl, "uid" => 0), array("limit" => 1));
58 if (DBM::is_result($r)) {
59 dba::update("contact", array("blocked" => true), array("id" => $r["id"]));
60 echo "NOTICE: The account should be blocked from the node now\r\n";
62 echo "NOTICE: Could not find any entry for this URL (".$nurl.")\r\n";