Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
44c20a11
Commit
44c20a11
authored
9 years ago
by
Jaime Perez Crespo
Browse files
Options
Downloads
Patches
Plain Diff
Add a method that tries to guess the base URI path.
parent
148e7cff
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/SimpleSAML/Utils/HTTP.php
+30
-0
30 additions, 0 deletions
lib/SimpleSAML/Utils/HTTP.php
with
30 additions
and
0 deletions
lib/SimpleSAML/Utils/HTTP.php
+
30
−
0
View file @
44c20a11
...
...
@@ -501,6 +501,36 @@ class HTTP
}
/**
* Try to guess the base SimpleSAMLphp path from the current request.
*
* This method offers just a guess, so don't rely on it.
*
* @return string The guessed base path that should correspond to the root installation of SimpleSAMLphp.
*/
public
static
function
guessBasePath
()
{
// get the name of the current script
$path
=
explode
(
'/'
,
$_SERVER
[
'SCRIPT_FILENAME'
]);
$script
=
array_pop
(
$path
);
// get the portion of the URI up to the script, i.e.: /simplesaml/some/directory/script.php
preg_match
(
'#^/(?:[^/]+/)*'
.
$script
.
'#'
,
$_SERVER
[
'REQUEST_URI'
],
$matches
);
$uri_s
=
explode
(
'/'
,
$matches
[
0
]);
$file_s
=
explode
(
'/'
,
$_SERVER
[
'SCRIPT_FILENAME'
]);
// compare both arrays from the end, popping elements matching out of them
while
(
$uri_s
[
count
(
$uri_s
)
-
1
]
===
$file_s
[
count
(
$file_s
)
-
1
])
{
array_pop
(
$uri_s
);
array_pop
(
$file_s
);
}
// we are now left with the minimum part of the URI that does not match anything in the file system, use it
return
join
(
'/'
,
$uri_s
)
.
'/'
;
}
/**
* Retrieve the base URL of the SimpleSAMLphp installation. The URL will always end with a '/'. For example:
* https://idp.example.org/simplesaml/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment