aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/cms-special/admin/index.php
blob: 8e388b6977f4ca165c35e0229d37c34c0454cdb9 (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
<?php require_once "../../resources/private/relative.php"; getRelativeDetails("cms-special"); ?>
<?php

if (isset($_GET['pr']) || isset($_GET['pa'])) {
    if (isset($_GET['pr']) && !isset($_GET['pa'])) {
        header("Location: {$GLOBALS["SYSTEM_ROOT"]}/cms-special/admin/login/?pr=" . $_GET['pr']);
        require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit();
    }
    if (!isset($_GET['pr']) && isset($_GET['pa'])) {
        header("Location: {$GLOBALS["SYSTEM_ROOT"]}/cms-special/admin/login/?pa=" . $_GET['pa']);
        require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit();
    }
    if (isset($_GET['pr']) && isset($_GET['pa'])) {
        header("Location: {$GLOBALS["SYSTEM_ROOT"]}/cms-special/admin/login/?pr=" . $_GET['pr'] . "&pa=" . $_GET['pa']);
        require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit();
    }
}

/** @var boolean $__electrode */
if (isset($__electrode) && $__electrode) {
    header("Location: {$GLOBALS["SYSTEM_ROOT"]}/cms-special/admin/home");
    require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit();
}

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Neutron</title>
    <link rel="stylesheet" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/css/ajax.css">
    <link rel="icon" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/image/siteicon.png">
    <script src="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/js/jquery.js"></script>
</head>
<body>
    <iframe id="content" src="<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/login" style="border:none;"></iframe>
    <div id="loader">
        <svg class="spinner" width="48px" height="48px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
            <circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
        </svg>
    </div>
</body>

<script>
    function iframeURLChange(iframe, callback) {
        var unloadHandler = function () {
            setTimeout(function () {
                callback(iframe.contentWindow.location.href);
            }, 0);
        };

        function attachUnload() {
            iframe.contentWindow.removeEventListener("unload", unloadHandler);
            iframe.contentWindow.addEventListener("unload", unloadHandler);
        }

        iframe.addEventListener("load", attachUnload);
        attachUnload();
    }

    iframeURLChange(document.getElementById("content"), function (newURL) {
        $("#loader").fadeIn(200);
    });

    document.getElementById('content').onbeforeunload = () => {
        $("#loader").fadeIn(200);
    }

    document.getElementById('content').onload = () => {
        $("#loader").fadeOut(200);

        setTimeout(() => {
            $("#loader").fadeOut(200);
        }, 300)

        els2 = document.getElementById('content').contentWindow.location.href.split("/");

        els2.shift();
        els2.shift();
        els2.shift();

        url = "/" + els2.join("/");
        if (!url.startsWith("<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin")) {
            document.getElementById('content').contentWindow.history.back();
            window.open(url);
        }

        els = document.getElementById('content').contentWindow.location.href.split("/");

        els.shift();
        els.shift();
        els.shift();
        els.shift();
        els.shift();
        <?php if ($GLOBALS["SYSTEM_PREFIXED"]): ?>
        els.shift();
        <?php endif; ?>
                                                
        oldu = "/" + els.join("/");

        window.history.replaceState("Neutron", "Neutron", "#/" + els.join("/"));
        console.log("<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/" + els.join("/"));

        document.title = document.getElementById('content').contentWindow.document.title;
    }

    oldu = null;
    setInterval(() => {
        hash = location.hash.substr(1);

        if (hash == "" && hash != oldu) {
            document.getElementById('content').src = "<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/home";
            console.log("<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/home");
            $("#loader").fadeIn(200);

            oldu = hash;
        } else if (hash != oldu) {
            if (hash.startsWith("/") && (hash.substr(1, 1) != "/")) {
                document.getElementById('content').src = "<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin" + hash;
                console.log("<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin" + hash);
                $("#loader").fadeIn(200);
            } else {
                document.getElementById('content').src = "<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/home";
                console.log("<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/home");
                $("#loader").fadeIn(200);
            }

            oldu = hash;
        }
    }, 200)
</script>

</html>