/
index.php
51 lines (37 loc) · 1.28 KB
/
index.php
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
<?php
namespace Paheko;
use Paheko\Web\Web;
use Paheko\Files\Files;
use Paheko\Users\Session;
use Paheko\Entities\Files\File;
use Paheko\Extensions;
use Paheko\Plugins;
require_once __DIR__ . '/_inc.php';
$session = Session::getInstance();
$banner = '';
$signal = Plugins::fire('home.banner', false, ['user' => $session->getUser(), 'session' => $session]);
if ($signal) {
$banner = implode('', $signal->getOut());
}
$homepage = Config::getInstance()->file('admin_homepage');
if ($homepage) {
$homepage = $homepage->render();
}
else {
$homepage = null;
}
$buttons = Extensions::listHomeButtons($session);
$has_extensions = empty($buttons) ? Extensions::isAnyExtensionEnabled() : true;
if (!$has_extensions && $session->canAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN)) {
$buttons = Extensions::listAvailableButtons();
}
$tpl->assign(compact('homepage', 'banner', 'buttons', 'has_extensions'));
$tpl->assign('custom_css', [BASE_URL . 'content.css']);
$tpl->display('index.tpl');
flush();
// If no cron task is used, then the cron is run when visiting the homepage
// this is not the best, but better than nothing
if (!USE_CRON && @filemtime(CACHE_ROOT . '/last_cron_run') < (time() - 24*3600)) {
touch(CACHE_ROOT . '/last_cron_run');
require_once ROOT . '/scripts/cron.php';
}