" : ""); if ($logedin && $rel[0]['following']) { $profile['top'] .= "Lists  "; } if ($logedin) { if ($rel[0]['following']) { $label = " Following"; $class = "unfollow"; } else { if ($info['locked']) { if ($rel[0]['requested']) { $label = " Follow Requested"; $class = "unfollow"; } else { $label = " Request Follow"; $class = "follow"; } } else { $label = " Follow"; $class = "follow"; } } $profile['top'] .= "$label"; } /* The NSFW button is available even to non logged in users, the value is stored in a cookie */ $profile['top'] .= "" . (in_array($info['id'], $user_settings['nsfw']) ? "NSFW " : "NSFW ") . ""; /* display some indicators (blocked, muting, etc) for loged in users only */ if ($logedin) { $profile['bottom'] = " " . ($info['locked'] ? " Locked" : "") . " " . ($rel[0]['followed_by'] ? " Follows You" : "") . " " . ($rel[0]['blocking'] ? " Blocked" : "") . " " . ($rel[0]['muting'] ? " Muted" : "") . " "; } else { $profile['bottom'] = ""; } /* some values are processed from the profile and stored in the $profile array*/ $profile['avatar'] = $info['avatar']; $profile['name'] = emojify($info['display_name'], $info['emojis'], 40); $profile['acct'] = $info['acct']; $profile['url'] = $info['url']; $profile['note'] = emojify(trim($info['note']) , $info['emojis']); $profile['statuses'] = $info['statuses_count']; $profile['following'] = $info['following_count']; $profile['followers'] = $info['followers_count']; /* now we replace the text of the index of $profile array with the contents of the index in the fetched template */ foreach ($profile as $key => $value) { $template = str_replace(":$key:", $value, $template); } echo $template; } elseif (!isset($_GET['next']) && !isset($_GET['since'])) { echo "
"; } /* if the timeline array is empty or the content is not a post, we just display an error message. */ if ((!isset($thread[0]['id']) && !empty($thread)) || !is_array($thread)) { //echo "
Error loading the timeline. " . json_encode($thread) . "
"; } else { $e = 0; /* process all the posts on the timeline */ foreach ($thread as $elem) { $post = array(); /* pid is the ABSOLUTE id of a post, not linked to the relative id, a retweet has a different absolute id than the post that was retweeted */ $post['pid'] = $elem['id']; $post['replyto'] = ""; $post['rt'] = ""; /* if the post is a retweet, we'll flag it as such and fetch the data of the post entity from the "reblog" key */ if ($elem['reblog'] != null) { if ($user_settings['reblog'] == 'off'){ continue; } $post['name'] = (empty($elem['reblog']['account']['display_name']) ? $elem['reblog']['account']['acct'] : emojify($elem['reblog']['account']['display_name'], $elem['reblog']['account']['emojis'], 20)); $post['uid'] = $elem['reblog']['account']['id']; $post['acct'] = '';//$elem['reblog']['account']['acct']; $post['handle'] = explode("@",$elem['reblog']['account']['acct'])[0]; $post['replyto'] = "" . ($elem['reblog']['in_reply_to_id'] ? " " : "") . ""; $post['rt'] = "
 by @" . explode("@", $elem['account']['acct']) [0] . "
"; $elem = $elem['reblog']; } else { $post['name'] = (empty($elem['account']['display_name']) ? $elem['account']['acct'] : emojify($elem['account']['display_name'], $elem['account']['emojis'], 20)); $post['uid'] = $elem['account']['id']; $post['acct'] = "(@".$elem['account']['acct'].")"; $post['handle'] = explode("@",$elem['account']['acct'])[0]; $post['replyto'] = "" . ($elem['in_reply_to_id'] ? " " : "") . ""; } /* We skip the post if it contains any of the muted words */ foreach($user_settings['mtwords'] as $word){ if(contains($elem['content'],trim($word))){ continue 2; } } /* if the poster ID was flagged as NSFW by the user, the post is flagged as sensitive by default */ if (in_array($elem["account"]['id'], $user_settings['nsfw'])) { $elem['sensitive'] = true; } /* if the settings say to avoid showing posts with NSFW content, we skip to the next post */ if ($user_settings['explicit'] == "hide" && $elem['sensitive'] == true && $tl['mode'] != "thread") { continue; } /* if this thread has been hidden by the user, we skip to the next one note that the "conversation_id" post key is only available with pleroma servers */ if (@in_array($elem["pleroma"]['conversation_id'], $user_settings['hide'])) { continue; } /* the $json array stores some data about the thread that is embedded inside the html of the post and is mostly used by the javascript portion of the FE. It stores the id of the post, the visibility and who was mentioned in the post. */ $json['id'] = $elem['id']; $json['scope'] = $elem['visibility']; if ($logedin) { $pos['mentions'] = ""; $array = $elem["mentions"]; $json['mentions'] = ($user_settings['acct'] == $elem["account"]['acct'] ? "" : "@" . $elem["account"]['acct']) . " "; if (!empty($array)) { foreach ($array as $mnt) { if ($mnt['acct'] != $user_settings['acct'] && $mnt['acct'] != $elem['account']['acct']) { $json['mentions'] .= "@" . $mnt['acct'] . " "; } } } } $post['json'] = json_encode($json); /* the options menu of the post */ $post['menu'] = ""; $post['style'] = ""; $post['id'] = $elem['id']; $post['avatar'] = $elem['account']['avatar']; $post['text'] = processText($elem); if (!empty($elem['poll'])){ $post['text'] .= "
"; $post['text'] .= renderPoll($elem); $post['text'] .= "
"; } $post['spoiler'] = (empty($elem['spoiler_text']) ? "" : "" . $elem['spoiler_text'] . "
"); $post['media'] = ""; $urls = get_urls(strip_tags($elem['content'], '

