chevereto-free/app/routes/route.install.php

22 lines
614 B
PHP
Raw Normal View History

2016-08-18 20:39:31 +00:00
<?php
2020-06-24 18:35:15 +00:00
$route = function ($handler) {
2016-08-18 20:39:31 +00:00
try {
// Detect if Chevereto is installed
2020-06-24 18:35:15 +00:00
if (CHV\Settings::get('chevereto_version_installed')) {
2016-08-18 20:39:31 +00:00
// Must be an admin
2020-06-24 18:35:15 +00:00
if (!CHV\Login::getUser()['is_admin']) {
2016-08-18 20:39:31 +00:00
G\redirect();
}
}
$install_script = CHV_APP_PATH_INSTALL . 'installer.php';
2020-06-24 18:35:15 +00:00
if (!file_exists($install_script)) {
2016-08-18 20:39:31 +00:00
throw new Exception('Missing ' . G\absolute_to_relative($install_script), 100);
}
2020-06-24 18:35:15 +00:00
if (!@require_once($install_script)) {
2016-08-18 20:39:31 +00:00
throw new Exception("Can't include " . G\absolute_to_relative($install_script), 101);
}
2020-06-24 18:35:15 +00:00
} catch (Exception $e) {
2016-08-18 20:39:31 +00:00
G\exception_to_error($e);
}
2020-06-24 18:35:15 +00:00
};