aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/cms-special/admin-v2/$resources/precontent.php
blob: af8d99939ee4b3c6c52a059b68f98eb4640b844d (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
221
222
223
<?php

require $_SERVER['DOCUMENT_ROOT'] . "/api/lang/processor.php";

$pageid = explode("/", $_SERVER['REQUEST_URI'])[3];
if (isset(explode("/", $_SERVER['REQUEST_URI'])[4])) {
    if (explode("/", $_SERVER['REQUEST_URI'])[4] != "index.php" && substr(explode("/", $_SERVER['REQUEST_URI'])[4], 0, 1) != "?" && substr(explode("/", $_SERVER['REQUEST_URI'])[4], 0, 1) != "#") {
        if (isset($lang["admin-titles"][$pageid]['subpages'])) {
            $subpageid = explode("/", $_SERVER['REQUEST_URI'])[4];
            $subpageel = (array)$lang["admin-titles"][$pageid]['subpages'];
        } else {
            $subpageid = "";
        }
    } else {
        $subpageid = "";
    }
} else {
    $subpageid = "";
}

if (isset($lang["admin-titles"][$pageid])) {
    if (isset($lang["admin-titles"][$pageid]['dom']) && isset($lang["admin-titles"][$pageid]['header'])) {
        if (isset($lang["admin-titles"][$pageid]['subpages'])) {
            if ($subpageid != "") {
                $subpages = $lang["admin-titles"][$pageid]['subpages'];
                if (isset($subpageel)) {
                    if (isset($subpageel[$subpageid])) {
                        $pageConfig = [ "domName" => $subpageel[$subpageid]['dom'] . " — " . $lang["admin-titles"][$pageid]['dom'], "headerName" => $subpageel[$subpageid]['header'] ];
                    } else {
                        $pageConfig = [ "domName" => $lang["admin-titles"]["fallback-subpages"] . " — " . $lang["admin-titles"][$pageid]['dom'], "headerName" => $lang["admin-titles"]["fallback-subpages"] ];
                    }
                } else {
                    $pageConfig = [ "domName" => $lang["admin-titles"][$pageid]['dom'], "headerName" => $lang["admin-titles"][$pageid]['header'] ];
                }
            } else {
                $pageConfig = [ "domName" => $lang["admin-titles"][$pageid]['dom'], "headerName" => $lang["admin-titles"][$pageid]['header'] ];
            }
        } else {
            $pageConfig = [ "domName" => $lang["admin-titles"][$pageid]['dom'], "headerName" => $lang["admin-titles"][$pageid]['header'] ];
        }
    } else {
        $pageConfig = [ "domName" => $lang["admin-titles"]["fallback"]['dom'], "headerName" => $lang["admin-titles"]["fallback"]['header'] ];
    }
} else {
    $pageConfig = [ "domName" => $lang["admin-titles"]["fallback"], "headerName" => $lang["admin-titles"]["fallback"] ];
}

$invalid = false;

if (isset($_COOKIE['_NEUTRON_ADMIN_TOKEN']) && $_COOKIE['_NEUTRON_ADMIN_TOKEN'] != "." && $_COOKIE['_NEUTRON_ADMIN_TOKEN'] != ".." && $_COOKIE['_NEUTRON_ADMIN_TOKEN'] != "/") {
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/tokens/" . $_COOKIE['_NEUTRON_ADMIN_TOKEN'])) {

    } else {
        require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("<script>location.href = '" . $GLOBALS["SYSTEM_ROOT"] . "/cms-special/admin/?pr=" . str_replace("/index.php", "", $_SERVER['SCRIPT_NAME']) . "&pa=" . urlencode("?" . explode("?", $_SERVER['REQUEST_URI'])[1]) . "'</script>");
    }
} else {
    require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("<script>location.href = '" . $GLOBALS["SYSTEM_ROOT"] . "/cms-special/admin/?pr=" . str_replace("/index.php", "", $_SERVER['SCRIPT_NAME']) . "&pa=" . urlencode("?" . explode("?", $_SERVER['REQUEST_URI'])[1]) . "'</script>");
}

