summaryrefslogtreecommitdiff
path: root/_profile/index.php
blob: 4a3cae62ca4036910eefb2194eeb89d607529d43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $_USER; global $_PROFILE;

$id = array_values(array_filter(array_keys($_GET), function ($i) {
    return str_starts_with($i, "/") && strlen($i) > 1;
}))[0] ?? null;

$gender = "other";

if (isset($id)) {
    $id = substr($id, 1);
    if (!preg_match("/[a-zA-Z0-6]/m", $id)) {
        header("Location: /profile/$_USER");
        die();
    }

    if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/" . $id . ".json")) {
        header("Location: /profile/$_USER");
        die();
    }

    $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";
} else {
    header("Location: /profile/$_USER");
    die();
}

require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/navigation.php";

$requests = array_reverse($data["requests"]);

foreach (array_filter(scandir($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people"), function ($i) { return !str_starts_with($i, "."); }) as $_id) {
    $_d = json_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $_id), true);

    if ($_d["delta"] === $id) {
        $gender = $_d["gender"];
    }
}

?>

<div class="container">
    <br><br>
    <h1>
        <span><?= $data["nick_name"] ?? $data["first_name"] . " " . $data["last_name"] ?><?php if (isset($data["nick_name"]) && trim($data["nick_name"]) !== ""): ?> <small><small><small>(<?= $data["first_name"] . " " . $data["last_name"] ?>)</small></small></small><?php endif; ?></span>
        <div id="btn-area" style="float: right;">
            <div id="badges-desktop" style="display: inline-block; margin-right: 10px;">
                <?php badges($data) ?>
            </div>
            <div class="btn-group">
                <a style="height: 38px;" href="/edit/<?= $id ?>" class="btn btn-outline-dark btn-with-img <?= $id !== $_USER ? "disabled" : "" ?>" title="<?= l("lang_people_edit") ?>" data-bs-toggle="tooltip"><img src="/icons/edit.svg" style="width: 24px;"></a><a style="height: 38px;" onclick="copy('<?= uuidToId($id) ?>', true)" class="btn btn-outline-dark btn-with-img" title="<?= l("lang_shortener_copy") ?>" data-bs-toggle="tooltip"><img src="/icons/copy.svg" style="width: 24px;"></a>
                <button style="height: 38px;" type="button" class="btn btn-outline-dark dropdown-toggle btn-with-img" title="<?= l("lang_profile_options") ?>" data-bs-toggle2="tooltip" data-bs-toggle="dropdown"><img src="/icons/admin.svg" style="width: 24px;"></button>
                <ul class="dropdown-menu">
                    <li><a class="dropdown-item <?= $id === $_USER ? "disabled" : "" ?>" href="/request/?type=userreport&id=<?= $id ?>">
                        <img src="/icons/report.svg" style="vertical-align: middle; width: 24px;<?= $id === $_USER ? "opacity:.5;" : "" ?>">
                        <span style="vertical-align: middle;"><?= $gender === "fem" || $gender === "trans_fem" ? l("lang_profile_report_female") : ($gender === "male" || $gender === "trans_male" ? l("lang_profile_report_male") : l("lang_profile_report")) ?></span>
                    </a></li>
                    <li><a class="dropdown-item <?= $id !== $_USER || !isset($_PROFILE["ultra"]) || !$_PROFILE["ultra"] ? "disabled" : "" ?>" href="/nickname">
                        <img src="/icons/rename.svg" style="vertical-align: middle; width: 24px;">
                        <span style="vertical-align: middle;"><?= l("lang_nickname_action") ?></span>
                    </a></li>
                    <li><a class="dropdown-item <?= $id !== $_USER ? "disabled" : "" ?>" href="/download">
                        <img src="/icons/download.svg" style="vertical-align: middle; width: 24px;">
                        <span style="vertical-align: middle;"><?= l("lang_download_action") ?></span>
                    </a></li>
                    <li><a class="dropdown-item" href="/request/?type=<?= $id === $_USER ? "profile" : "profileother" ?>&id=<?= $id ?>">
                        <img src="/icons/edit.svg" style="vertical-align: middle; width: 24px;">
                        <span style="vertical-align: middle;"><?= l("lang_profile_request") ?></span>
                    </a></li>
                </ul>
            </div>
        </div>
        <div id="badges-mobile" style="display: none;">
            <?php badges($data) ?>
        </div>
    </h1>

    <div id="profile-grid" style="margin-top: 20px; display: grid; grid-template-columns: repeat(<?= hasProfileSetting("hide", false) ? "1" : "2" ?>, 1fr); grid-column-gap: 20px;">
        <?php if (!hasProfileSetting("hide", false)): ?>
        <div class="card">
            <div class="card-body">
                <table>
                    <tr>
                        <td class="ellipsis"><img alt="" src="/icons/time.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
                        <td class="ellipsis"><?= $gender === "fem" || $gender === "trans_fem" ? l("lang_profile_since_female") : ($gender === "male" || $gender === "trans_male" ? l("lang_profile_since_male") : l("lang_profile_since")) ?> <?= timeAgo($data["date"], false) ?></td>
                    </tr>
                    <tr>
                        <td class="ellipsis"><img alt="" src="/icons/clock.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
                        <td class="ellipsis"><?php if (isset($data["last_seen"])): ?><?= $gender === "fem" || $gender === "trans_fem" ? l("lang_profile_last_female") : ($gender === "male" || $gender === "trans_male" ? l("lang_profile_last_male") : l("lang_profile_last")) ?> <?= timeAgo($data["last_seen"], true, false, true) ?><?php else: ?><?= l("lang_profile_never") ?><?php endif; ?></td>
                    </tr>
                    <tr>
                        <td class="ellipsis"><img alt="" src="/icons/pending.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
                        <td class="ellipsis"><?= count($data["requests"]) === 0 ? l("lang_profile_pending3") : count($data["requests"]) ?> <?= l(count($data["requests"]) > 1 || count($data["requests"]) === 0 ? "lang_profile_pending2" : "lang_profile_pending1") ?></td>
                    </tr>
                </table>
            </div>
        </div>
        <?php endif; ?>
        <div class="card">
            <div class="card-body">
                <div id="profile-grid-user" style="display: grid; grid-template-columns: <?= hasProfileSetting("photo", true) ? "64px max-content" : "1fr" ?>; grid-gap: 10px;">
                    <?php if (hasProfileSetting("photo", true)): ?>
                    <div style="display: flex; align-items: center;">
                        <img src="<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $id . ".webp") ? "/uploads/" . $id . ".webp" : "/icons/defaultuser.svg" ?>" style="width: 64px; height: 64px; border-radius: 100%;">
                    </div>
                    <?php endif; ?>
                    <table>
                        <tr>
                            <td class="ellipsis" style="width: 28px;"><img alt="" src="/icons/age.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
                            <td class="ellipsis"><?php

                            if (isset($data["birth"])):

                            $bdate = strtotime($data["birth"]);
                            echo(timeAgo($bdate, false, true) . " " . l("lang_profile_old"));

                            ?><?php if (hasProfileSetting("birth", true)): ?> (<?= $gender === "fem" || $gender === "trans_fem" ? l("lang_profile_birth_female") : ($gender === "male" || $gender === "trans_male" ? l("lang_profile_birth_male") : l("lang_profile_birth")) ?> <?= formatDate($data["birth"], false) ?>)<?php endif; ?><?php else: ?>-<?php endif; ?></td>
                        </tr>
                        <tr>
                            <?php

                            $email = $data["email"];

                            ?>
                            <td class="ellipsis" style="width: 28px;"><img alt="" src="/icons/email.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
                            <td class="ellipsis"><?php if (hasProfileSetting("email", true)): ?><a href="mailto:<?= $email ?>"><?= $email ?></a><?php else: ?><?= l("lang_studio_redacted") ?><?php endif; ?></td>
                        </tr>
                        <tr>
                            <td class="ellipsis" style="width: 28px;"><img alt="" src="/icons/phone.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
                            <td class="ellipsis"><?php if (hasProfileSetting("phone", true)): ?><?php if (isset($data["phone"]) && $data["phone"] !== ""): ?><a href="tel:<?= str_replace(" ", "", $data["phone"]) ?>"><?= $data["phone"] ?></a><?php else: ?>-<?php endif; ?><?php else: ?><?= l("lang_studio_redacted") ?><?php endif; ?></td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <?php if (hasProfileSetting("detailed", false, $data)): ?>
    <div id="profile-grid-2" style="margin-top: 20px; display: grid; grid-template-columns: repeat(2, 1fr); grid-column-gap: 20px;">
        <div class="card">
            <div class="card-body">
                <div style="height: 28px; display: flex; align-items: center;"><b><?= l("lang_studio_details_most") ?></b></div>
                <?php

                if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $id . ".json")) {
                    $history = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json"), true);
                } else {
                    $history = [];
                }

                uasort($history, function ($a, $b) { return $b - $a; });
                array_filter($history, function ($i) { return getFileFromId($i) !== null; }, ARRAY_FILTER_USE_KEY);

                ?>

                <table>
                    <?php if (isset(array_keys($history)[0])): ?>
                    <tr>
                        <td class="ellipsis" style="width: 28px;"><img alt="" src="/icons/<?= getTypeFromId(array_keys($history)[0]) ?>.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
                        <td class="ellipsis"><a href="<?= getUrlFromId(array_keys($history)[0]) ?>"><?= getNameFromId(array_keys($history)[0]) ?></a></td>
                    </tr>
                    <?php endif; ?>
                    <?php if (isset(array_keys($history)[1])): ?>
                    <tr>
                        <td class="ellipsis" style="width: 28px;"><img alt="" src="/icons/<?= getTypeFromId(array_keys($history)[1]) ?>.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
                        <td class="ellipsis"><a href="<?= getUrlFromId(array_keys($history)[1]) ?>"><?= getNameFromId(array_keys($history)[1]) ?></a></td>
                    </tr>
                    <?php endif; ?>
                </table>
            </div>
        </div>

        <div class="card">
            <div class="card-body">
                <div style="height: 28px; display: flex; align-items: center;"><b><?= l("lang_studio_details_requests") ?></b></div>
                <?php if (count($requests) === 0): ?>
                <div style="height: 28px; display: flex; align-items: center;" class="text-muted"><?= l("lang_studio_details_none") ?></div>
                <?php else: ?>
                    <table>
                        <?php if (isset(array_keys($requests)[0])): ?>
                            <tr>
                                <td class="ellipsis" style="width: 28px;"><img alt="" src="/icons/<?= getTypeFromId(array_keys($requests)[0]) ?>.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
                                <td class="ellipsis"><a href="<?= getUrlFromId(array_keys($requests)[0]) ?>"><?= getNameFromId(array_keys($requests)[0]) ?></a> · <?= timeAgo(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . array_values($requests)[0] . ".json"), true)["date"]) ?></td>
                            </tr>
                        <?php endif; ?>
                        <?php if (isset(array_keys($requests)[1])): ?>
                            <tr>
                                <td class="ellipsis" style="width: 28px;"><img alt="" src="/icons/<?= getTypeFromId(array_keys($requests)[1]) ?>.svg" style="vertical-align: middle; width: 29px; padding-right: 5px;"></td>
                                <td class="ellipsis"><a href="<?= getUrlFromId(array_keys($requests)[1]) ?>"><?= getNameFromId(array_keys($requests)[1]) ?></a> · <?= timeAgo(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . array_values($requests)[1] . ".json"), true)["date"]) ?></td>
                            </tr>
                        <?php endif; ?>
                    </table>
                <?php endif; ?>
            </div>
        </div>
    </div>
    <?php endif ;?>

    <div style="margin-top: 20px;">
        <?php if (isset($data["contents"]) && trim($data["contents"] !== "")): ?>
            <div>
                <?= str_replace("<script>", "&lt;script&gt;", $data["contents"]) ?>
            </div>
            <?php if (!hasProfileSetting("hide", false)): ?>
            <small class="text-muted"><?= str_replace("%1", timeAgo($data["update"]), l("lang_time_update")) ?></small>
            <?php endif; ?>
        <?php else: ?>
            <p class="text-muted"><?= $gender === "fem" || $gender === "trans_fem" ? l("lang_profile_empty_female") : ($gender === "male" || $gender === "trans_male" ? l("lang_profile_empty_male") : l("lang_profile_empty")) ?></p>
        <?php endif; ?>
    </div>

    <br><br>
</div>

<?php if ($id !== $_USER) addToUserHistory($id); require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"; ?>