]> git.mxchange.org Git - friendica.git/blob - include/remove_contact.php
Diaspora Relay: Only accept postings from anyone when the relay is configured
[friendica.git] / include / remove_contact.php
1 <?php
2 /**
3  * @file include/remove_contact.php
4  * @brief Removes orphaned data from deleted contacts
5  */
6
7 use \Friendica\Core\Config;
8
9 require_once("boot.php");
10
11 function remove_contact_run($argv, $argc) {
12         global $a, $db;
13
14         if (is_null($a)) {
15                 $a = new App;
16         }
17
18         if (is_null($db)) {
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);
23         }
24
25         Config::load();
26
27         if ($argc != 2) {
28                 return;
29         }
30
31         $id = intval($argv[1]);
32
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)) {
36                 return;
37         }
38
39         q("DELETE FROM `item` WHERE `contact-id` = %d", intval($id));
40
41         q("DELETE FROM `photo` WHERE `contact-id` = %d", intval($id));
42
43         q("DELETE FROM `mail` WHERE `contact-id` = %d", intval($id));
44
45         q("DELETE FROM `event` WHERE `cid` = %d", intval($id));
46
47         q("DELETE FROM `queue` WHERE `cid` = %d", intval($id));
48 }
49
50 if (array_search(__file__, get_included_files()) === 0) {
51         remove_contact_run($_SERVER["argv"], $_SERVER["argc"]);
52         killme();
53 }
54 ?>