if (isset($_POST['password'])) {
    if (password_verify($_POST['password'], file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/password"))) {
        require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("<script>location.href = '" . $GLOBALS["SYSTEM_ROOT"] . "/cms-special/admin/home';</script>");
        return;
    } else {
        $invalid = true;
    }
}

?>

<?php ob_start();echo("<!--\n\n" . str_replace('%year%', date('Y'), file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/resources/private/license")) . "\n\n-->") ?>
<?php

if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent")) {
    $ready = true;
} else {
    $ready = false;
}

function startsWith ($string, $startString) {
    $len = strlen($startString);
    return (substr($string, 0, $len) === $startString);
}

function getData(string $dir, $ignoreUploadDir = false) {
    global $size;
    $dircontent = scandir($dir);
    foreach ($dircontent as $direl) {
        if (($ignoreUploadDir && ($direl == "/upload" || $dir . "/" . $direl == $_SERVER['DOCUMENT_ROOT'] . "/resources/upload")) || $direl == ".git") {} else {
            if ($direl == "." || $direl == "..") {} else {
                if (is_link($dir . "/" . $direl)) {} else {
                    if (is_dir($dir . "/" . $direl)) {
                        getData($dir . "/" . $direl);
                    } else {
			try {
			    $size = $size + filesize($dir . "/" . $direl);
			} catch (Error $err) {}
                    }
                }
            }
        }
    }
}

function isJson(string $json) {
    json_decode($json);
    return (json_last_error() == JSON_ERROR_NONE);
}

require_once $_SERVER['DOCUMENT_ROOT'] . "/resources/private/headers/preprocessor.php";

?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/css/fonts-import.css">
    <link rel="stylesheet" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/css/alerts.css">
    <link href="<?= $_MD_INCLUDES ?>/material-components-web.min.css" rel="stylesheet">
    <script src="<?= $_MD_INCLUDES ?>/material-components-web.min.js"></script>
    <link rel="stylesheet" href="<?= $_MDI_PATH ?>">
    <link rel="stylesheet" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/css/spotlight.css">
    <link rel="stylesheet" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/css/admin.css">
    <link rel="stylesheet" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/css/ui.css">
    <link rel="stylesheet" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/css/codename.css">
    <link rel="icon" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/image/siteicon.png">
    <script src="<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/$resources/admin.js"></script>
    <link rel="preload" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/css/fonts-import.css" as="style">
    <link rel="preload" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/css/alerts.css" as="style">
    <link rel="preload" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/css/admin.css" as="style">
    <link rel="preload" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/css/ui.css" as="style">
    <link rel="preload" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/$resources/common.css" as="style">
    <link rel="preload" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/$resources/index.css" as="style">
    <link rel="preload" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/$resources/responsive.css" as="style">
    <link rel="preload" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/$resources/index-dark.css" as="style">
    <link rel="preload" href="<?= $_MD_INCLUDES ?>/material-components-web.min.css" as="style">
    <link rel="preload" href="<?= $_MDI_PATH ?>" as="style">
    <link rel="preload" href="<?= $_MD_INCLUDES ?>/material-components-web.min.js" as="script">
    <link rel="preload" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/$resources/admin.js" as="script">
    <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/resources/private/headers/documenthead.php"; ?>

    <?php

    if (!isset($loadEditor)) {
        $loadEditor = true;
    }

    if ($loadEditor) {
        echo('<script src="' . $GLOBALS["SYSTEM_ROOT"] . '/resources/js/ckeditor5/ckeditor.js"></script><script src="' . $GLOBALS["SYSTEM_ROOT"] . '/resources/js/ckeditor5/translations/fr.js"></script><script src="' . $GLOBALS["SYSTEM_ROOT"] . '/resources/js/ckeditor5/translations/en.js"></script>');
    }

    ?>
    <?php
        if (file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/theme") == "dark") {
            echo('<link rel="stylesheet" href="' . $GLOBALS["SYSTEM_ROOT"] . '/cms-special/admin/$resources/index-dark.css">');
        } elseif (file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/theme") == "auto") {
            echo('<link rel="stylesheet" href="' . $GLOBALS["SYSTEM_ROOT"] . '/cms-special/admin/$resources/index-auto.css">');
        } else {
            echo('<link rel="stylesheet" href="' . $GLOBALS["SYSTEM_ROOT"] . '/cms-special/admin/$resources/index.css">');
        }
    ?>
    <link rel="stylesheet" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/lib/pushbar.js/library.css">
    <script src="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/lib/pushbar.js/library.js"></script>
    <title><?php

    if ($ready) {
        echo("{$lang["admin-titles"]["suffix"]} — " . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/sitename"));
    } else {
        echo("{$lang["admin-titles"]["suffix"]} — Neutron");
    }

    ?></title>
    <?php
        if (!$ready) {
            require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("<script>location.href = '" . $GLOBALS["SYSTEM_ROOT"] . "/cms-special/setup';</script></head>");
        }
    ?>
    <?php

    getData($_SERVER['DOCUMENT_ROOT']);
    $sizestr = $size . " " . $lang["sizes"]["bytes"];
    if ($size > 1024) {
        if ($size > 1048576) {
            if ($size > 1073741824) {
                $sizestr = round($size / 1073741824, 2) . " " . $lang["sizes"]["gib"];
            } else {
                $sizestr = round($size / 1048576, 2) . " " . $lang["sizes"]["mib"];
            }
        } else {
            $sizestr = round($size / 1024, 2) . " " . $lang["sizes"]["kib"];
        }
    } else {
        $sizestr = $size . " " . $lang["sizes"]["bytes"];
    }
    $sizestr = str_replace(".", $lang["sizes"]["separator"], $sizestr);

    ?>
</head>
<body id="settings" style="overflow-x:hidden;">
    <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/cms-special/admin/\$resources/spotlight.php"; ?>
    <?php

    require_once $_SERVER['DOCUMENT_ROOT'] . "/resources/private/headers/documentbody.php";

    $path = str_replace("/index.php", "", $_SERVER['SCRIPT_NAME']);
    $name = $pageConfig['headerName'];

    ?>
    <div id="admin">
        <?php
        
        if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/updates")) {
            echo("<div id=\"updates-available\">" . $lang["admin-home"]["updates"][0] . " — <a href=\"/cms-special/admin/updates\">" . $lang["admin-home"]["updates"][1] . "</a></div>");
            $updatable = true;
        } else {
            $updatable = false;
        }
        
        ?>
        <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/cms-special/admin/\$resources/header.php"; ?>