From 2d65eae2f5354912f4e6ff92c739ae96f7fbdc1a Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sat, 25 Nov 2017 16:40:03 +0100 Subject: [PATCH 1/3] Script to block an account from the node --- util/global_community_block.php | 65 +++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 util/global_community_block.php diff --git a/util/global_community_block.php b/util/global_community_block.php new file mode 100755 index 0000000000..705054bb79 --- /dev/null +++ b/util/global_community_block.php @@ -0,0 +1,65 @@ +#!/usr/bin/env php + util/global_community_block.php http://example.com/profile/bob + * + * will block bob@example.com. + * + * Author: Tobias Diekershoff + * + * License: AGPLv3 or later, same as Friendica + **/ + +if ($argc!=2 || $argv[1]=="-h" || $argv[1]=="--help" || $argv[1]=="-?") { + echo "Usage: ".$argv[0]." [-h|profile_url]\r\n"; + echo " -h, -?, --help ... show this help\r\n"; + echo " profile_url ...... The URL of the profile you want to silence\r\n"; + echo "\r\n"; + echo "Example: block bob@example.com\r\n"; + echo "$> ".$argv[0]." https://example.com/profiles/bob\r\n"; + echo "\r\n"; + exit(0); +} + +use Friendica\Database\DBM; +use Friendica\Network\Probe; + +require_once("boot.php"); +require_once('include/dba.php'); +require_once("include/text.php"); +$a = get_app(); +require_once ".htconfig.php"; + +dba::connect($db_host, $db_user, $db_pass, $db_data); +unset($db_host, $db_user, $db_pass, $db_data); + +/** + * 1. make nurl from last parameter + * 2. check DB (contact) if there is a contact with uid=0 and that nurl, get the ID + * 3. set the flag hidden=1 for the contact entry with the found ID + **/ +$net = Probe::uri($argv[1]); +if (in_array($net['network'], array(NETWORK_PHANTOM, NETWORK_MAIL))) { + echo "This account seems not to exist."; + echo "\r\n"; + exit(1); +} +$nurl = normalise_link($net['url']); +$r = dba::select("contact", array("id"), array("nurl" => $nurl, "uid" => 0), array("limit" => 1)); +if (DBM::is_result($r)) { + dba::update("contact", array("blocked" => true), array("id" => $r["id"])); + echo "NOTICE: The account should be blocked from the node now\r\n"; +} else { + echo "NOTICE: Could not find any entry for this URL (".$nurl.")\r\n"; +} + +?> From d9185540a5462207d0256a4c879e3a98809dda23 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sat, 25 Nov 2017 16:45:20 +0100 Subject: [PATCH 2/3] some minor stuff --- util/global_community_block.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/global_community_block.php b/util/global_community_block.php index 705054bb79..a0f8ec223b 100755 --- a/util/global_community_block.php +++ b/util/global_community_block.php @@ -19,7 +19,7 @@ * License: AGPLv3 or later, same as Friendica **/ -if ($argc!=2 || $argv[1]=="-h" || $argv[1]=="--help" || $argv[1]=="-?") { +if ($argc != 2 || $argv[1] == "-h" || $argv[1] == "--help" || $argv[1] == "-?") { echo "Usage: ".$argv[0]." [-h|profile_url]\r\n"; echo " -h, -?, --help ... show this help\r\n"; echo " profile_url ...... The URL of the profile you want to silence\r\n"; @@ -33,11 +33,11 @@ if ($argc!=2 || $argv[1]=="-h" || $argv[1]=="--help" || $argv[1]=="-?") { use Friendica\Database\DBM; use Friendica\Network\Probe; -require_once("boot.php"); +require_once('boot.php'); require_once('include/dba.php'); -require_once("include/text.php"); +require_once('include/text.php'); $a = get_app(); -require_once ".htconfig.php"; +require_once('.htconfig.php'); dba::connect($db_host, $db_user, $db_pass, $db_data); unset($db_host, $db_user, $db_pass, $db_data); From 8a91e631cf6aa0663b789e81e6c4c077e011419b Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sat, 25 Nov 2017 17:02:42 +0100 Subject: [PATCH 3/3] some more minor stuff --- util/global_community_block.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/util/global_community_block.php b/util/global_community_block.php index a0f8ec223b..cb6789e45c 100755 --- a/util/global_community_block.php +++ b/util/global_community_block.php @@ -33,11 +33,11 @@ if ($argc != 2 || $argv[1] == "-h" || $argv[1] == "--help" || $argv[1] == "-?") use Friendica\Database\DBM; use Friendica\Network\Probe; -require_once('boot.php'); -require_once('include/dba.php'); -require_once('include/text.php'); +require_once 'boot.php'; +require_once 'include/dba.php'; +require_once 'include/text.php'; $a = get_app(); -require_once('.htconfig.php'); +require_once '.htconfig.php'; dba::connect($db_host, $db_user, $db_pass, $db_data); unset($db_host, $db_user, $db_pass, $db_data); @@ -49,14 +49,14 @@ unset($db_host, $db_user, $db_pass, $db_data); **/ $net = Probe::uri($argv[1]); if (in_array($net['network'], array(NETWORK_PHANTOM, NETWORK_MAIL))) { - echo "This account seems not to exist."; + echo 'This account seems not to exist.'; echo "\r\n"; exit(1); } $nurl = normalise_link($net['url']); -$r = dba::select("contact", array("id"), array("nurl" => $nurl, "uid" => 0), array("limit" => 1)); +$r = dba::select('contact', array('id'), array('nurl' => $nurl, 'uid' => 0), array('limit' => 1)); if (DBM::is_result($r)) { - dba::update("contact", array("blocked" => true), array("id" => $r["id"])); + dba::update('contact', array('blocked' => true), array('id' => $r['id'])); echo "NOTICE: The account should be blocked from the node now\r\n"; } else { echo "NOTICE: Could not find any entry for this URL (".$nurl.")\r\n";