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.
 
 
 
 
 
 

153 lines
3.8 KiB

  1. <?php
  2. function display_content(&$a) {
  3. if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
  4. notice( t('Public access denied.') . EOL);
  5. return;
  6. }
  7. require_once("include/bbcode.php");
  8. require_once('include/security.php');
  9. require_once('include/conversation.php');
  10. require_once('include/acl_selectors.php');
  11. $o = '';
  12. $a->page['htmlhead'] .= get_markup_template('display-head.tpl');
  13. $nick = (($a->argc > 1) ? $a->argv[1] : '');
  14. profile_load($a,$nick);
  15. $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
  16. if(! $item_id) {
  17. $a->error = 404;
  18. notice( t('Item not found.') . EOL);
  19. return;
  20. }
  21. $groups = array();
  22. $contact = null;
  23. $remote_contact = false;
  24. $contact_id = 0;
  25. if(is_array($_SESSION['remote'])) {
  26. foreach($_SESSION['remote'] as $v) {
  27. if($v['uid'] == $a->profile['uid']) {
  28. $contact_id = $v['cid'];
  29. break;
  30. }
  31. }
  32. }
  33. if($contact_id) {
  34. $groups = init_groups_visitor($contact_id);
  35. $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
  36. intval($contact_id),
  37. intval($a->profile['uid'])
  38. );
  39. if(count($r)) {
  40. $contact = $r[0];
  41. $remote_contact = true;
  42. }
  43. }
  44. if(! $remote_contact) {
  45. if(local_user()) {
  46. $contact_id = $_SESSION['cid'];
  47. $contact = $a->contact;
  48. }
  49. }
  50. $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
  51. intval($a->profile['uid'])
  52. );
  53. if(count($r))
  54. $a->page_contact = $r[0];
  55. $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
  56. if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
  57. notice( t('Access to this profile has been restricted.') . EOL);
  58. return;
  59. }
  60. if ($is_owner) {
  61. $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
  62. $x = array(
  63. 'is_owner' => true,
  64. 'allow_location' => $a->user['allow_location'],
  65. 'default_location' => $a->user['default-location'],
  66. 'nickname' => $a->user['nickname'],
  67. 'lockstate' => ( (is_array($a->user)) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))) ? 'lock' : 'unlock'),
  68. 'acl' => populate_acl($a->user, $celeb),
  69. 'bang' => '',
  70. 'visitor' => 'block',
  71. 'profile_uid' => local_user()
  72. );
  73. $o .= status_editor($a,$x,0,true);
  74. }
  75. $sql_extra = item_permissions_sql($a->profile['uid'],$remote_contact,$groups);
  76. $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
  77. `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
  78. `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
  79. `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
  80. FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
  81. WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
  82. and `item`.`moderated` = 0
  83. AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
  84. AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' ))
  85. $sql_extra
  86. ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
  87. intval($a->profile['uid']),
  88. dbesc($item_id),
  89. dbesc($item_id)
  90. );
  91. if(count($r)) {
  92. if((local_user()) && (local_user() == $a->profile['uid'])) {
  93. q("UPDATE `item` SET `unseen` = 0
  94. WHERE `parent` = %d AND `unseen` = 1",
  95. intval($r[0]['parent'])
  96. );
  97. }
  98. $items = conv_sort($r,"`commented`");
  99. $o .= conversation($a,$items,'display', false);
  100. }
  101. else {
  102. $r = q("SELECT `id`,`deleted` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
  103. dbesc($item_id),
  104. dbesc($item_id)
  105. );
  106. if(count($r)) {
  107. if($r[0]['deleted']) {
  108. notice( t('Item has been removed.') . EOL );
  109. }
  110. else {
  111. notice( t('Permission denied.') . EOL );
  112. }
  113. }
  114. else {
  115. notice( t('Item not found.') . EOL );
  116. }
  117. }
  118. return $o;
  119. }