From 8c2b678aaa3811af6b9ab086e5066a4dda6ff984 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sat, 25 Nov 2017 15:16:55 +0100 Subject: [PATCH 1/2] silence accounts from global community page --- util/global_community_silence.php | 61 +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 util/global_community_silence.php diff --git a/util/global_community_silence.php b/util/global_community_silence.php new file mode 100755 index 0000000000..b25c2af223 --- /dev/null +++ b/util/global_community_silence.php @@ -0,0 +1,61 @@ +#!/usr/bin/env php + util/global_community_silence.php http://example.com/profile/bob + * + * will silence bob@example.com so that his postings wont appear at + * the global community page. + * + * 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: Silence bob@example.com\r\n"; + echo "$> ".$argv[0]." https://exaple.com/profiles/bob\r\n"; + echo "\r\n"; + exit(0); +} + +use Friendica\Database\DBM; +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 + **/ + +$nurl = normalise_link($argv[1]); +$r = dba::select("contact", array("id"), array("nurl" => $nurl, "uid" => 0), array("limit"=> 1)); +if (DBM::is_result($r)) { + dba::update("contact", array("hidden"=>1), array("id"=>$r["id"])); + echo "NOTICE: The account should be silenced from the global community page\r\n"; +} else { + echo "NOTICE: Could not find any entry for this URL (".$nurl.")\r\n"; +} + +?> From 9f0e8cffbabee81adc9ab345068c4507e3ddd700 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sat, 25 Nov 2017 16:25:53 +0100 Subject: [PATCH 2/2] use all profile formats, typos --- util/global_community_silence.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/util/global_community_silence.php b/util/global_community_silence.php index b25c2af223..d18efd345e 100755 --- a/util/global_community_silence.php +++ b/util/global_community_silence.php @@ -28,12 +28,14 @@ if ($argc!=2 || $argv[1]=="-h" || $argv[1]=="--help" || $argv[1]=="-?") { echo " profile_url ...... The URL of the profile you want to silence\r\n"; echo "\r\n"; echo "Example: Silence bob@example.com\r\n"; - echo "$> ".$argv[0]." https://exaple.com/profiles/bob\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"); @@ -48,11 +50,16 @@ unset($db_host, $db_user, $db_pass, $db_data); * 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 **/ - -$nurl = normalise_link($argv[1]); -$r = dba::select("contact", array("id"), array("nurl" => $nurl, "uid" => 0), array("limit"=> 1)); +$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("hidden"=>1), array("id"=>$r["id"])); + dba::update("contact", array("hidden" => true), array("id" => $r["id"])); echo "NOTICE: The account should be silenced from the global community page\r\n"; } else { echo "NOTICE: Could not find any entry for this URL (".$nurl.")\r\n";