aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/api/admin/cache_pages_update.php
blob: 3122731e6ecde3a35317fcd5b8ba7dfb51122e4b (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
<?php

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

$customSettings = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/customSettings.json"));
global $cache;
$cache = "";

function append(string $text) {
    global $cache;
    $cache = $cache . $text;
}

function compareASCII($a, $b) {
    $at = iconv('UTF-8', 'ASCII//TRANSLIT', $a);
    $bt = iconv('UTF-8', 'ASCII//TRANSLIT', $b);
    return strcmp($at, $bt);
}

$pages = scandir($_SERVER['DOCUMENT_ROOT']);
uasort($pages, 'compareASCII');
$index = 0;
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/enabled")) {$index = 1;}
append("@home|@indexHomeIcon");
foreach ($pages as $page) {
    if ((($page != ".." && $page != ".") && $index < 6) && (is_dir($_SERVER['DOCUMENT_ROOT'] . "/" . $page)) && (file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . $page . "/pagename")) && (!in_array($page, $customSettings->hiddenPages))) {
        append("\n{$page}|" . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $page . "/pagename"));
        $index++;
    }
}
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/enabled")) {
    append("\n@galery|" . $lang["viewer"]["galery"]);
}

file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/cache/pagelist.mtd", $cache);

$cache = "";
$index = 0;
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/enabled")) {$index = 1;}
append("@home|@indexHomeIcon");
foreach ($pages as $page) {
    if ((($page != ".." && $page != ".")) && (is_dir($_SERVER['DOCUMENT_ROOT'] . "/" . $page)) && (file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . $page . "/pagename")) && (!in_array($page, $customSettings->hiddenPages))) {
        append("\n{$page}|" . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $page . "/pagename"));
        $index++;
    }
}
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/enabled")) {
    append("\n@galery|" . $lang["viewer"]["galery"]);
}

file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/cache/pagelist-full.mtd", $cache);

/* --------------------------- */
// Backwards compatibility with the old engine-cyclic
$cache = "";

$pages = scandir($_SERVER['DOCUMENT_ROOT']);
uasort($pages, 'compareASCII');
foreach ($pages as $page) {
    if ($page != ".." && $page != ".") {
        if (is_dir($_SERVER['DOCUMENT_ROOT'] . "/" . $page)) {
            if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . $page . "/pagename")) {
                if (!in_array($page, $customSettings->hiddenPages)) {
                    append("<a href=\"/{$page}\" title=\"/{$page}\" class=\"menulink-desktop\">" . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $page . "/pagename") . "</a>");
                }
            }
        }
    }
}
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/enabled")) {append("<a href=\"/cms-special/gallery\" title=\"/cms-special/gallery\" class=\"menulink-desktop\">" . $lang["viewer"]["galery"] . "</a>");}

file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/cache/pagelist-old.mtd", $cache);