diff options
author | RaindropsSys <contact@minteck.org> | 2023-03-12 19:16:53 +0100 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-03-12 19:16:53 +0100 |
commit | eb89b15c0f044673c1206a418a21d0baba1a675e (patch) | |
tree | 39ac31a576d8b8392cbd9baf8d67621bf2cefa86 /includes/util/profiles.inc | |
parent | 5385f0ed8fbb4325203a222a75e6700ffb519349 (diff) | |
download | pluralconnect-eb89b15c0f044673c1206a418a21d0baba1a675e.tar.gz pluralconnect-eb89b15c0f044673c1206a418a21d0baba1a675e.tar.bz2 pluralconnect-eb89b15c0f044673c1206a418a21d0baba1a675e.zip |
Updated 104 files, added 3 files, deleted 4 files and renamed 36 files (automated)
Diffstat (limited to 'includes/util/profiles.inc')
-rw-r--r-- | includes/util/profiles.inc | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/includes/util/profiles.inc b/includes/util/profiles.inc new file mode 100644 index 0000000..66274c7 --- /dev/null +++ b/includes/util/profiles.inc @@ -0,0 +1,97 @@ +<?php + +function calculateProfileScore($member) { + $values = [ + ((isset($member["_metadata"]["birth"]["age"]) && $member["_metadata"]["birth"]["age"] > 0) || isset($member["_metadata"]["birth"]["year"]) && $member["_metadata"]["birth"]["year"] > 1900) || ((isset($member["_metadata"]["birth"]["age"]) && $member["_metadata"]["birth"]["age"] === -1) && in_array("alicorn", $member["_metadata"]["species"])), + isset($member["_metadata"]["birth"]["date"]) && trim($member["_metadata"]["birth"]["date"]) !== "" && $member["_metadata"]["birth"]["date"] !== "01-01", + file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html") && strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html"))) > 200, + file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html") && strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html"))) > 200, + isset($member["banner"]), + file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png"), + isset($member["color"]) + ]; + + $result = [ + "values" => $values, + "pages" => [], + "characters" => [], + "score" => (float)array_reduce($values, function ($a, $b) { + return $a + $b; + }), + "score2" => (float)array_reduce($values, function ($a, $b) { + return $a + $b; + }), + "actions" => [] + ]; + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html") && strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html"))) <= 200) { + $result["pages"][] = true; + $result["score"] += strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html"))) / 201; + } else { + $result["pages"][] = false; + } + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html") && strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html"))) <= 200) { + $result["pages"][] = true; + $result["score"] += strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html"))) / 201; + } else { + $result["pages"][] = false; + } + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html")) { + $result["characters"][] = strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . ".html"))); + } else { + $result["characters"][] = -1; + } + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html")) { + $result["characters"][] = strlen(preg_replace("/[^a-zA-Z0-9]/m", "", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member["id"] . "-private.html"))); + } else { + $result["characters"][] = -1; + } + + if (!((isset($member["_metadata"]["birth"]["age"]) && $member["_metadata"]["birth"]["age"] > 0) || isset($member["_metadata"]["birth"]["year"]) && $member["_metadata"]["birth"]["year"] > 1900) && !(isset($member["_metadata"]["birth"]["age"]) && $member["_metadata"]["birth"]["age"] === -1) && in_array("alicorn", $member["_metadata"]["species"])) { + $result["score"] += 0.5; + } + + $result["progress"] = $result["score"] / 7; + $result["sortable"] = (int)($result["progress"] * 100000000000000); + + if (!$result["values"][5]) { + $result["actions"][] = "a Pony Town character"; + } + + if (!$result["values"][6]) { + $result["actions"][] = "a color"; + } + + if (!$result["values"][2]) { + if ($result["characters"][0] === -1) { + $result["actions"][] = "a public page"; + } else { + $result["actions"][] = (200 - $result["characters"][0]) . " characters to the public page"; + } + } + + if (!$result["values"][3]) { + if ($result["characters"][1] === -1) { + $result["actions"][] = "a private page"; + } else { + $result["actions"][] = (200 - $result["characters"][1]) . " characters to the private page"; + } + } + + if (!$result["values"][4]) { + $result["actions"][] = "a banner"; + } + + if (!$result["values"][0]) { + $result["actions"][] = "an age"; + } + + if (!$result["values"][1]) { + $result["actions"][] = "a birthdate"; + } + + return $result; +}
\ No newline at end of file |