summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2023-01-22 09:13:00 +0100
committerMinteck <contact@minteck.org>2023-01-22 09:13:00 +0100
commitee7daaafbd6513fe93c6f17b44a6287d0dac09a1 (patch)
tree6a19bbd166b0d449dba4e4bf0a2a2e925bc7e9cb
parent28fca88e2c9869e52644384ac6e2fd6848ba67b9 (diff)
downloaddelta-ee7daaafbd6513fe93c6f17b44a6287d0dac09a1.tar.gz
delta-ee7daaafbd6513fe93c6f17b44a6287d0dac09a1.tar.bz2
delta-ee7daaafbd6513fe93c6f17b44a6287d0dac09a1.zip
Updated 26 files and added router.php (automated)
-rw-r--r--_articles/index.php4
-rw-r--r--_edit/index.php8
-rw-r--r--_edit/save/index.php6
-rw-r--r--_gallery/index.php4
-rw-r--r--_people/index.php8
-rw-r--r--_profile/index.php2
-rw-r--r--_upload/index.php2
-rw-r--r--_upload/save/index.php2
-rw-r--r--admin/approve/index.php14
-rw-r--r--admin/create/save/index.php2
-rw-r--r--admin/edit/index.php2
-rw-r--r--admin/edit/save/index.php2
-rw-r--r--admin/index.php28
-rw-r--r--admin/reject/index.php6
-rw-r--r--content/index.php6
-rw-r--r--handoff/fcm/index.php4
-rw-r--r--includes/functions.php18
-rw-r--r--includes/jobs-handler.php6
-rw-r--r--includes/session.php14
-rw-r--r--index.php10
-rw-r--r--login/index.php14
-rw-r--r--request/index.php2
-rw-r--r--request/save/index.php2
-rw-r--r--requests/delete/index.php6
-rw-r--r--requests/index.php4
-rw-r--r--router.php71
-rw-r--r--support/index.php4
27 files changed, 167 insertions, 84 deletions
diff --git a/_articles/index.php b/_articles/index.php
index 640ce33..9e7d31d 100644
--- a/_articles/index.php
+++ b/_articles/index.php
@@ -16,7 +16,7 @@ if (isset($id)) {
die();
}
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $id . ".json")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $id . ".json")), true);
$title_pre = $data["title"];
$title = "lang_articles_title";
@@ -46,7 +46,7 @@ if (!isset($id)):
?>
<div class="list-group">
- <?php foreach ($articles as $person): $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $person)), true); ?>
+ <?php foreach ($articles as $person): $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $person)), true); ?>
<a href="/articles/<?= explode(".", $person)[0] ?>" class="list-group-item list-group-item-action"><?= $data["title"] ?></a>
<?php endforeach; ?>
</div>
diff --git a/_edit/index.php b/_edit/index.php
index 2ac2911..b2350ac 100644
--- a/_edit/index.php
+++ b/_edit/index.php
@@ -22,13 +22,13 @@ if (isset($id)) {
}
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json")) {
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json")), true);
$title_pre = $data["first_name"] . " " . $data["last_name"];
} else if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $id . ".json")) {
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $id . ".json")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $id . ".json")), true);
$title_pre = $data["title"];
} else if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")) {
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")), true);
$title_pre = $data["title"];
} else {
$self = true;
@@ -134,7 +134,7 @@ if (!isset($_PROFILE["requests"][$id])):
<p><b><?= l("lang_edit_alert_title") ?></b></p>
<?php
- $request = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $_PROFILE["requests"][$id] . ".json")), true);
+ $request = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $_PROFILE["requests"][$id] . ".json")), true);
?>
<p><?= str_replace("%1", timeAgo($request["date"]), l("lang_edit_alert_message")) ?></p>
diff --git a/_edit/save/index.php b/_edit/save/index.php
index 856efd8..eb26ac9 100644
--- a/_edit/save/index.php
+++ b/_edit/save/index.php
@@ -30,7 +30,7 @@ $rid = uuid();
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json")) {
if ($_PROFILE["blocked"] >= $blockLevel) die();
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $rid . ".json", utf8_encode(json_encode([
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $rid . ".json", pf_utf8_encode(json_encode([
"type" => "userpage",
"author" => $_USER,
"id" => $id,
@@ -41,7 +41,7 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".j
} elseif (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $id . ".json")) {
if ($_PROFILE["blocked"] >= $blockLevel) die();
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $rid . ".json", utf8_encode(json_encode([
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $rid . ".json", pf_utf8_encode(json_encode([
"type" => "article",
"author" => $_USER,
"id" => $id,
@@ -52,7 +52,7 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".j
} elseif (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")) {
if ($_PROFILE["blocked"] >= $blockLevel) die();
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $rid . ".json", utf8_encode(json_encode([
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $rid . ".json", pf_utf8_encode(json_encode([
"type" => "gallerymeta",
"author" => $_USER,
"id" => $id,
diff --git a/_gallery/index.php b/_gallery/index.php
index de90416..650a2de 100644
--- a/_gallery/index.php
+++ b/_gallery/index.php
@@ -16,7 +16,7 @@ if (isset($id)) {
die();
}
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")), true);
$title_pre = $data["title"];
$title = "lang_gallery_title";
@@ -46,7 +46,7 @@ if (!isset($id)):
?>
<div class="list-group">
- <?php foreach ($articles as $person): $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $person)), true); ?>
+ <?php foreach ($articles as $person): $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $person)), true); ?>
<a href="/gallery/<?= explode(".", $person)[0] ?>" class="list-group-item list-group-item-action"><?= $data["title"] ?></a>
<?php endforeach; ?>
</div>
diff --git a/_people/index.php b/_people/index.php
index 034adc4..1257e81 100644
--- a/_people/index.php
+++ b/_people/index.php
@@ -1,5 +1,7 @@
<?php
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php";
+
$id = array_values(array_filter(array_keys($_GET), function ($i) {
return str_starts_with($i, "/") && strlen($i) > 1;
}))[0] ?? null;
@@ -16,7 +18,7 @@ if (isset($id)) {
die();
}
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $id . ".json")), true);
$title_pre = $data["first_name"] . " " . $data["last_name"];
$title = "lang_people_title";
@@ -46,7 +48,7 @@ if (!isset($id)):
?>
<div class="list-group">
- <?php foreach ($people as $person): $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $person)), true); ?>
+ <?php foreach ($people as $person): $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $person)), true); ?>
<a href="/people/<?= explode(".", $person)[0] ?>" class="list-group-item list-group-item-action"><?= $data["first_name"] . " " . $data["last_name"] ?></a>
<?php endforeach; ?>
</div>
@@ -169,7 +171,7 @@ if (!isset($id)):
$text = "<code class='text-danger'>" . $nid . "</code>";
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $nid . ".json")) {
- $d = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $nid . ".json")), true);
+ $d = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $nid . ".json")), true);
$text = $d["first_name"] . " " . $d["last_name"];
}
diff --git a/_profile/index.php b/_profile/index.php
index cf2dc84..5bcfb08 100644
--- a/_profile/index.php
+++ b/_profile/index.php
@@ -18,7 +18,7 @@ if (isset($id)) {
die();
}
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $id . ".json")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $id . ".json")), true);
$title_pre = $data["nick_name"] ?? $data["first_name"] . " " . $data["last_name"];
$title = "lang_profile_title";
diff --git a/_upload/index.php b/_upload/index.php
index f69d650..47ce1a6 100644
--- a/_upload/index.php
+++ b/_upload/index.php
@@ -20,7 +20,7 @@ if (isset($id)) {
}
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")) {
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")), true);
$title_pre = $data["title"];
} else {
header("Location: /");
diff --git a/_upload/save/index.php b/_upload/save/index.php
index c15d2da..3c81f4b 100644
--- a/_upload/save/index.php
+++ b/_upload/save/index.php
@@ -56,7 +56,7 @@ switch ($_FILES["file"]["type"]) {
imagejpeg($im, $_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $uuid . ".jpg");
-file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $uuid . ".json", utf8_encode(json_encode([
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $uuid . ".json", pf_utf8_encode(json_encode([
"type" => "galleryupload",
"author" => $_USER,
"id" => $id,
diff --git a/admin/approve/index.php b/admin/approve/index.php
index dedafb4..71697a1 100644
--- a/admin/approve/index.php
+++ b/admin/approve/index.php
@@ -17,12 +17,12 @@ if (isset($id)) {
die();
}
-$request = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $id . ".json")), true);
+$request = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $id . ".json")), true);
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")) {
while (trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")) === "") {}
- $profile = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true);
+ $profile = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true);
loadLang(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/lang/" . $profile["language"] . ".json"), true), "lang");
$index = array_search($id, $profile["requests"]);
@@ -38,12 +38,12 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $reques
"read" => false
];
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json", utf8_encode(json_encode($profile, JSON_PRETTY_PRINT)));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json", pf_utf8_encode(json_encode($profile, JSON_PRETTY_PRINT)));
}
if ($request["type"] === "galleryupload" && !isset($_GET['mark'])) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $request["id"] . ".json")) {
- $gallery = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $request["id"] . ".json")), true);
+ $gallery = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $request["id"] . ".json")), true);
$gallery["images"][] = [
"id" => $id,
"author" => $request["author"],
@@ -52,7 +52,7 @@ if ($request["type"] === "galleryupload" && !isset($_GET['mark'])) {
$gallery["update"] = date('c');
$gallery["update_user"] = $request["author"];
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $request["id"] . ".json", utf8_encode(json_encode($gallery)));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $request["id"] . ".json", pf_utf8_encode(json_encode($gallery)));
}
}
@@ -62,12 +62,12 @@ if (($request["type"] === "gallerymeta" || $request["type"] === "article" || $re
if ($request["type"] === "article") $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/" . $request["id"] . ".json";
if ($request["type"] === "userpage") $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/" . $request["id"] . ".json";
- $d = json_decode(utf8_decode(file_get_contents($file)), true);
+ $d = json_decode(pf_utf8_decode(file_get_contents($file)), true);
$d["contents"] = $request["contents"];
$d["update"] = date('c');
$d["update_user"] = $request["author"];
- file_put_contents($file, utf8_encode(json_encode($d)));
+ file_put_contents($file, pf_utf8_encode(json_encode($d)));
}
unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $id . ".json");
diff --git a/admin/create/save/index.php b/admin/create/save/index.php
index 57c7d93..2c71d56 100644
--- a/admin/create/save/index.php
+++ b/admin/create/save/index.php
@@ -21,7 +21,7 @@ if (isset($_GET["skel"])) {
$d["update"] = date('c');
$d["update_user"] = $_USER;
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $_GET["skel"] . "/" . $id . ".json", utf8_encode(json_encode(json_decode($_POST["contents"]), JSON_PRETTY_PRINT)));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $_GET["skel"] . "/" . $id . ".json", pf_utf8_encode(json_encode(json_decode($_POST["contents"]), JSON_PRETTY_PRINT)));
header("Location: /admin/edit/?id=$id");
die();
} else {
diff --git a/admin/edit/index.php b/admin/edit/index.php
index fbe1dd2..c62218b 100644
--- a/admin/edit/index.php
+++ b/admin/edit/index.php
@@ -35,7 +35,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/navigation.php";
<form action="/admin/edit/save/?id=<?= $_GET['id'] ?>" method="post">
<p>
- <textarea name="contents" style="width: 100%; max-height: 90vh; resize: none; outline: none; font-family: monospace;" rows="15"><?= $_POST["contents"] ?? json_encode(json_decode(utf8_decode(file_get_contents(getFileFromId($_GET['id'])))), JSON_PRETTY_PRINT) ?></textarea>
+ <textarea name="contents" style="width: 100%; max-height: 90vh; resize: none; outline: none; font-family: monospace;" rows="15"><?= $_POST["contents"] ?? json_encode(json_decode(pf_utf8_decode(file_get_contents(getFileFromId($_GET['id'])))), JSON_PRETTY_PRINT) ?></textarea>
</p>
<p>
diff --git a/admin/edit/save/index.php b/admin/edit/save/index.php
index 03c825e..a26dde0 100644
--- a/admin/edit/save/index.php
+++ b/admin/edit/save/index.php
@@ -17,7 +17,7 @@ if (isset($_GET["id"])) {
die();
} else {
if (isJson($_POST["contents"])) {
- file_put_contents(getFileFromId($_GET["id"]), utf8_encode(json_encode(json_decode($_POST["contents"]), JSON_PRETTY_PRINT)));
+ file_put_contents(getFileFromId($_GET["id"]), pf_utf8_encode(json_encode(json_decode($_POST["contents"]), JSON_PRETTY_PRINT)));
header("Location: /admin/edit/?id=$_GET[id]");
die();
} else {
diff --git a/admin/index.php b/admin/index.php
index 3a0a7bb..5961ac8 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -12,7 +12,7 @@ foreach (array_filter(scandir($_SERVER["DOCUMENT_ROOT"] . "/includes/data/articl
$keys[] = [
"type" => "articles",
"id" => $id,
- "name" => json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/articles/" . $_id)), true)["title"] ?? null
+ "name" => json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/articles/" . $_id)), true)["title"] ?? null
];
}
@@ -21,7 +21,7 @@ foreach (array_filter(scandir($_SERVER["DOCUMENT_ROOT"] . "/includes/data/galler
$keys[] = [
"type" => "gallery",
"id" => $id,
- "name" => json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/gallery/" . $_id)), true)["title"] ?? null
+ "name" => json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/gallery/" . $_id)), true)["title"] ?? null
];
}
@@ -30,7 +30,7 @@ foreach (array_filter(scandir($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people
$keys[] = [
"type" => "people",
"id" => $id,
- "name" => json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $_id)), true)["nick_name"] ?? (isset(json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $_id)), true)["first_name"]) && isset(json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $_id)), true)["last_name"]) ? json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $_id)), true)["first_name"] . " " . json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $_id)), true)["last_name"] : null)
+ "name" => json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $_id)), true)["nick_name"] ?? (isset(json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $_id)), true)["first_name"]) && isset(json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $_id)), true)["last_name"]) ? json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $_id)), true)["first_name"] . " " . json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $_id)), true)["last_name"] : null)
];
}
@@ -39,7 +39,7 @@ foreach (array_filter(scandir($_SERVER["DOCUMENT_ROOT"] . "/includes/data/profil
$keys[] = [
"type" => "profiles",
"id" => $id,
- "name" => json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/profiles/" . $_id)), true)["nick_name"] ?? (isset(json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/profiles/" . $_id)), true)["first_name"]) && isset(json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/profiles/" . $_id)), true)["last_name"]) ? json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/profiles/" . $_id)), true)["first_name"] . " " . json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/profiles/" . $_id)), true)["last_name"] : null)
+ "name" => json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/profiles/" . $_id)), true)["nick_name"] ?? (isset(json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/profiles/" . $_id)), true)["first_name"]) && isset(json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/profiles/" . $_id)), true)["last_name"]) ? json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/profiles/" . $_id)), true)["first_name"] . " " . json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/profiles/" . $_id)), true)["last_name"] : null)
];
}
@@ -67,36 +67,36 @@ usort($keys, function ($a, $b) {
$requestsNonPlus = array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests"), function ($i) { return !str_starts_with($i, "."); });
$requestsNonPlus = array_values(array_filter($requestsNonPlus, function ($i) {
- $request = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$i")), true);
- $adata = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true);
+ $request = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$i")), true);
+ $adata = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true);
return !$adata["plus"];
}));
usort($requestsNonPlus, function ($a, $b) {
- return strtotime(json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$a")), true)["date"]) - strtotime(json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$b")), true)["date"]);
+ return strtotime(json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$a")), true)["date"]) - strtotime(json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$b")), true)["date"]);
});
$requestsPlus = array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests"), function ($i) { return !str_starts_with($i, "."); });
$requestsPlus = array_values(array_filter($requestsPlus, function ($i) {
- $request = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$i")), true);
- $adata = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true);
+ $request = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$i")), true);
+ $adata = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true);
return $adata["plus"];
}));
usort($requestsPlus, function ($a, $b) {
- return strtotime(json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$a")), true)["date"]) - strtotime(json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$b")), true)["date"]);
+ return strtotime(json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$a")), true)["date"]) - strtotime(json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$b")), true)["date"]);
});
$requests = [...array_map(function ($i) {
$id = $i;
- $i = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$i")), true);
+ $i = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$i")), true);
$i["_id"] = explode(".", $id)[0];
$i["_plus"] = true;
return $i;
}, $requestsPlus), ...array_map(function ($i) {
$id = $i;
- $i = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$i")), true);
+ $i = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$i")), true);
$i["_id"] = explode(".", $id)[0];
$i["_plus"] = false;
return $i;
@@ -108,13 +108,13 @@ usort($keys, function ($a, $b) {
<div class="list-group">
<?php foreach ($requests as $request): ?>
<details class="list-group-item list-group-item-action <?= $request["_plus"] ? "list-group-item-warning" : "" ?>">
- <summary><?= json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/lang/en.json"), true)["request"]["types"][$request["type"]] ?> (<?php if (isset($request["id"]) && trim($request["id"]) !== "" && $request["id"] !== $request["author"]): ?>on <a href="/<?= str_starts_with("gallery", $request["type"]) ? "gallery" : ($request["type"] === "userpage" ? "people" : "article") ?>/<?= $request["id"] ?>" target="_blank"><?= getNameFromId($request["id"]) ?></a>; <?php endif; ?>from <a href="/profile/<?= $request["author"] ?>" target="_blank"><?php $adata = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true); ?> <?= isset($adata["nick_name"]) && trim($adata["nick_name"]) !== "" ? $adata["nick_name"] : $adata["first_name"] . " " . $adata["last_name"] ?></a>; <?= timeAgo($request["date"]) ?>)</summary>
+ <summary><?= json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/lang/en.json"), true)["request"]["types"][$request["type"]] ?> (<?php if (isset($request["id"]) && trim($request["id"]) !== "" && $request["id"] !== $request["author"]): ?>on <a href="/<?= str_starts_with("gallery", $request["type"]) ? "gallery" : ($request["type"] === "userpage" ? "people" : "article") ?>/<?= $request["id"] ?>" target="_blank"><?= getNameFromId($request["id"]) ?></a>; <?php endif; ?>from <a href="/profile/<?= $request["author"] ?>" target="_blank"><?php $adata = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true); ?> <?= isset($adata["nick_name"]) && trim($adata["nick_name"]) !== "" ? $adata["nick_name"] : $adata["first_name"] . " " . $adata["last_name"] ?></a>; <?= timeAgo($request["date"]) ?>)</summary>
<div class="list-group-item" style="margin-top: 10px;">
<p>
<b>ID:</b> <?= $request["_id"] ?><br>
<b>Publish date:</b> <?= date('r', strtotime($request["date"])) ?><br>
- <b>User:</b> <?php $adata = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true); ?> <?= isset($adata["nick_name"]) && trim($adata["nick_name"]) !== "" ? $adata["nick_name"] : $adata["first_name"] . " " . $adata["last_name"] ?> (<?= $request["author"] ?>)<br>
+ <b>User:</b> <?php $adata = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true); ?> <?= isset($adata["nick_name"]) && trim($adata["nick_name"]) !== "" ? $adata["nick_name"] : $adata["first_name"] . " " . $adata["last_name"] ?> (<?= $request["author"] ?>)<br>
<b>Target:</b> <?= isset($request["id"]) && trim($request["id"]) !== "" && $request["id"] !== $request["author"] ? getNameFromId($request["id"]) . " (" . $request["id"] . ")" : "<span class='text-muted'>Not applicable</span>" ?><br>
<b>Summary:</b> <?= isset($request["summary"]) && trim($request["summary"]) !== "" ? strip_tags($request["summary"]) : "<span class='text-muted'>Not applicable</span>" ?>
</p>
diff --git a/admin/reject/index.php b/admin/reject/index.php
index b4c0a8f..2a84b43 100644
--- a/admin/reject/index.php
+++ b/admin/reject/index.php
@@ -17,12 +17,12 @@ if (isset($id)) {
die();
}
-$request = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $id . ".json")), true);
+$request = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $id . ".json")), true);
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")) {
while (trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")) === "") {}
- $profile = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true);
+ $profile = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true);
loadLang(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/lang/" . $profile["language"] . ".json"), true), "lang");
$index = array_search($id, $profile["requests"]);
@@ -38,7 +38,7 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $reques
"read" => false
];
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json", utf8_encode(json_encode($profile, JSON_PRETTY_PRINT)));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json", pf_utf8_encode(json_encode($profile, JSON_PRETTY_PRINT)));
}
if ($request["type"] === "galleryupload" && file_exists($_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $id . ".jpg")) {
diff --git a/content/index.php b/content/index.php
index 337d499..00cfd39 100644
--- a/content/index.php
+++ b/content/index.php
@@ -18,7 +18,7 @@ global $_PROFILE;
$list = [];
foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles"), function ($i) { return !str_starts_with($i, "."); }) as $id) {
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/$id")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/$id")), true);
$id = substr($id, 0, -5);
$data["_type"] = "articles";
@@ -28,7 +28,7 @@ global $_PROFILE;
}
foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery"), function ($i) { return !str_starts_with($i, "."); }) as $id) {
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/$id")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/$id")), true);
$id = substr($id, 0, -5);
$data["_type"] = "gallery";
@@ -38,7 +38,7 @@ global $_PROFILE;
}
foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people"), function ($i) { return !str_starts_with($i, "."); }) as $id) {
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/$id")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/$id")), true);
$id = substr($id, 0, -5);
$data["_type"] = "people";
diff --git a/handoff/fcm/index.php b/handoff/fcm/index.php
index b32ee7c..59dc762 100644
--- a/handoff/fcm/index.php
+++ b/handoff/fcm/index.php
@@ -37,12 +37,12 @@ if (isset($_PROFILE) && isset($data["session"])) {
if (!in_array($data["session"], $_PROFILE["devices"])) {
foreach ($users as $user) {
$GLOBALS["dump"][] = $users;
- $userData = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $user)), true);
+ $userData = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $user)), true);
$userData["devices"] = array_values(array_filter($userData["devices"], function ($i) use ($data) {
return $i !== $data["session"];
}));
while (trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $user)) === "") {}
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $user, utf8_encode(json_encode($userData, JSON_PRETTY_PRINT)));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $user, pf_utf8_encode(json_encode($userData, JSON_PRETTY_PRINT)));
}
$_PROFILE["devices"][] = $data["session"];
diff --git a/includes/functions.php b/includes/functions.php
index 5cfed75..a109d49 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -2,6 +2,14 @@
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/lang.php";
+function pf_utf8_decode(string $string): string {
+ return iconv("UTF-8", "ISO-8859-1", $string);
+}
+
+function pf_utf8_encode(string $string): string {
+ return iconv("ISO-8859-1", "UTF-8", $string);
+}
+
function initLang(): void {
if (isset($_PROFILE) && isset($_PROFILE["language"])) {
genLang("en");
@@ -155,7 +163,7 @@ function timeAgo($time, $showTense = true, $strict = false, $daysOnly = false):
function resolveUser($id) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $id . ".json")) {
- $p = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $id . ".json")), true);
+ $p = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $id . ".json")), true);
if (isset($p["nick_name"]) && trim($p["nick_name"]) !== "") {
return $p["nick_name"];
@@ -264,13 +272,13 @@ function formatDate($date, $withYear = true) {
function getNameFromId($id) {
if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $id . ".json")) {
- return json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $id . ".json")), true)["first_name"] . " " . json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $id . ".json")), true)["last_name"];
+ return json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $id . ".json")), true)["first_name"] . " " . json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $id . ".json")), true)["last_name"];
} elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . "/includes/data/gallery/" . $id . ".json")) {
- return json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/gallery/" . $id . ".json")), true)["title"];
+ return json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/gallery/" . $id . ".json")), true)["title"];
} elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . "/includes/data/articles/" . $id . ".json")) {
- return json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/articles/" . $id . ".json")), true)["title"];
+ return json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/articles/" . $id . ".json")), true)["title"];
} elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . "/includes/data/profiles/" . $id . ".json")) {
- $d = json_decode(utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/profiles/" . $id . ".json")), true);
+ $d = json_decode(pf_utf8_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/profiles/" . $id . ".json")), true);
return $d["nick_name"] ?? $d["first_name"] . " " . $d["last_name"];
}
diff --git a/includes/jobs-handler.php b/includes/jobs-handler.php
index de4e571..98bd403 100644
--- a/includes/jobs-handler.php
+++ b/includes/jobs-handler.php
@@ -16,7 +16,7 @@ $price = (float)trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/plusprice")
$list = array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles"), function ($i) { return !str_starts_with($i, "."); });
foreach ($list as $file) {
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/$file")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/$file")), true);
genLang($data["language"]);
println($data["first_name"], " ", $data["last_name"]);
@@ -211,6 +211,6 @@ foreach ($list as $file) {
}
}
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/$file", utf8_encode(json_encode($data, JSON_PRETTY_PRINT)));
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/users.json", utf8_encode(json_encode($users, JSON_PRETTY_PRINT)));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/$file", pf_utf8_encode(json_encode($data, JSON_PRETTY_PRINT)));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/users.json", pf_utf8_encode(json_encode($users, JSON_PRETTY_PRINT)));
} \ No newline at end of file
diff --git a/includes/session.php b/includes/session.php
index 2a3f840..3167832 100644
--- a/includes/session.php
+++ b/includes/session.php
@@ -1,18 +1,20 @@
<?php
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php";
+
global $_USER;
global $_PROFILE;
if (isset($_COOKIE["DeltaSession"])) {
if (preg_match("/^[a-zA-Z0-9]*$/m", $_COOKIE['DeltaSession']) !== false) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $_COOKIE['DeltaSession'])) {
- $_SessionCheck_Data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $_COOKIE['DeltaSession'])), true);
+ $_SessionCheck_Data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $_COOKIE['DeltaSession'])), true);
if (time() - strtotime($_SessionCheck_Data["date"]) < 86400 * 90) {
$_USER = $_SessionCheck_Data["user"];
while (trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $_SessionCheck_Data["user"] . ".json")) === "") {}
- $_PROFILE = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $_SessionCheck_Data["user"] . ".json")), true);
+ $_PROFILE = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $_SessionCheck_Data["user"] . ".json")), true);
if (isset($api)) $data["loggedIn"] = true;
@@ -55,7 +57,7 @@ function saveProfile(): void {
while (trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $_USER . ".json")) === "") {}
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $_USER . ".json", utf8_encode(json_encode($_PROFILE, JSON_PRETTY_PRINT)));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $_USER . ".json", pf_utf8_encode(json_encode($_PROFILE, JSON_PRETTY_PRINT)));
}
$userLang = $_COOKIE["DeltaLanguage"] ?? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? "en", 0, 2);
@@ -73,10 +75,10 @@ if (!isset($api) && date('d-m-Y') !== date('d-m-Y', strtotime($_PROFILE["last_se
function addToUserHistory($id) {
global $_USER;
- if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json", utf8_encode("{}"));
+ if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json", pf_utf8_encode("{}"));
while (trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json")) === "") {}
- $history = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json")), true);
+ $history = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json")), true);
if (isset($history[$id])) {
$history[$id]++;
@@ -84,5 +86,5 @@ function addToUserHistory($id) {
$history[$id] = 1;
}
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json", utf8_encode(json_encode($history, JSON_PRETTY_PRINT)));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json", pf_utf8_encode(json_encode($history, JSON_PRETTY_PRINT)));
} \ No newline at end of file
diff --git a/index.php b/index.php
index a295460..fa4c018 100644
--- a/index.php
+++ b/index.php
@@ -34,7 +34,7 @@ function showPage($item) { ?>
<?php
$birthdays = array_values(array_filter(array_map(function ($i) {
- $r = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/$i")), true);
+ $r = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/$i")), true);
$r["_id"] = substr($i, 0, -5);
return $r;
}, array_values(array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles"), function ($i) { return str_ends_with($i, ".json"); }))), function ($i) {
@@ -71,7 +71,7 @@ function showPage($item) { ?>
<?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json")):
- $history = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json")), true);
+ $history = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json")), true);
if (count(array_keys($history)) > 0):
@@ -104,7 +104,7 @@ function showPage($item) { ?>
$list = [];
foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles"), function ($i) { return !str_starts_with($i, "."); }) as $id) {
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/$id")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/$id")), true);
$id = substr($id, 0, -5);
$data["_type"] = "articles";
@@ -114,7 +114,7 @@ function showPage($item) { ?>
}
foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery"), function ($i) { return !str_starts_with($i, "."); }) as $id) {
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/$id")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/$id")), true);
$id = substr($id, 0, -5);
$data["_type"] = "gallery";
@@ -124,7 +124,7 @@ function showPage($item) { ?>
}
foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people"), function ($i) { return !str_starts_with($i, "."); }) as $id) {
- $data = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/$id")), true);
+ $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/$id")), true);
$id = substr($id, 0, -5);
$data["_type"] = "people";
diff --git a/login/index.php b/login/index.php
index c9e1fe6..814e0c2 100644
--- a/login/index.php
+++ b/login/index.php
@@ -14,7 +14,7 @@ function encode($string) {
return preg_replace("/[^a-zA-Z0-9.]/m", "", base64_encode($string));
}
-$users = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/users.json")), true);
+$users = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/users.json")), true);
if (isset($_POST["p"]) && $_POST["p"] === "1") {
if (in_array($_POST["email"], array_keys($users))) {
@@ -26,7 +26,7 @@ if (isset($_POST["p"]) && $_POST["p"] === "1") {
$code = substr(hexdec(bin2hex(openssl_random_pseudo_bytes(6))), 0, 10);
if (!$error) {
- $list = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/codes.json")), true);
+ $list = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/codes.json")), true);
$list[$code] = [
"date" => date('c'),
"email" => $_POST["email"],
@@ -35,10 +35,10 @@ if (isset($_POST["p"]) && $_POST["p"] === "1") {
sendCode($_POST["email"], $code);
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/codes.json", utf8_encode(json_encode($list)));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/codes.json", pf_utf8_encode(json_encode($list)));
}
} elseif (isset($_POST["p"]) && $_POST["p"] === "2") {
- $list = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/codes.json")), true);
+ $list = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/codes.json")), true);
if (in_array($_POST['code'], array_keys($list)) && $list[$_POST['code']]["email"] === $_POST["email"]) {
if (time() - strtotime($list[$_POST['code']]["date"]) > 900) {
@@ -47,14 +47,14 @@ if (isset($_POST["p"]) && $_POST["p"] === "1") {
sendLogin($_POST["email"]);
$token = encode(openssl_random_pseudo_bytes(128));
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $token, utf8_encode(json_encode([
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $token, pf_utf8_encode(json_encode([
"user" => $users[$_POST["email"]],
"date" => date('c')
])));
$_USER = $users[$_POST["email"]];
setcookie("DeltaSession", $token, time() + (86400 * 90), "/", "", false, true);
unset($list[$_POST['code']]);
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/codes.json", utf8_encode(json_encode($list)));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/codes.json", pf_utf8_encode(json_encode($list)));
$step = 2;
}
} else {
@@ -131,7 +131,7 @@ $title = "lang_login_title"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes
<input type="submit" class="btn btn-primary" value="<?= l("lang_login_continue") ?>">
</form>
<?php endif; ?>
-<?php else: global $_USER; $user = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $_USER . ".json")), true); ?>
+<?php else: global $_USER; $user = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $_USER . ".json")), true); ?>
<img src="/icons/finish.svg" style="width: 48px; margin-bottom: 10px;">
<p><b><?= str_replace('%1', $user["nick_name"] ?? $user["first_name"] . " " . $user["last_name"], l("lang_login_back")) ?></b></p>
<p><?= l("lang_login_done") ?></p>
diff --git a/request/index.php b/request/index.php
index 56a3ceb..6d8a3b5 100644
--- a/request/index.php
+++ b/request/index.php
@@ -55,7 +55,7 @@ if (!isset($_PROFILE["requests"]["r:" . $_GET['id']])):
<p><b><?= l("lang_edit_alert_title") ?></b></p>
<?php
- $request = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $_PROFILE["requests"]["r:" . $_GET['id']] . ".json")), true);
+ $request = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $_PROFILE["requests"]["r:" . $_GET['id']] . ".json")), true);
?>
<p><?= str_replace("%1", timeAgo($request["date"]), l("lang_edit_alert_message")) ?></p>
diff --git a/request/save/index.php b/request/save/index.php
index e77a6bb..54f9bed 100644
--- a/request/save/index.php
+++ b/request/save/index.php
@@ -17,7 +17,7 @@ if (isset($_PROFILE["requests"]["r:" . $id]) || !isset($description)) {
}
$rid = uuid();
-file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $rid . ".json", utf8_encode(json_encode([
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $rid . ".json", pf_utf8_encode(json_encode([
"type" => $type,
"author" => $_USER,
"id" => $id,
diff --git a/requests/delete/index.php b/requests/delete/index.php
index 3c0bb70..ff2d33b 100644
--- a/requests/delete/index.php
+++ b/requests/delete/index.php
@@ -19,14 +19,14 @@ if (isset($id)) {
die();
}
-$request = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $id . ".json")), true);
+$request = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $id . ".json")), true);
if ($request["author"] !== $_USER) die();
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")) {
while (trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")) === "") {}
- $profile = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true);
+ $profile = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json")), true);
loadLang(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/lang/" . $profile["language"] . ".json"), true), "lang");
$index = array_search($id, $profile["requests"]);
@@ -35,7 +35,7 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $reques
unset($profile["requests"][$index]);
}
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json", utf8_encode(json_encode($profile, JSON_PRETTY_PRINT)));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $request["author"] . ".json", pf_utf8_encode(json_encode($profile, JSON_PRETTY_PRINT)));
}
if ($request["type"] === "galleryupload" && file_exists($_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $id . ".jpg")) {
diff --git a/requests/index.php b/requests/index.php
index 9d70f87..8e37183 100644
--- a/requests/index.php
+++ b/requests/index.php
@@ -9,12 +9,12 @@ global $_PROFILE; global $_USER;
$requests = array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests"), function ($i) { return !str_starts_with($i, "."); });
usort($requests, function ($a, $b) {
- return strtotime(json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$a")), true)["date"]) - strtotime(json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$b")), true)["date"]);
+ return strtotime(json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$a")), true)["date"]) - strtotime(json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$b")), true)["date"]);
});
$requests = [...array_map(function ($i) {
$id = $i;
- $i = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$i")), true);
+ $i = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/$i")), true);
$i["_id"] = explode(".", $id)[0];
return $i;
}, $requests)];
diff --git a/router.php b/router.php
new file mode 100644
index 0000000..9e95440
--- /dev/null
+++ b/router.php
@@ -0,0 +1,71 @@
+<?php
+
+if (str_contains($_SERVER['REQUEST_URI'], "..")) die();
+
+if (str_starts_with($_SERVER['REQUEST_URI'], "/people/") || $_SERVER['REQUEST_URI'] === "/people") {
+ $parts = explode("/", $_SERVER['REQUEST_URI']);
+ array_shift($parts); array_shift($parts);
+
+ $_GET["__"] = implode("/", $parts);
+ $_GET["/" . implode("/", $parts)] = null;
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/_people/index.php";
+} else if (str_starts_with($_SERVER['REQUEST_URI'], "/articles/") || $_SERVER['REQUEST_URI'] === "/articles") {
+ $parts = explode("/", $_SERVER['REQUEST_URI']);
+ array_shift($parts); array_shift($parts);
+
+ $_GET["__"] = implode("/", $parts);
+ $_GET["/" . implode("/", $parts)] = null;
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/_articles/index.php";
+} else if (str_starts_with($_SERVER['REQUEST_URI'], "/gallery/") || $_SERVER['REQUEST_URI'] === "/gallery") {
+ $parts = explode("/", $_SERVER['REQUEST_URI']);
+ array_shift($parts); array_shift($parts);
+
+ $_GET["__"] = implode("/", $parts);
+ $_GET["/" . implode("/", $parts)] = null;
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/_gallery/index.php";
+} else if (str_starts_with($_SERVER['REQUEST_URI'], "/edit/") || $_SERVER['REQUEST_URI'] === "/edit") {
+ $parts = explode("/", $_SERVER['REQUEST_URI']);
+ array_shift($parts); array_shift($parts);
+
+ $_GET["__"] = implode("/", $parts);
+ $_GET["/" . implode("/", $parts)] = null;
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/_edit/index.php";
+} else if (str_starts_with($_SERVER['REQUEST_URI'], "/profile/") || $_SERVER['REQUEST_URI'] === "/profile") {
+ $parts = explode("/", $_SERVER['REQUEST_URI']);
+ array_shift($parts); array_shift($parts);
+
+ $_GET["__"] = implode("/", $parts);
+ $_GET["/" . implode("/", $parts)] = null;
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/_profile/index.php";
+} else {
+ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . $_SERVER['REQUEST_URI'])) {
+ if (!is_dir($_SERVER['DOCUMENT_ROOT'] . "/" . $_SERVER['REQUEST_URI'])) {
+ if (str_ends_with($_SERVER['DOCUMENT_ROOT'] . "/" . $_SERVER['REQUEST_URI'], ".css")) {
+ header("Content-Type: text/css");
+ } else if (str_ends_with($_SERVER['DOCUMENT_ROOT'] . "/" . $_SERVER['REQUEST_URI'], ".js")) {
+ header("Content-Type: application/javascript");
+ } else {
+ header("Content-Type: " . mime_content_type($_SERVER['DOCUMENT_ROOT'] . "/" . $_SERVER['REQUEST_URI']));
+ }
+
+ header("Content-Length: " . filesize($_SERVER['DOCUMENT_ROOT'] . "/" . $_SERVER['REQUEST_URI']));
+ readfile($_SERVER['DOCUMENT_ROOT'] . "/" . $_SERVER['REQUEST_URI']);
+ } else {
+ require_once $_SERVER['SCRIPT_FILENAME'];
+ }
+ } else if (str_starts_with($_SERVER['REQUEST_URI'], "/icons/")) {
+ $parts = explode("/", $_SERVER['REQUEST_URI']);
+ array_shift($parts); array_shift($parts);
+ $name = implode("/", $parts);
+
+ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/_icons/" . $name)) {
+ header("Content-Type: " . mime_content_type($_SERVER['DOCUMENT_ROOT'] . "/_icons/" . $name));
+ header("Content-Length: " . filesize($_SERVER['DOCUMENT_ROOT'] . "/_icons/" . $name));
+ readfile($_SERVER['DOCUMENT_ROOT'] . "/_icons/" . $name);
+ } else {
+ die("Not found");
+ }
+ } else {
+ require_once $_SERVER['SCRIPT_FILENAME'];
+ }
+} \ No newline at end of file
diff --git a/support/index.php b/support/index.php
index c6dd324..e6184a5 100644
--- a/support/index.php
+++ b/support/index.php
@@ -40,13 +40,13 @@ $emailSupport = file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/email") && tr
$code = substr(hexdec(bin2hex(random_bytes(6))), 0, 9);
$codePretty = implode(" ", str_split($code, 3));
- $codes = json_decode(utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/supportcodes.json")), true);
+ $codes = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/supportcodes.json")), true);
$codes[$code] = [
"user" => $_USER,
"type" => [$p1, $p2],
"date" => date('c')
];
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/supportcodes.json", utf8_encode(json_encode($codes, JSON_PRETTY_PRINT)));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/supportcodes.json", pf_utf8_encode(json_encode($codes, JSON_PRETTY_PRINT)));
?>
<h1><?= l("lang_support_types_" . $p1 . "_" . $p2) ?></h1>