timeline.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <?php
  2. /* this file will fetch and render the posts of a timeline based
  3. on the options of the user_settings cookie and the url query.
  4. a "timeline" may be something like TWKN or just a single post
  5. */
  6. $thread = timeline(array_merge($tl, $user_settings));
  7. /*
  8. if the timeline requested is the first part of an user profile it will render first
  9. the user profile header, i may move this to it's own place in the future but
  10. for now it's here.
  11. */
  12. if (isset($_GET['user']) && (!isset($_GET['next']) && !isset($_GET['since']))) {
  13. list($info, $rel) = user_info($_GET['user']);
  14. $template = themes("get","templates/profileheader.txt");
  15. $profile['mainColor'] = averageColor($info['avatar']);
  16. $profile['header'] = $info['header_static'];
  17. /* display user buttons (block, mute, list, etc) for loged in users only */
  18. $profile['top'] = ($logedin ? "<span id='" . $info['id'] . "' class='profileButton profileMenu' style='position:relative;'>&#xe811;
  19. <div class='menu' style='width:80px; position:absolute; background-color:yellow; top:25px; display:none;'>
  20. <div id='" . $info['id'] . "' class='profileButton " . ($rel[0]['muting'] ? "un" : "") . "mute' style='width:100%; border-radius:0px;'>" . ($rel[0]['muting'] ? "&#xe81a; Unmute" : "&#xe81b; Mute") . "</div>
  21. <div id='" . $info['id'] . "' class='profileButton " . ($rel[0]['blocking'] ? "un" : "") . "block' style='width:100%; border-radius:0px;'>" . ($rel[0]['blocking'] ? "&#xe80d Unblock" : "&#xe813; Block") . "</div>
  22. </div>
  23. </span>" : "");
  24. if ($logedin && $rel[0]['following']) {
  25. $profile['top'] .= "<span id='" . $info['id'] . "' class='profileButton listmenu' style='position:relative;'>Lists &#xe80b;
  26. <div class='menu' style='width:120px; position:absolute; background-color:yellow; top:25px; left:00px; display:none;'><ul>";
  27. $userlist = api_get("accounts/" . $info['id'] . "/lists");
  28. $listids = array();
  29. foreach ($userlist as $lst) {
  30. $listids[] = $lst['id'];
  31. }
  32. $lists = api_get("/lists");
  33. foreach ($lists as $list) {
  34. $profile['top'] .= "<a href='?action=addtolist&user=" . $info['id'] . "&list=" . $list['id'] . "' id='" . $info['id'] . "' list='" . $list['id'] . "' class='" . (in_array($list['id'], $listids) ? 'rutl' : 'autl') . "' onClick='return false;'><li>" . $list['title'] . "</li></a>";
  35. }
  36. $profile['top'] .= "<a href='?page=lists' class='ldr' onClick='return false;'><li>Manage Lists</li></a>";
  37. $profile['top'] .= "
  38. </ul></div>
  39. </span>";
  40. }
  41. if ($logedin) {
  42. if ($rel[0]['following']) {
  43. $label = "&#xe80c; Following";
  44. $class = "unfollow";
  45. }
  46. else {
  47. if ($info['locked']) {
  48. if ($rel[0]['requested']) {
  49. $label = "&#xe806; Follow Requested";
  50. $class = "unfollow";
  51. }
  52. else {
  53. $label = "&#xe806; Request Follow";
  54. $class = "follow";
  55. }
  56. }
  57. else {
  58. $label = "&#xf234; Follow";
  59. $class = "follow";
  60. }
  61. }
  62. $profile['top'] .= "<span id='" . $info['id'] . "' class='profileButton $class'>$label</span>";
  63. }
  64. /* The NSFW button is available even to non logged in users, the value is stored in a cookie */
  65. $profile['top'] .= "<span id='" . $info['id'] . "' class='profileButton " . (in_array($info['id'], $user_settings['nsfw']) ? "unnsfw" : "nsfw") . "'>" . (in_array($info['id'], $user_settings['nsfw']) ? "NSFW <span class='fontello'>&#xf205;</span>" : "NSFW <span class='fontello'>&#xf204;</span>") . "</span>";
  66. /* display some indicators (blocked, muting, etc) for loged in users only */
  67. if ($logedin) {
  68. $profile['bottom'] = "
  69. " . ($info['locked'] ? "<span class='profileButton' style='background-color: rgba(255,255,255,.5);'>&#xe819; Locked</span>" : "") . "
  70. " . ($rel[0]['followed_by'] ? "<span class='profileButton' style='background-color: rgba(255,255,255,.5);'>&#xe80c; Follows You</span>" : "") . "
  71. " . ($rel[0]['blocking'] ? "<span class='profileButton' style='background-color: rgba(255,255,255,.5);'>&#xe82c; Blocked</span>" : "") . "
  72. " . ($rel[0]['muting'] ? "<span class='profileButton' style='background-color: rgba(255,255,255,.5);'>&#xe813; Muted</span>" : "") . "
  73. ";
  74. }
  75. else {
  76. $profile['bottom'] = "";
  77. }
  78. /* some values are processed from the profile and stored in the $profile array*/
  79. $profile['avatar'] = $info['avatar'];
  80. $profile['name'] = emojify($info['display_name'], $info['emojis'], 40);
  81. $profile['acct'] = $info['acct'];
  82. $profile['url'] = $info['url'];
  83. $profile['note'] = emojify(trim($info['note']) , $info['emojis']);
  84. $profile['statuses'] = $info['statuses_count'];
  85. $profile['following'] = $info['following_count'];
  86. $profile['followers'] = $info['followers_count'];
  87. /* now we replace the text of the index of $profile array with the contents of the index
  88. in the fetched template */
  89. foreach ($profile as $key => $value) {
  90. $template = str_replace(":$key:", $value, $template);
  91. }
  92. echo $template;
  93. }
  94. elseif (!isset($_GET['next']) && !isset($_GET['since'])) {
  95. echo "<div class='element'></div>";
  96. }
  97. /*
  98. if the timeline array is empty or the content is not a post, we just display an error message.
  99. */
  100. if ((!isset($thread[0]['id']) && !empty($thread)) || !is_array($thread)) {
  101. //echo "<div class='element'><div class='avatar'></div><span class='button error'> Error loading the timeline. " . json_encode($thread) . "</span></div>";
  102. } else {
  103. $e = 0;
  104. /* process all the posts on the timeline */
  105. foreach ($thread as $elem) {
  106. $post = array();
  107. /* pid is the ABSOLUTE id of a post, not linked to the relative id,
  108. a retweet has a different absolute id than the post that was retweeted */
  109. $post['pid'] = $elem['id'];
  110. $post['replyto'] = "";
  111. $post['rt'] = "";
  112. /* if the post is a retweet, we'll flag it as such and fetch the data of the post entity
  113. from the "reblog" key
  114. */
  115. if ($elem['reblog'] != null) {
  116. if ($user_settings['reblog'] == 'off'){
  117. continue;
  118. }
  119. $post['name'] = (empty($elem['reblog']['account']['display_name']) ? $elem['reblog']['account']['acct'] : emojify($elem['reblog']['account']['display_name'], $elem['reblog']['account']['emojis'], 20));
  120. $post['uid'] = $elem['reblog']['account']['id'];
  121. $post['acct'] = '';//$elem['reblog']['account']['acct'];
  122. $post['handle'] = explode("@",$elem['reblog']['account']['acct'])[0];
  123. $post['replyto'] = "<span>" . ($elem['reblog']['in_reply_to_id'] ? " <a class='fontello link preview ldr' target='_blank' id='" . $elem['reblog']['in_reply_to_id'] . "' href='?thread=" . $elem['reblog']['in_reply_to_id'] . "'>&#xf112;</a>" : "") . "</span>";
  124. $post['rt'] = "<div style='display:inline-block; font-family:fontello, sans-serif; vertical-align:top;'>&#xe826; by <img src='" . $elem['account']['avatar'] . "' width=20 style='border-radius:5px; vertical-align:middle;'> <span class='user' id='" . $elem['account']['id'] . "'><a class='link ldr' style='font-size:12px;' id='" . $elem['account']['id'] . "' href='?user=" . $elem['account']['id'] . "'><span>@" . explode("@", $elem['account']['acct']) [0] . "</a></span></div>";
  125. $elem = $elem['reblog'];
  126. }
  127. else {
  128. $post['name'] = (empty($elem['account']['display_name']) ? $elem['account']['acct'] : emojify($elem['account']['display_name'], $elem['account']['emojis'], 20));
  129. $post['uid'] = $elem['account']['id'];
  130. $post['acct'] = "(@".$elem['account']['acct'].")";
  131. $post['handle'] = explode("@",$elem['account']['acct'])[0];
  132. $post['replyto'] = "<span>" . ($elem['in_reply_to_id'] ? " <a class='fontello link preview ldr' target='_blank' id='" . $elem['in_reply_to_id'] . "' href='?thread=" . $elem['in_reply_to_id'] . "'>&#xf112;</a>" : "") . "</span>";
  133. }
  134. /* We skip the post if it contains any of the muted words */
  135. foreach($user_settings['mtwords'] as $word){
  136. if(contains($elem['content'],trim($word))){
  137. continue 2;
  138. }
  139. }
  140. /* if the poster ID was flagged as NSFW by the user, the post is flagged
  141. as sensitive by default */
  142. if (in_array($elem["account"]['id'], $user_settings['nsfw'])) {
  143. $elem['sensitive'] = true;
  144. }
  145. /* if the settings say to avoid showing posts with NSFW content, we skip to the next post */
  146. if ($user_settings['explicit'] == "hide" && $elem['sensitive'] == true && $tl['mode'] != "thread") {
  147. continue;
  148. }
  149. /* if this thread has been hidden by the user, we skip to the next one
  150. note that the "conversation_id" post key is only available with pleroma servers
  151. */
  152. if (@in_array($elem["pleroma"]['conversation_id'], $user_settings['hide'])) {
  153. continue;
  154. }
  155. /* the $json array stores some data about the thread that is embedded inside the
  156. html of the post and is mostly used by the javascript portion of the FE. It stores
  157. the id of the post, the visibility and who was mentioned in the post.
  158. */
  159. $json['id'] = $elem['id'];
  160. $json['scope'] = $elem['visibility'];
  161. if ($logedin) {
  162. $pos['mentions'] = "";
  163. $array = $elem["mentions"];
  164. $json['mentions'] = ($user_settings['acct'] == $elem["account"]['acct'] ? "" : "@" . $elem["account"]['acct']) . " ";
  165. if (!empty($array)) {
  166. foreach ($array as $mnt) {
  167. if ($mnt['acct'] != $user_settings['acct'] && $mnt['acct'] != $elem['account']['acct']) {
  168. $json['mentions'] .= "@" . $mnt['acct'] . " ";
  169. }
  170. }
  171. }
  172. }
  173. $post['json'] = json_encode($json);
  174. /* the options menu of the post */
  175. $post['menu'] = "<ul>";
  176. if ($logedin) {
  177. $post['menu'] .= ($elem['account']['id'] == $user_settings['uid'] ? "<li><a href='?action=delete&thread=" . $elem['id'] . "' onClick='return false;' class='delete fontello' id=':id:'>&#xe80e; Delete Post</a></li>" : "");
  178. $post['menu'] .= "<li><a href='?action=compose&quote=" . $elem['id'] . "' onClick='return false;' class='quote fontello' id='" . $elem['id'] . "' style='background-color:transparent;'>&#xf10e; Quote Post</a></li>";
  179. $post['menu'] .= ($elem['account']['id'] != $user_settings['uid'] ? "<li><a href='?action=mute&user=" . $elem['account']['id'] . "' onClick='return false;' class='mute fontello' id='" . $elem['account']['id'] . "' style='background-color:transparent;'>&#xe81b; Mute User</a></li>" : "");
  180. $post['menu'] .= ($elem['account']['id'] != $user_settings['uid'] ? "<li><a href='?action=mute&thread=" . $elem['account']['id'] . "' onClick='return false;' class='muteconv fontello' id='" . $elem['id'] . "' style='background-color:transparent;'>&#xf1f7; Drop Thread</a></li>" : "");
  181. $post['menu'] .= (isset($user_settings['pleroma']) ? "<li><a href='?action=hide&thread=" . $elem['pleroma']['conversation_id'] . "' onClick='return false;' class='hide fontello' id='" . $elem['pleroma']['conversation_id'] . "' style='background-color:transparent;'>&#xf1f8; Hide Thread</a></li>" : "");
  182. $post['menu'] .= "<li><a href='?action=bookmark&thread=" . $elem['account']['id'] . "' onClick='return false;' class='" . ($elem['bookmarked'] == true ? "un" : "") . "bookmark fontello' id='" . $elem['id'] . "' style='background-color:transparent;'>&#xe81e; " . ($elem['bookmarked'] == true ? "Unb" : "B") . "ookmark</a></li>";
  183. $post['menu'] .= ($elem['account']['id'] != $user_settings['uid'] ? "<li><a href='?action=nsfw&user=" . $elem['account']['id'] . "' onClick='return false;' class='nsfw fontello' id='" . $elem['account']['id'] . "' style='background-color:transparent;'>&#xe829; User is NSFW</a></li>" : "");
  184. }
  185. $post['menu'] .= "<li><a target='_blank' href='" . $elem['url'] . "' class='original link fontello' style='background-color:transparent;'>&#xf14c; Original Note</a></li>";
  186. $post['menu'] .= "</ul>";
  187. $post['style'] = "";
  188. $post['id'] = $elem['id'];
  189. $post['avatar'] = $elem['account']['avatar'];
  190. $post['text'] = processText($elem);
  191. if (!empty($elem['poll'])){
  192. $post['text'] .= "<div class='poll' id='".$elem['poll']['id']."' ".($elem['poll']['multiple'] ? "multiple" : "").">";
  193. $post['text'] .= renderPoll($elem);
  194. $post['text'] .= "</div>";
  195. }
  196. $post['spoiler'] = "";
  197. $post['hidden'] = "";
  198. if ($user_settings['unrollcw'] == 'off'){
  199. $post['spoiler'] = (empty($elem['spoiler_text']) ? "" : "<div class='spoiler' style='font-weight:bold;font-size:15px;'>" . emojify($elem['spoiler_text'], $elem['emojis'], 40) . "<a style='display:block;'>Click here to reveal</a></div>");
  200. $post['hidden'] = (empty($elem['spoiler_text']) ? "" : "hidden");
  201. } else {
  202. $post['spoiler'] = (empty($elem['spoiler_text']) ? "" : "<div style='font-weight:bold;font-size:15px;'>" . emojify($elem['spoiler_text'], $elem['emojis'], 40) . "</div>");
  203. }
  204. $post['media'] = "";
  205. $urls = get_urls(strip_tags($elem['content'], '<br><br \>'));
  206. /* embed videos in the post via invidio.us if there are youtube links */
  207. if (!empty($urls)) {
  208. foreach ($urls as $url) {
  209. parse_str(parse_url($url, PHP_URL_QUERY) , $my_array_of_vars);
  210. if (isset($my_array_of_vars['v'])) {
  211. $post['media'] = "<embed class='desktop' width='620' height='415' src='https://youtube.com/embed/" . $my_array_of_vars['v'] . "'>";
  212. }
  213. }
  214. }
  215. /* embed the media attachments to the post... */
  216. if (!empty($elem['media_attachments'])) {
  217. /* ...only if there are attachments and the user hasn't turned off the attachments in the settings */
  218. if ($user_settings['attach'] != "off"){
  219. $images = count($elem['media_attachments']);
  220. $class = ($images === 1 ? "" : ($images > 4 ? "class='smaller'" : "class='small'"));
  221. $m = 1;
  222. foreach ($elem['media_attachments'] as $file) {
  223. $ext = explode(".", $file['url']);
  224. $ext = end($ext);
  225. $ext = explode("?", $ext) [0];
  226. if (in_array($ext,array('webm','mp4','ogv')) || $file['type'] == "video") {
  227. $post['media'] .= "<div style='overflow:hidden; float:left; margin:2px;' $class><video preload='metadata' style='text-align:center; max-width:100%; max-height:100%;' controls ".($user_settings['videoloop'] == "on" ? "loop" : "").">
  228. <source src='" . $file['url'] . "' type='video/".($ext == "ogv" ? "ogg" : $ext)."'>
  229. </video></div>
  230. ";
  231. }
  232. elseif (in_array($ext,array('mp3','ogg','oga','opus')) || $file['type'] == "audio") {
  233. $post['media'] .= "<div style='text-align:center; width:100%;'><audio controls>
  234. <source src='" . $file['url'] . "' type='audio/$ext'>
  235. Your browser does not support the audio tag.
  236. </audio> </div>";
  237. }
  238. elseif (in_array($ext,array('jpg','jpeg','png','gif','apng','svg','webp')) || $file['type'] == "image") {
  239. /* we'll either hide the attachment or assign a css class depending on the user's settings */
  240. /* if the post is marked as sensitive and nsfw hiding isn't turned off, we'll blur the image */
  241. if ($elem['sensitive'] == true && $user_settings['explicit'] != 'off') {
  242. //$post['media'] .= " <div style='overflow:hidden; float:left; margin:2px;background-color:#".(($class != "") || ($elem['sensitive'] == true && $user_settings['explicit'] != 'off') ? averageColor($file['url']) : "000")."!important; ".($images === 1 ? "width:100%;" : "max-width:100%; max-height:100%;")."' $class>
  243. $post['media'] .= " <div style='overflow:hidden; float:left; margin:2px;background-color:#".(($class != "") || ($elem['sensitive'] == true && $user_settings['explicit'] != 'off') ? "000" : "000")."!important; ".($images === 1 ? "width:100%;" : "max-width:100%; max-height:100%;")."' $class>
  244. <div class='toggleblur' style='height:25px;'>&#xe81b; Blur</div>
  245. <a target='_blank' href='" . $file['url'] . "' onClick='return false;' style='width:100%;' class='blur'>
  246. <noscript><img src='" . $file['url'] . "' style='width:100%;'></noscript>
  247. <img " . ($e < 2 ? "src='" . $file['url'] . "'" : "data-src='" . $file['url'] . "'") . " class='lazyload' style='".($images === 1 ? "width:100%;" : "max-width:100%; max-height:100%;")." vertical-align:middle;'>
  248. </a>
  249. <a target='_blank' href='" . $file['url'] . "' onClick='return false;' class='open-lightbox' style='display:none;'>
  250. <img src='" . $file['url'] . "' class='lazyload' style='width:100%;'>
  251. </a>
  252. </div>";
  253. }
  254. else {
  255. /* If the post was sensitive and wasn't caught by the nsfw filter and
  256. didn't got blurred, then the image will be shown normally */
  257. $post['media'] .= "<div style='margin:0px; ".($images == 3 && $m == 3 ? "width:100% !important;" : "")."background-color:#".($class != "" ? "000" : "000").";' $class><a target='_blank' href='" . $file['url'] . "' onClick='return false;' class='open-lightbox'><img " . ($e < 2 ? "src='" . $file['url'] . "'" : "data-src='" . $file['url'] . "'") . " class='lazyload' style='" . ($images === 1 ? "width:100%;" : "max-width:100%; max-height:100%;") . " vertical-align:middle;'><noscript><img src='" . $file['url'] . "' style='width:100%;'></noscript></a></div>";
  258. // $post['media'] .= "<div style='margin:0px; ".($images == 3 && $m == 3 ? "width:100% !important;" : "")."background-color:#".($class != "" ? averageColor($file['url']) : "000").";' $class><a target='_blank' href='" . $file['url'] . "' onClick='return false;' class='open-lightbox'><img " . ($e < 2 ? "src='" . $file['url'] . "'" : "data-src='" . $file['url'] . "'") . " class='lazyload' style='" . ($images === 1 ? "width:100%;" : "max-width:100%; max-height:100%;") . " vertical-align:middle;'><noscript><img src='" . $file['url'] . "' style='width:100%;'></noscript></a></div>";
  259. }
  260. } else {
  261. $post['media'] .= "<center><table><tr><td><a href='".$file['remote_url']."' download><img src='img/doc.png' width=40 border=0></a></td><td><a href='".$file['url']."' target='_blank'>".$file['description']."</a></td></tr></table></center>";
  262. }
  263. $m++;
  264. }
  265. } else {
  266. /* if the user turned off attachments we'll only show a link to it */
  267. $post['text'] .= "<br><br>\n";
  268. foreach ($elem['media_attachments'] as $file) {
  269. $post['text'] .= "<span class='fontello'>&#xe818;</span><a href='".$file['url']."' target='_blank' onClick='return false;' class='open-lightbox'>See attachment ".($elem['sensitive'] == true ? "(NSFW)" : "")."</a><br>\n";
  270. }
  271. }
  272. }
  273. /* the code of the post footer (date, visibility and like/reblog buttons */
  274. $post['footer'] = "<div style='float:left;'>
  275. <a style='text-decoration:none;' class='ldr postAge' id='".strtotime($elem['created_at'])."' target='_blank' href='?thread=" . $elem['id'] . "' title='".gmdate("d/m/y H:i", strtotime($elem['created_at']))."'>" .time_elapsed_string($elem['created_at']) . "</a> - <span class='fontello ".$elem['visibility']."'></span> <span class='fontello ". ($elem['sensitive'] == true ? "sensitive" : "")."'> </span>
  276. </div>
  277. <div class='post_buttons' id='" . $elem['id'] . "'>
  278. " . ($logedin ? "<div class='felem'><a onClick='return false' class='replyform' href='?thread=" . $elem['id'] . "' style='font-family:fontello; vertical-align:middle;' alt='reply'>&#xf112;</a></div>" : "") . "
  279. <div class='felem'><a onClick='return false' " . ($logedin ? "class='" . ($elem['favourited'] == true ? "unfav" : "fav") . "' href='?action=true&mode=".($elem['favourited'] == true ? "off" : "true")."&fav=" . $elem['id'] . "'" : "class='notAllowed'") . " style='font-family:fontello; vertical-align:middle;'>&#xe802; <span>" . $elem['favourites_count'] . "</span></a></div>
  280. <div class='felem'><a onClick='return false' " . ($logedin && ($elem['visibility'] == "public" || $elem['visibility'] == "unlisted") ? "class='" . ($elem['reblogged'] == true ? "unreblog" : "reblog") . "' href='?action=true&mode=".($elem['reblogged'] == true ? "off" : "on")."&reblog=" . $elem['id'] . "'" : "class='notAllowed'") . " style='font-family:fontello; vertical-align:middle;'>&#xe83a; <span>" . $elem['reblogs_count'] . "</span></a></div>
  281. <div class='felem'><a class='replies' onClick='return false' href='?thread=" . $elem['id'] . "' style='font-family:fontello; vertical-align:middle;'>&#xe827; <span>" . $elem['replies_count'] . "</span></a></div>
  282. </div>";
  283. $post['form'] = ($tl['mode'] == 'thread' && $logedin ? str_replace(array(
  284. ":id:",
  285. ":content:"
  286. ) , array(
  287. $elem['id'],
  288. $json['mentions']
  289. ) , themes("get","templates/replyform.txt")) : "");
  290. $post['ancestors'] = " ";
  291. $post['descendants'] = " ";
  292. $post['notes'] = "";
  293. /* if the timeline is a single post, we'll fetch the replies and notes */
  294. if ($tl['mode'] == 'thread') {
  295. $replies = ($tl['mode'] == "thread" ? getreplies($tl['thread']) : false);
  296. $notes = ($tl['mode'] == "thread" ? getnotes($tl['thread']) : false);
  297. foreach ($replies as $e) {
  298. if ($e['mode'] == 'ancestor') {
  299. $post['ancestors'] .= render_reply($e['content']);
  300. }
  301. else {
  302. $post['descendants'] .= render_reply($e['content']);
  303. }
  304. }
  305. if ($notes) {
  306. foreach ($notes as $note) {
  307. $post['notes'] .= "<div id='" . $note[1]['id'] . "'>
  308. <a href='?user=" . $note[1]['id'] . "' class='ldr' title='" . $note[1]['acct'] . "'>
  309. <div class='nte' style='background-image:url(" . $note[1]['avatar'] . ");'>
  310. <div class='nte_type' style='background-color:" . ($note[0] == "fav" ? "red" : "green") . "'><span>" . ($note[0] == "fav" ? "&#xe802;" : "&#xe826;") . "</span></div>
  311. </div>
  312. </a>
  313. </div>";
  314. }
  315. }
  316. }
  317. if ((empty($elem['media_attachments']) && $post['media'] == "") || (!(empty($elem['media_attachments']) && $post['media'] == "") && $user_settings['attach'] == "off")) {
  318. $post['template'] = themes("get","templates/textpost.txt");
  319. }
  320. else {
  321. if ($logedin){
  322. $post['template'] = themes("get","templates/post.txt");
  323. } else {
  324. $post['template'] = themes("get","templates/post_logout.txt");
  325. }
  326. }
  327. foreach ($post as $key => $value) {
  328. $post['template'] = str_replace(":$key:", $value, $post['template']);
  329. }
  330. echo $post['template'];
  331. unset($post);
  332. $e++;
  333. $next = $elem['id'];
  334. }
  335. if ((!isset($_GET['next']) || (isset($_GET['next']) && !isset($_GET['ajax']))) && !isset($_GET['since']) && !isset($_GET['thread'])) {
  336. $query = http_build_query(array_filter(array(
  337. 'user' => (isset($tl['user']) ? $tl['user'] : false) ,
  338. 'mode' => $tl['mode']
  339. )));
  340. if ($tl['mode'] != "search"){
  341. echo "<div class='element'><div class='avatar' style='height:0px;'></div><div class='loadmore' style='display:table-cell; height:50px; line-height:50px;'><a class='link' onClick='return false;' style='margin:5px;' href='?next=$next&" . $query . "'>Load More Posts</a></div></div>";
  342. }
  343. }
  344. }
  345. ?>