summaryrefslogtreecommitdiff
path: root/includes/components/explicit.php
blob: 9b3b159826680eecece9331ddb5549c09dd86ad4 (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
<?php global $isLoggedIn; global $isLowerLoggedIn; global $_PROFILE; global $app; if ($isLoggedIn || $isLowerLoggedIn): ?>
<div class="modal" id="explicit-modal" data-bs-backdrop="static" data-bs-keyboard="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body" style="text-align: center;">
                <img alt="" style="width: 64px; height: 64px;" src="/assets/icons/explicit.svg">
                <h3>This content is sexually explicit</h3>

                <p>This page shows uncensored graphically explicit sexual content that you may not want to see in some cases. Please refrain from visiting this part of the website in a public place.</p>
                <p>By continuing, you agree to be presented with sexually explicit content that is not appropriate for everyone.</p>

                <span onclick="explicitConfirm();" id="explicit-modal-confirm" class="btn btn-primary">Continue</span>
                <span onclick="explicitCancel();" id="explicit-modal-cancel" class="btn btn-outline-secondary">Go back</span>

                <label style="margin-top:10px; display: block; text-align: left; opacity: .5;">
                    <input checked type="checkbox" class="form-check-input" id="explicit-modal-hour">
                    Don't show for the next hour
                </label>
            </div>
        </div>
    </div>
</div>

<style>
    #explicit-modal .modal-header {
        border-bottom: 1px solid #353738;
    }

    #explicit-modal .modal-content {
        border: 1px solid rgba(255, 255, 255, .2);
        background-color: #111;
    }
</style>

<!--suppress JSVoidFunctionReturnValueUsed -->
<script>
    window.explicitModal = new bootstrap.Modal(document.getElementById("explicit-modal"));
    window.ip = "<?= $_SERVER['REMOTE_ADDR'] ?>";
    window.front = "<?php

    $front = [];
    $id = null;

    if ($_PROFILE["login"] === "raindrops") {
        $id = "gdapd";
    } else if ($_PROFILE["login"] === "cloudburst") {
        $id = "ynmuc";
    } else {
        $id = $app["other"]["id"];
    }

    $fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$id/fronters.json"), true)["members"];
    $front = array_map(function ($i) {
        return $i["id"];
    }, $fronters);

    echo(implode(",", $front));

    ?>";
    window.age = <?php

    if (isset($front[0]) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $front[0] . ".json")) {
        $metadata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $front[0] . ".json"), true);
        $age = null;

        if (isset($metadata["birth"]["age"]) && $metadata["birth"]["age"] !== 0) {
            $age = $metadata["birth"]["age"];
        } else if (isset($metadata["birth"]["year"]) && $metadata["birth"]["year"] > 1990) {
            $age = (int)date('Y') - $metadata["birth"]["year"] + (strtotime(date('Y') . "-" . $metadata["birth"]["date"]) <= time() ? 0 : -1);
        }

        if (is_string($age) && isset(explode("-", $age)[1]) && is_numeric(explode("-", $age)[1])) {
            $age = (int)explode("-", $age)[1];
        }

        echo($age);
    }

    ?>;
    window.explicitCancelAction = "back";

    function requestExplicit(ifNotAgreed, allowUnderage) {
        window.explicitCancelAction = ifNotAgreed;

        if (!allowUnderage && (window.age < 15 || !window.age)) {
            document.getElementById("explicit-modal-confirm").classList.add("disabled");
            document.getElementById("explicit-modal-hour").disabled = true;

            window.explicitModal.show();
            document.getElementById("explicit-modal").classList.add("fade");
        }

        if (!localStorage.getItem("explicit-consent")) {
            window.explicitModal.show();
            document.getElementById("explicit-modal").classList.add("fade");
        } else {
            let parts = localStorage.getItem("explicit-consent").split("|");

            if (parts[0] !== window.front || parts[1] !== window.ip || new Date().getTime() - parseInt(parts[2]) > 3600000) {
                window.explicitModal.show();
                document.getElementById("explicit-modal").classList.add("fade");
            }
        }
    }

    function explicitConfirm() {
        window.explicitModal.hide();

        if (document.getElementById("explicit-modal-hour").checked) {
            localStorage.setItem("explicit-consent", window.front + "|" + window.ip + "|" + new Date().getTime());
        }
    }

    function explicitCancel() {
        if (window.explicitCancelAction === "refresh") {
            location.reload();
        } else {
            if (history.length > 1) {
                if (history.back() === undefined) {
                    location.href = "https://ponies.equestria.horse";
                }
            } else {
                location.href = "https://ponies.equestria.horse";
            }
        }
    }
</script>
<?php endif; ?>