3 * @file include/remove_contact.php
4 * @brief Removes orphaned data from deleted contacts
7 use \Friendica\Core\Config;
9 require_once("boot.php");
11 function remove_contact_run($argv, $argc) {
19 @include(".htconfig.php");
20 require_once("include/dba.php");
21 $db = new dba($db_host, $db_user, $db_pass, $db_data);
22 unset($db_host, $db_user, $db_pass, $db_data);
31 $id = intval($argv[1]);
33 // Only delete if the contact doesn't exist (anymore)
34 $r = q("SELECT `id` FROM `contact` WHERE `id` = %d", intval($id));
35 if (dbm::is_result($r)) {
39 q("DELETE FROM `item` WHERE `contact-id` = %d", intval($id));
41 q("DELETE FROM `photo` WHERE `contact-id` = %d", intval($id));
43 q("DELETE FROM `mail` WHERE `contact-id` = %d", intval($id));
45 q("DELETE FROM `event` WHERE `cid` = %d", intval($id));
47 q("DELETE FROM `queue` WHERE `cid` = %d", intval($id));
50 if (array_search(__file__, get_included_files()) === 0) {
51 remove_contact_run($_SERVER["argv"], $_SERVER["argc"]);