2016-11-28 16:44:04 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @file include/remove_contact.php
|
|
|
|
* @brief Removes orphaned data from deleted contacts
|
|
|
|
*/
|
2017-01-18 16:45:32 -05:00
|
|
|
|
|
|
|
use \Friendica\Core\Config;
|
|
|
|
|
2016-11-28 16:44:04 -05:00
|
|
|
require_once("boot.php");
|
|
|
|
|
|
|
|
function remove_contact_run($argv, $argc) {
|
|
|
|
global $a, $db;
|
|
|
|
|
2016-11-28 17:18:37 -05:00
|
|
|
if (is_null($a)) {
|
2016-11-28 16:44:04 -05:00
|
|
|
$a = new App;
|
2016-11-28 17:18:37 -05:00
|
|
|
}
|
2016-11-28 16:44:04 -05:00
|
|
|
|
|
|
|
if (is_null($db)) {
|
|
|
|
@include(".htconfig.php");
|
|
|
|
require_once("include/dba.php");
|
|
|
|
$db = new dba($db_host, $db_user, $db_pass, $db_data);
|
|
|
|
unset($db_host, $db_user, $db_pass, $db_data);
|
|
|
|
}
|
|
|
|
|
2017-01-18 16:45:32 -05:00
|
|
|
Config::load();
|
2016-11-28 16:44:04 -05:00
|
|
|
|
|
|
|
if ($argc != 2) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$id = intval($argv[1]);
|
|
|
|
|
|
|
|
// Only delete if the contact doesn't exist (anymore)
|
|
|
|
$r = q("SELECT `id` FROM `contact` WHERE `id` = %d", intval($id));
|
|
|
|
if (dbm::is_result($r)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
q("DELETE FROM `item` WHERE `contact-id` = %d", intval($id));
|
|
|
|
|
|
|
|
q("DELETE FROM `photo` WHERE `contact-id` = %d", intval($id));
|
|
|
|
|
|
|
|
q("DELETE FROM `mail` WHERE `contact-id` = %d", intval($id));
|
|
|
|
|
|
|
|
q("DELETE FROM `event` WHERE `cid` = %d", intval($id));
|
|
|
|
|
|
|
|
q("DELETE FROM `queue` WHERE `cid` = %d", intval($id));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (array_search(__file__, get_included_files()) === 0) {
|
|
|
|
remove_contact_run($_SERVER["argv"], $_SERVER["argc"]);
|
|
|
|
killme();
|
|
|
|
}
|
|
|
|
?>
|