From b682512d511157efcb5f36349d5c7d8271cbb5e4 Mon Sep 17 00:00:00 2001 From: Charles Severance Date: Tue, 24 Sep 2024 12:23:57 -0400 Subject: [PATCH] Make FileRouter work better when mod_rewrite is not installed --- src/Core/LTIX.php | 2 +- src/Util/FileRouter.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Core/LTIX.php b/src/Core/LTIX.php index 38fae24f..93d87001 100644 --- a/src/Core/LTIX.php +++ b/src/Core/LTIX.php @@ -446,7 +446,7 @@ public static function setupSession($needed=self::ALL, $session_object=null, $re session_start(); // if we're using a cookie session, the session may already have been started; if not, start it now // (if we call session_start() and the session has already been started, php will generate a notice, which we don't want) - } else if (U::isEmpty($_SESSION)) { + } else if (U::isEmpty($_SESSION ?? null)) { session_start(); } $session_id = session_id(); diff --git a/src/Util/FileRouter.php b/src/Util/FileRouter.php index c307ccd4..71d4d4d9 100644 --- a/src/Util/FileRouter.php +++ b/src/Util/FileRouter.php @@ -39,7 +39,7 @@ public function trimQuery($uri) { } // /wa4e/install returns install.php if the file exists - public function fileCheck($uri=null) { + public function fileCheck($uri=null, $defaultFile='index.php') { global $TSUGI_REST_PATH_VALUES; global $TSUGI_REST_PATH; $TSUGI_REST_PATH = false; @@ -48,9 +48,13 @@ public function fileCheck($uri=null) { $uri = self::trimQuery($uri); // /wa4e/tsugi $cwd = self::cwd(); - if ( ! endsWith($cwd, '/') ) $cwd = $cwd .'/'; + if ( ! endsWith($cwd, '/') ) $cwd = $cwd .'/'; if ( strpos($uri,$cwd) === 0 ) { $remainder = substr($uri, strlen($cwd)); + if ( empty($remainder) && $defaultFile && file_exists($defaultFile ) ) { + $TSUGI_REST_PATH = $cwd . $defaultFile; + return $defaultFile; + } if ( empty($remainder) ) return false; $pieces = explode('/',$remainder,2); $file = $pieces[0] . '.php';