Skip to content

Commit

Permalink
Make FileRouter work better without mod_rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
csev committed Sep 24, 2024
1 parent 696f1f1 commit 02b19b8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"react/dns" : ">=1.12.0",
"react/socket" : ">=1.15.0",

"tsugi/lib": "dev-master#8f7fa3b0171b90c1c328523f14329f74dd4aefa7",
"tsugi/lib": "dev-master#b682512d511157efcb5f36349d5c7d8271cbb5e4",
"koseu/lib": "dev-master#b9a31b7875108196dbdf284e685b813d424f2def"
},
"config": {
Expand Down
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -7708,12 +7708,12 @@
"source": {
"type": "git",
"url": "https://github.com/tsugiproject/tsugi-php.git",
"reference": "8f7fa3b0171b90c1c328523f14329f74dd4aefa7"
"reference": "b682512d511157efcb5f36349d5c7d8271cbb5e4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tsugiproject/tsugi-php/zipball/8f7fa3b0171b90c1c328523f14329f74dd4aefa7",
"reference": "8f7fa3b0171b90c1c328523f14329f74dd4aefa7",
"url": "https://api.github.com/repos/tsugiproject/tsugi-php/zipball/b682512d511157efcb5f36349d5c7d8271cbb5e4",
"reference": "b682512d511157efcb5f36349d5c7d8271cbb5e4",
"shasum": ""
},
"require": {
Expand All @@ -7727,7 +7727,7 @@
"phpunit/php-timer": "v5.0.3",
"phpunit/phpunit": "9.*"
},
"time": "2024-09-17T17:49:17+00:00",
"time": "2024-09-24T16:23:57+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
Expand Down
6 changes: 3 additions & 3 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '4c3816d04aedb00a1d0dc0223d85cd8ef24224b9',
'reference' => '696f1f107ba2fedfb3624a557cc107c9267f185d',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '4c3816d04aedb00a1d0dc0223d85cd8ef24224b9',
'reference' => '696f1f107ba2fedfb3624a557cc107c9267f185d',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -1078,7 +1078,7 @@
'tsugi/lib' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '8f7fa3b0171b90c1c328523f14329f74dd4aefa7',
'reference' => 'b682512d511157efcb5f36349d5c7d8271cbb5e4',
'type' => 'library',
'install_path' => __DIR__ . '/../tsugi/lib',
'aliases' => array(
Expand Down
2 changes: 1 addition & 1 deletion vendor/tsugi/lib/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 vendor/tsugi/lib/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 02b19b8

Please sign in to comment.