aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/api/admin/rename_page.php
blob: 4091940808562b64a8d59444d310183cac9eba06 (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
<?php require_once "../../resources/private/relative.php"; getRelativeDetails("api"); ?>
<?php

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

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($lang['api']['token']);
        if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log")) {
            file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log") . date("d/m/Y H:i:s") . " - APIDENY/" . $_SERVER['REQUEST_METHOD'] . " - " . $_SERVER['REQUEST_URI'] . " - " . $_SERVER['HTTP_USER_AGENT'] . "\n\n");
        } else {
            file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log", date("d/m/Y H:i:s") . " - APIDENY/" . $_SERVER['REQUEST_METHOD'] . " - " . $_SERVER['REQUEST_URI'] . " - " . $_SERVER['HTTP_USER_AGENT'] . "\n\n");
        }
    }
} else {
    require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang['api']['token']);
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log")) {
        file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log") . date("d/m/Y H:i:s") . " - APIDENY/" . $_SERVER['REQUEST_METHOD'] . " - " . $_SERVER['REQUEST_URI'] . " - " . $_SERVER['HTTP_USER_AGENT'] . "\n\n");
    } else {
        file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log", date("d/m/Y H:i:s") . " - APIDENY/" . $_SERVER['REQUEST_METHOD'] . " - " . $_SERVER['REQUEST_URI'] . " - " . $_SERVER['HTTP_USER_AGENT'] . "\n\n");
    }
}

if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log")) {
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log") . date("d/m/Y H:i:s") . " - API/" . $_SERVER['REQUEST_METHOD'] . " - " . $_SERVER['REQUEST_URI'] . " - " . $_SERVER['HTTP_USER_AGENT'] . "\n\n");
} else {
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log", date("d/m/Y H:i:s") . " - API/" . $_SERVER['REQUEST_METHOD'] . " - " . $_SERVER['REQUEST_URI'] . " - " . $_SERVER['HTTP_USER_AGENT'] . "\n\n");
}

if (isset($_POST['page'])) {
    $oldslug = $_POST['page'];
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent")) {
        if (isset($_POST['newname'])) {
            $newname = $_POST['newname'];
            $newname = str_replace('>', '&gt;', $newname);
            $newname = str_replace('<', '&lt;', $newname);
            if (trim($newname) == "") {
                require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnameempty"]);
            }
            $newslug = preg_replace("/[^0-9a-zA-Z ]/m", "", $newname );
            $newslug = str_replace(" ", "-", $newslug);
            $newslug = strtolower($newslug);
            if ($newslug == "api" || $newslug == "cms-special" || $newslug == "galery" || $newslug == "vendor" || $newslug == "cms-unrelated" || $newslug == "data" || $newslug == "resources" || $newslug == "widgets" || $newslug == "-htaccess" || $newslug == "index" || $newslug == "index-php") {
                require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnameinternal"]);
            }
            if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pages/" . $newslug)) {
                require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnameexists"]);
            }
            if (strlen($newslug) > 70) {
                require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnamelong"]);
            }
            file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pages/" . $newslug, file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pages/" . $oldslug));
            file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pagetypes/" . $newslug, file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pagetypes/" . $oldslug));
            mkdir($_SERVER['DOCUMENT_ROOT'] . "/" . $newslug);
            file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $newslug . "/index.php", '<?php require_once "../resources/private/relative.php"; getRelativeDetails(' . $newslug . '); ?><?php require_once $_SERVER[\'DOCUMENT_ROOT\'] . "/api/engine-cyclic/render.php"; render(\'' . $newslug . '\'); ?>');
            file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $newslug . "/pagename", $newname);
            unlink($_SERVER['DOCUMENT_ROOT'] . "/" . $oldslug . "/index.php");
            unlink($_SERVER['DOCUMENT_ROOT'] . "/" . $oldslug . "/pagename");
            rmdir($_SERVER['DOCUMENT_ROOT'] . "/" . $oldslug);
            unlink($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pages/" . $oldslug);
            unlink($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pagetypes/" . $oldslug);
            require_once $_SERVER['DOCUMENT_ROOT'] . "/api/admin/cache_pages_update.php";
            require $_SERVER['DOCUMENT_ROOT'] . "/api/admin/cache_content_reset.php";
            require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok");
        } else {
            require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnamenone"]);
        }
    } else {
        require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnotfound"]);
    }
} else {
    require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["pgnone"]);
}