return FALSE;
}
+function page_requires_no_login()
+{
+ if (str_ends_with($_SERVER['SCRIPT_FILENAME'],"login/index.php") ||
+ page_requires_no_config())
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
function read_config_file()
{
GLOBAL $config;
require_once UPATH . "/config.php";
require_once UPATH . "/config/compat.php";
}
- if ((include(UPATH . "/config/config.php")) !== 1)
+ if ((@include(UPATH . "/config/config.php")) !== 1)
return false;
if (isset($config['unrealircd']))
$config_transition_unreal_server = true;
function upgrade_check()
{
GLOBAL $config_transition_unreal_server;
+ GLOBAL $config;
/* Moving of a config.php item to DB: */
if ($config_transition_unreal_server)
}
}
+function panel_start_session($user = false)
+{
+ if (!isset($_SESSION))
+ {
+ session_set_cookie_params(86400); // can't set this to session_timeout due to catch-22
+ session_start();
+ }
+
+ if ($user === false)
+ {
+ $user = unreal_get_current_user();
+ if ($user === false)
+ return false;
+ }
+
+ $timeout = 3600;
+ if (isset($user->user_meta['session_timeout']))
+ $timeout = (INT)$user->user_meta['session_timeout'];
+
+ if (!isset($_SESSION['session_timeout']))
+ $_SESSION['session_timeout'] = $timeout;
+
+ $_SESSION['last-activity'] = time();
+ return true;
+}
+
/* Now read the config, and redirect to install screen if we don't have it */
$config_transition_unreal_server = false;
if (!read_config_file())
require_once UPATH . "/Classes/class-paneluser.php";
require_once UPATH . "/plugins.php";
-/* Now that plugins are loaded, read config from DB */
-read_config_db();
+/* Do various checks and reading, except during setup step 1. */
+if (!page_requires_no_config())
+{
+ /* Now that plugins are loaded, read config from DB */
+ read_config_db();
-/* Check if anything needs upgrading (eg on panel version change) */
-upgrade_check();
+ /* Check if anything needs upgrading (eg on panel version change) */
+ upgrade_check();
-/* And a check... */
-if (!page_requires_no_config() && !get_config("base_url"))
- die("The base_url was not found in your config. Setup went wrong?");
+ /* And a check... */
+ if (!get_config("base_url"))
+ die("The base_url was not found in your config. Setup went wrong?");
+}
$pages = [
"Overview" => "",
"News" => "news.php",
];
-if (is_auth_provided())
+if (!panel_start_session())
{
+ if (!page_requires_no_login())
+ {
+ if (!is_auth_provided())
+ die("No authentication plugin loaded. You must load either sql_auth, file_auth, or a similar auth plugin!");
+ $current_page = $_SERVER['REQUEST_URI'];
+ header("Location: ".get_config("base_url")."login/?redirect=".urlencode($current_page));
+ die;
+ }
+} else {
$pages["Settings"]["Accounts"] = "settings";
$user = unreal_get_current_user();
$pages["Logout"] = "login/?logout=true";
}
}
+
Hook::run(HOOKTYPE_NAVBAR, $pages);
/* Example to add new menu item: