Skip to content

Commit

Permalink
Make FileRouter work better when mod_rewrite is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
csev committed Sep 24, 2024
1 parent 8f7fa3b commit b682512
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Core/LTIX.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 6 additions & 2 deletions src/Util/FileRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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';
Expand Down

0 comments on commit b682512

Please sign in to comment.