Use more PAGE_URL
This commit is contained in:
parent
bd37c14ef9
commit
5561393403
2 changed files with 6 additions and 13 deletions
|
@ -84,10 +84,7 @@ function displayIndex() { ?>
|
|||
}
|
||||
|
||||
function redirUrl($pageId) {
|
||||
$currentPath = '';
|
||||
if (SERVICE !== '.') $currentPath .= SERVICE . '/';
|
||||
if (PAGE !== 'index') $currentPath .= PAGE;
|
||||
return CONF['common']['prefix'] . "/$pageId?redir=$currentPath";
|
||||
return CONF['common']['prefix'] . '/' . $pageId . '?redir=' . PAGE_URL;
|
||||
}
|
||||
|
||||
function redir() {
|
||||
|
|
14
router.php
14
router.php
|
@ -4,12 +4,13 @@ define("CONF", parse_ini_file(__DIR__ . "/config.ini", true, INI_SCANNER_TYPED))
|
|||
|
||||
foreach (array_diff(scandir(CONF['common']['root_path'] . "/fn"), array('..', '.')) as $file)
|
||||
require CONF['common']['root_path'] . '/fn/' . $file;
|
||||
require "pages.php";
|
||||
|
||||
define("DB_PATH", CONF['common']['root_path'] . "/db/niver.db");
|
||||
|
||||
define("PLACEHOLDER_DOMAIN", "example"); // From RFC2606: Reserved Top Level DNS Names > 2. TLDs for Testing, & Documentation Examples
|
||||
define("PLACEHOLDER_IPV6", "2001:db8::3"); // From RFC3849: IPv6 Address Prefix Reserved for Documentation
|
||||
define("PLACEHOLDER_IPV4", "203.0.113.42"); // From RFC5737: IPv4 Address Blocks Reserved for Documentation
|
||||
const PLACEHOLDER_DOMAIN = 'example'; // From RFC2606: Reserved Top Level DNS Names > 2. TLDs for Testing, & Documentation Examples
|
||||
const PLACEHOLDER_IPV6 = '2001:db8::3'; // From RFC3849: IPv6 Address Prefix Reserved for Documentation
|
||||
const PLACEHOLDER_IPV4 = '203.0.113.42'; // From RFC5737: IPv4 Address Blocks Reserved for Documentation
|
||||
|
||||
if ($_SERVER['REQUEST_URI'] === '/sftpgo-auth.php')
|
||||
return;
|
||||
|
@ -19,15 +20,12 @@ if (strpos($pageAddress, "?") !== false) {
|
|||
parse_str(substr($pageAddress, strpos($pageAddress, "?") + 1), $_GET);
|
||||
$pageAddress = substr($pageAddress, 0, strpos($pageAddress, "?"));
|
||||
}
|
||||
|
||||
define("PAGE_URL", $pageAddress);
|
||||
define("PAGE_ADDRESS", $pageAddress . ((substr($pageAddress, -1) === '/' OR $pageAddress === '') ? 'index' : ''));
|
||||
define("PAGE_LINEAGE", explode('/', PAGE_ADDRESS));
|
||||
define("SERVICE", dirname(PAGE_ADDRESS));
|
||||
define("PAGE", basename(PAGE_ADDRESS, '.php'));
|
||||
|
||||
require "pages.php";
|
||||
|
||||
function getTitlesLineage($titles, $pageElements) {
|
||||
if (!isset($titles['index']) OR $pageElements[0] === 'index')
|
||||
return [$titles[$pageElements[0]] ?? false];
|
||||
|
@ -50,9 +48,7 @@ if (!TITLES_LINEAGE[array_key_last(TITLES_LINEAGE)]) {
|
|||
if (
|
||||
isset($_COOKIE['niver-session-key']) // Resume session
|
||||
OR
|
||||
(SERVICE === "auth" // Create new session
|
||||
AND (PAGE === "login" OR PAGE === "register")
|
||||
AND isset($_POST['username']))
|
||||
(isset($_POST['username']) AND in_array(PAGE_URL, ['auth/login', 'auth/register'])) // Start new session
|
||||
) {
|
||||
session_start([
|
||||
'name' => 'niver-session-key',
|
||||
|
|
Loading…
Reference in a new issue