2017-11-25 14:16:55 +00:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief tool to silence accounts on the global community page
|
|
|
|
*
|
|
|
|
* With this tool, you can silence an account on the global community page.
|
2017-11-25 15:55:58 +00:00
|
|
|
* Postings from silenced accounts will not be displayed on the community
|
2017-11-25 14:16:55 +00:00
|
|
|
* page. This silencing does only affect the display on the community page,
|
|
|
|
* accounts following the silenced accounts will still get their postings.
|
|
|
|
*
|
2017-11-25 15:55:58 +00:00
|
|
|
* Usage: pass the URL of the profile to be silenced account as only parameter
|
2017-11-25 14:16:55 +00:00
|
|
|
* at the command line when running this tool. E.g.
|
|
|
|
*
|
|
|
|
* $> util/global_community_silence.php http://example.com/profile/bob
|
|
|
|
*
|
2017-11-25 15:55:58 +00:00
|
|
|
* will silence bob@example.com so that his postings won't appear at
|
2017-11-25 14:16:55 +00:00
|
|
|
* the global community page.
|
|
|
|
*
|
|
|
|
* Author: Tobias Diekershoff
|
|
|
|
*
|
|
|
|
* License: AGPLv3 or later, same as Friendica
|
|
|
|
**/
|
|
|
|
|
2017-11-25 15:55:58 +00:00
|
|
|
if ($argc != 2 || $argv[1] == "-h" || $argv[1] == "--help" || $argv[1] == "-?") {
|
2017-11-25 14:16:55 +00:00
|
|
|
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";
|
2017-11-25 15:25:53 +00:00
|
|
|
echo "$> ".$argv[0]." https://example.com/profiles/bob\r\n";
|
2017-11-25 14:16:55 +00:00
|
|
|
echo "\r\n";
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
use Friendica\Database\DBM;
|
2017-11-25 15:25:53 +00:00
|
|
|
use Friendica\Network\Probe;
|
|
|
|
|
2017-11-25 16:05:27 +00:00
|
|
|
require_once 'boot.php';
|
|
|
|
require_once 'include/dba.php';
|
|
|
|
require_once 'include/text.php';
|
2017-11-25 14:16:55 +00:00
|
|
|
$a = get_app();
|
2017-11-25 16:10:29 +00:00
|
|
|
require_once '.htconfig.php';
|
2017-11-25 14:16:55 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
**/
|
2017-11-25 15:25:53 +00:00
|
|
|
$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']);
|
2018-01-11 08:26:30 +00:00
|
|
|
$contact = dba::selectFirst("contact", ["id"], ["nurl" => $nurl, "uid" => 0]);
|
|
|
|
if (DBM::is_result($contact)) {
|
2018-01-11 23:56:33 +00:00
|
|
|
dba::update("contact", array("hidden" => true), array("id" => $contact["id"]));
|
2017-11-25 14:16:55 +00:00
|
|
|
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";
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|