summaryrefslogtreecommitdiffstats
path: root/index.php
blob: 0d149bda669e60d4339642c06ede9faecd00e107 (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
<?php
include_once(__DIR__.'/app/app.php');
include_once(__DIR__.'/app/classes/Cache.php');

if (!$PlanetConfig::isInstalled()) {
    die('<p>' . _g('You might want to <a href="install.php">install moonmoon</a>.') . '</p>');
}

$pageRole = $_GET['type'] ?? 'index';
$pageTheme = 'default';
if (!in_array($pageRole, ['index', 'archive', 'atom10'])) {
    $pageRole = 'index';
}

if ($pageRole == 'atom10') {
    /* XXX: Redirect old ATOM feeds to new url to make sure our users don't
     * loose subscribers upon upgrading their moonmoon installation.
     * Remove this check in a more distant future.
     */
    header('Status: 301 Moved Permanently', false, 301);
    header('Location: atom.php');
    exit;
}

$cache_duration = $PlanetConfig->getOutputTimeout();
Cache::$enabled = ($cache_duration > 0);
Cache::setStore($PlanetConfig->getCacheDir() . '/');

if (!OutputCache::Start('html', $pageRole, $cache_duration)) {
    $items = $Planet->getFeedsItems();
    $last_modified  = (count($items)) ? $items[0]->get_date() : '';
    include_once(__DIR__.'/custom/views/'.$pageTheme.'/'.$pageRole.'.tpl.php');
    OutputCache::End();
}

if ($PlanetConfig->getDebug()) {
    echo "<!-- \$Planet->errors:\n";
    var_dump($Planet->errors);
    echo "-->";
}