From bc4d21ddbc50a4295ad1be0f4797b09895a65fea Mon Sep 17 00:00:00 2001 From: Minteck Date: Sun, 22 May 2022 18:16:34 +0200 Subject: Initial commit --- initial/index.php | 395 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 395 insertions(+) create mode 100644 initial/index.php (limited to 'initial') diff --git a/initial/index.php b/initial/index.php new file mode 100644 index 0000000..e7c3fb1 --- /dev/null +++ b/initial/index.php @@ -0,0 +1,395 @@ + -1 && $_GET['s'] < 6) { + $step = (int)$_GET['s']; +} else { + header("Location: ?s=0"); + die(); +} + +switch ($_GET['s']) { + case "0": + $title = "initial"; + break; + case "1": + $title = "initial.1"; + break; + case "2": + $title = "initial.2"; + break; + case "3": + $title = "initial.3"; + break; + case "4": + $title = "initial.4"; + break; + default: + break; +} + +if ($step >= 3) { + if (!isset($_GET['s2-display']) || !is_string($_GET['s2-display']) || trim($_GET['s2-display']) === "") header("Location: ?s=2") and die; + if (!isset($_GET['s2-username']) || !is_string($_GET['s2-username']) || trim($_GET['s2-username']) === "") header("Location: ?s=2") and die; + if (!isset($_GET['s2-plural']) || trim($_GET['s2-plural']) === "" || !is_numeric($_GET['s2-plural'])) header("Location: ?s=2") and die; + + $display = substr(str_replace("\"", "''", strip_tags($_GET['s2-display'])), 0, 30); + $username = preg_replace("/\.+/mi", ".", preg_replace("/[^a-z\d]+/mi", ".", substr(str_replace("\"", "''", strip_tags($_GET['s2-username'])), 0, 30))); + $plural = (int)$_GET['s2-plural']; + + if ($username === ".") header("Location: ?s=2") and die; + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/" . $username) || $username === "system" || $username === "users.json" || str_contains($username, "multisocial")) header("Location: ?s=2&s2-display=" . urlencode($display) . "&s2-username=" . urlencode($username) . "&s3-taken" . ($plural === 1 ? "&s2-plural=1" : "")) and die; + + if ($plural === 0 && $step === 3) { + header("Location: ?s=4&s2-display=" . urlencode($display) . "&s2-username=" . urlencode($username) . "&s2-plural=0&s3-members[0]=&s3-pluralkit=&s2-plural=0") and die; + } + + if ($step >= 4) { + if (!isset($_GET['s3-members']) || !is_array($_GET['s3-members'])) header("Location: ?s=3&s2-display=" . urlencode($display) . "&s2-username=" . urlencode($username) . ($plural === 1 ? "&s2-plural=1" : "")) and die; + if (!isset($_GET['s3-pluralkit']) || !is_string($_GET['s3-pluralkit'])) header("Location: ?s=3&s2-display=" . urlencode($display) . "&s2-username=" . urlencode($username) . ($plural === 1 ? "&s2-plural=1" : "")) and die; + + if ($plural === 1) { + if (trim($_GET['s3-members'][0]) === "" && strlen(trim($_GET['s3-pluralkit'])) !== 5 && strlen(trim($_GET['s3-pluralkit'])) !== 18) header("Location: ?s=3&s2-display=" . urlencode($display) . "&s2-username=" . urlencode($username) . "&s2-plural=1") and die; + } + } + + if ($step === 5) { + if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/" . $username)) mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/" . $username); + if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/" . $username . "/posts")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/" . $username . "/posts"); + if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/" . $username . "/settings")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/" . $username . "/settings"); + + $members = []; + foreach ($_GET['s3-members'] as $member) { + $members[] = [ + 'fronting' => false, + 'name' => substr(str_replace("\"", "''", strip_tags($member)), 0, 30), + 'picture' => null, + 'proxy' => [] + ]; + } + + if (trim($_GET['s3-pluralkit']) !== "") { + $system = json_decode(file_get_contents("https://api.pluralkit.me/v2/systems/" . $_GET['s3-pluralkit']), true); + $sysmembers = json_decode(file_get_contents("https://api.pluralkit.me/v2/systems/" . $_GET['s3-pluralkit'] . "/members"), true); + $sysfronters = json_decode(file_get_contents("https://api.pluralkit.me/v2/systems/" . $_GET['s3-pluralkit'] . "/fronters"), true); + + $fronters = []; + foreach ($sysfronters['members'] as $fronter) { + $fronters[] = $fronter['id']; + } + + $members = []; + foreach ($sysmembers as $member) { + $members[] = [ + 'fronting' => in_array($member['id'], $fronters), + 'name' => substr(str_replace("\"", "''", strip_tags($member["display_name"] ?? $member["name"])), 0, 30), + 'picture' => $member["avatar_url"], + 'proxy' => $member["proxy_tags"] + ]; + } + } + + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/" . $username . "/settings/plurality.json", json_encode([ + "plural" => $plural === 1, + "picture" => trim($_GET['s3-pluralkit']) !== "" ? ($system['avatar_url'] ?? null) : null, + "displayname" => trim($_GET['s3-pluralkit']) !== "" ? ($system['name'] ?? $display) : $display, + "pluralkit" => trim($_GET['s3-pluralkit']) !== "" ? $_GET['s3-pluralkit'] : null, + "members" => count($members) > 0 ? $members : null + ])); + $users = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/users.json"), true); + $users[$_PROFILE['id']] = $username; + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/users.json", json_encode($users)); + header("Location: /") and die(); + } +} + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/gui/header.initial.php"; global $lang; global $_PROFILE; global $Parsedown; + +?> + + +
+
+

+

+ + +
+ +
+ + +

+

+ +

+

+
+ +
+
+

+

+
+ text(file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/includes/terms/' . $langp . '.md'))); + } else { + echo($Parsedown->text(file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/includes/terms/en.md'))); + } + + ?> +
+
+

+ +

+

+
+ +
+
+

+

+ +
+
+
+ PluralKit", $lang["intro"]["s2"]["system"]) ?> +
+
+ + +
+ +
+ + +
+ " + + value="" + >
+ " + + value="" + > + + + +
+

+ "> +

+
+

+ +
+ +

+
+ + + +
+
+

+

+

+ ' . $lang['intro']['s3']['back-action'] . '', $lang['intro']['s3']['back']) ?> +

+
+

+

+ " + + value="" + > +
+
+ +

+

+
+ "> +
+
+ + + + + + +

+ "> +

+
+
+ + + +
+
+

+

+

+ $member) { + $sys .= "&s3-members[$id]=$member"; + } + + ?> + +

+

+
+ \ No newline at end of file -- cgit