')); /* embed videos in the post via invidio.us if there are youtube links */ if (!empty($urls)) { foreach ($urls as $url) { parse_str(parse_url($url, PHP_URL_QUERY) , $my_array_of_vars); if (isset($my_array_of_vars['v'])) { $post['media'] = ""; } } } /* embed the media attachments to the post... */ if (!empty($elem['media_attachments'])) { /* ...only if there are attachments and the user hasn't turned off the attachments in the settings */ if ($user_settings['attach'] != "off"){ $images = count($elem['media_attachments']); $class = ($images === 1 ? "" : ($images > 4 ? "class='smaller'" : "class='small'")); $m = 1; foreach ($elem['media_attachments'] as $file) { $ext = explode(".", $file['url']); $ext = end($ext); $ext = explode("?", $ext) [0]; if (in_array($ext,array('webm','mp4','ogv')) || $file['type'] == "video") { $post['media'] .= "
"; } elseif (in_array($ext,array('mp3','ogg','oga','opus')) || $file['type'] == "audio") { $post['media'] .= "
"; } elseif (in_array($ext,array('jpg','jpeg','png','gif','apng','svg','webp')) || $file['type'] == "image") { /* we'll either hide the attachment or assign a css class depending on the user's settings */ /* if the post is marked as sensitive and nsfw hiding isn't turned off, we'll blur the image */ if ($elem['sensitive'] == true && $user_settings['explicit'] != 'off') { //$post['media'] .= "
$post['media'] .= "
 Blur
"; } else { /* If the post was sensitive and wasn't caught by the nsfw filter and didn't got blurred, then the image will be shown normally */ $post['media'] .= "
"; // $post['media'] .= "
"; } } else { $post['media'] .= "
".$file['description']."
"; } $m++; } } else { /* if the user turned off attachments we'll only show a link to it */ $post['text'] .= "

\n"; foreach ($elem['media_attachments'] as $file) { $post['text'] .= "See attachment ".($elem['sensitive'] == true ? "(NSFW)" : "")."
\n"; } } } /* the code of the post footer (date, visibility and like/reblog buttons */ $post['footer'] = "
" .time_elapsed_string($elem['created_at']) . " -
" . ($logedin ? "" : "") . "
"; $post['form'] = ($tl['mode'] == 'thread' && $logedin ? str_replace(array( ":id:", ":content:" ) , array( $elem['id'], $json['mentions'] ) , themes("get","templates/replyform.txt")) : ""); $post['ancestors'] = " "; $post['descendants'] = " "; $post['notes'] = ""; /* if the timeline is a single post, we'll fetch the replies and notes */ if ($tl['mode'] == 'thread') { $replies = ($tl['mode'] == "thread" ? getreplies($tl['thread']) : false); $notes = ($tl['mode'] == "thread" ? getnotes($tl['thread']) : false); foreach ($replies as $e) { if ($e['mode'] == 'ancestor') { $post['ancestors'] .= render_reply($e['content']); } else { $post['descendants'] .= render_reply($e['content']); } } if ($notes) { foreach ($notes as $note) { $post['notes'] .= "
" . ($note[0] == "fav" ? "" : "") . "
"; } } } if ((empty($elem['media_attachments']) && $post['media'] == "") || (!(empty($elem['media_attachments']) && $post['media'] == "") && $user_settings['attach'] == "off")) { $post['template'] = themes("get","templates/textpost.txt"); } else { if ($logedin){ $post['template'] = themes("get","templates/post.txt"); x } else { $post['template'] = themes("get","templates/post_logout.txt"); } } foreach ($post as $key => $value) { $post['template'] = str_replace(":$key:", $value, $post['template']); } echo $post['template']; unset($post); $e++; $next = $elem['id']; } if ((!isset($_GET['next']) || (isset($_GET['next']) && !isset($_GET['ajax']))) && !isset($_GET['since']) && !isset($_GET['thread'])) { $query = http_build_query(array_filter(array( 'user' => (isset($tl['user']) ? $tl['user'] : false) , 'mode' => $tl['mode'] ))); if ($tl['mode'] != "search"){ echo "
"; } } } ?>