summaryrefslogtreecommitdiffstats
path: root/public/index.php
diff options
context:
space:
mode:
authorrdalverny <rdalverny@gmail.com>2022-01-22 18:54:11 +0100
committerrdalverny <rdalverny@gmail.com>2022-01-22 18:54:11 +0100
commitc27c9d1d359828a071159995689c9c3b28d99891 (patch)
tree8aa8e0e2ea11935c34cee67f2a8f44201329b7e8 /public/index.php
parent58ce95a255c04e1b6ecac0d794bc4dbeb23871de (diff)
downloadplanet-c27c9d1d359828a071159995689c9c3b28d99891.tar
planet-c27c9d1d359828a071159995689c9c3b28d99891.tar.gz
planet-c27c9d1d359828a071159995689c9c3b28d99891.tar.bz2
planet-c27c9d1d359828a071159995689c9c3b28d99891.tar.xz
planet-c27c9d1d359828a071159995689c9c3b28d99891.zip
Move public resources under public/ directory
Existing setups need to update their server config to point (or link to) public/ directory instead of the root of the code repo. Configuration (and password) location also changes from custom/ and admin/inc to custom/config/. That way, config and code library move out of the publicly served file tree. Apart from the change of the web root, config should be migrated seamlessly.
Diffstat (limited to 'public/index.php')
-rwxr-xr-xpublic/index.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/public/index.php b/public/index.php
new file mode 100755
index 0000000..0a0de38
--- /dev/null
+++ b/public/index.php
@@ -0,0 +1,40 @@
+<?php
+require_once '../app/app.php';
+require_once '../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: feed/');
+ 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 '../custom/views/'.$pageTheme.'/'.$pageRole.'.tpl.php';
+ OutputCache::End();
+}
+
+if ($PlanetConfig->getDebug()) {
+ echo "<!-- \$Planet->errors:\n";
+ var_dump($Planet->errors);
+ echo "-->";
+}