Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

55 lines
1.1 KiB

  1. <?php
  2. /**
  3. * @file include/remove_contact.php
  4. * @brief Removes orphaned data from deleted contacts
  5. */
  6. use \Friendica\Core\Config;
  7. require_once("boot.php");
  8. function remove_contact_run($argv, $argc) {
  9. global $a, $db;
  10. if (is_null($a)) {
  11. $a = new App;
  12. }
  13. if (is_null($db)) {
  14. @include(".htconfig.php");
  15. require_once("include/dba.php");
  16. $db = new dba($db_host, $db_user, $db_pass, $db_data);
  17. unset($db_host, $db_user, $db_pass, $db_data);
  18. }
  19. Config::load();
  20. if ($argc != 2) {
  21. return;
  22. }
  23. $id = intval($argv[1]);
  24. // Only delete if the contact doesn't exist (anymore)
  25. $r = q("SELECT `id` FROM `contact` WHERE `id` = %d", intval($id));
  26. if (dbm::is_result($r)) {
  27. return;
  28. }
  29. q("DELETE FROM `item` WHERE `contact-id` = %d", intval($id));
  30. q("DELETE FROM `photo` WHERE `contact-id` = %d", intval($id));
  31. q("DELETE FROM `mail` WHERE `contact-id` = %d", intval($id));
  32. q("DELETE FROM `event` WHERE `cid` = %d", intval($id));
  33. q("DELETE FROM `queue` WHERE `cid` = %d", intval($id));
  34. }
  35. if (array_search(__file__, get_included_files()) === 0) {
  36. remove_contact_run($_SERVER["argv"], $_SERVER["argc"]);
  37. killme();
  38. }
  39. ?>