From bc4d21ddbc50a4295ad1be0f4797b09895a65fea Mon Sep 17 00:00:00 2001 From: Minteck Date: Sun, 22 May 2022 18:16:34 +0200 Subject: Initial commit --- profile/index.php | 300 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 300 insertions(+) create mode 100644 profile/index.php (limited to 'profile/index.php') diff --git a/profile/index.php b/profile/index.php new file mode 100644 index 0000000..d1c8469 --- /dev/null +++ b/profile/index.php @@ -0,0 +1,300 @@ + $author, + 'contents' => substr($_POST['post-text'], 0, 500), + 'date' => $date, + 'image' => null, + 'audio' => null, + 'comments' => [], + 'edits' => [] + ])); + } + header("Location: /profile") and die(); + } else if (isset($_POST['post']) && $_POST['post'] === "1" && isset($_POST['edit']) && $_POST['edit'] === "1" && isset($_POST['edit-post'])) { + $posts = array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/data/" . $_PROFILE['mmsp_username'] . "/posts"), function ($item) { + return str_ends_with($item, ".json"); + }); + + if (!in_array($_POST['edit-post'] . ".json", $posts)) header("Location: /profile") and die(); + $id = $_POST['edit-post']; + $post = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/" . $_PROFILE['mmsp_username'] . "/posts/" . $id . ".json"), true); + + $plurality = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/" . $_PROFILE['mmsp_username'] . "/settings/plurality.json"), true); + $date = date('c'); + $author = $plurality['members'][0]; + foreach ($plurality['members'] as $member) { + if ($member['name'] === $_POST['post-member']) { + $author = $member; + } + } + + $post['author'] = $author; + $post['contents'] = substr($_POST['post-text'], 0, 500); + $post['edits'][] = [ + "date" => $date, + "before" => $post['contents'] + ]; + + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/" . $_PROFILE['mmsp_username'] . "/posts/" . $id . ".json", json_encode($post)); + + header("Location: /profile") and die(); + } +} + +$plurality = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/" . $search . "/settings/plurality.json"), true); +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/" . $_PROFILE['mmsp_username'] . "/settings/favorites.json")) { + $favorites = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/" . $_PROFILE['mmsp_username'] . "/settings/favorites.json"), true); +} else { + $favorites = []; +} +$titlec = $plurality['displayname'] . " (@" . $search . ")"; + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/gui/header.app.php"; global $lang; global $Parsedown; + +?> + +
+
+

+ + + + +

+
+ @ + · + + 1 ? $lang['profile']['plural.2'] : $lang['profile']['plural.1'] ?> +   + + + · + 1) echo(count($posts) . " " . $lang['profile']['posts.2']); + ?> +
+ +
+ +
+ +
+
+
+
+
+ setSafeMode(true); $Parsedown->setMarkupEscaped(true); echo $Parsedown->line($post['contents']) ?> +
+ +
+
+ +
+
+ +
+ +
+ + + + + + + + \ No newline at end of file -- cgit