Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SWITCHwayf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Guillaume Rousse
SWITCHwayf
Commits
f2b8706c
Commit
f2b8706c
authored
Jul 16, 2013
by
haemmer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #2786 and #2787
parent
ccd69df9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
29 deletions
+46
-29
functions.php
functions.php
+46
-29
No files found.
functions.php
View file @
f2b8706c
...
...
@@ -397,8 +397,8 @@ function decomposeLocale($locale){
}
/******************************************************************************/
// Gets a string in
the user's language. If no localized version is available
//
for the string, the English string is returned as default
.
// Gets a string in
a specific language. Fallback to default language and
//
to English
.
function
getLocalString
(
$string
,
$encoding
=
''
){
global
$defaultLanguage
,
$langStrings
,
$language
;
...
...
@@ -406,8 +406,10 @@ function getLocalString($string, $encoding = ''){
$textString
=
''
;
if
(
isset
(
$langStrings
[
$language
][
$string
])){
$textString
=
$langStrings
[
$language
][
$string
];
}
else
{
}
else
if
(
isset
(
$langStrings
[
$defaultLanguage
][
$string
]))
{
$textString
=
$langStrings
[
$defaultLanguage
][
$string
];
}
else
{
$textString
=
$langStrings
[
'en'
][
$string
];
}
// Change encoding if necessary
...
...
@@ -699,38 +701,53 @@ function redirectToSP($url, $IdP){
function
logAccessEntry
(
$protocol
,
$type
,
$sp
,
$idp
){
global
$WAYFLogFile
,
$useLogging
;
// Return if logging deactivated
if
(
!
$useLogging
){
return
;
}
// Let's make sure the file exists and is writable first.
if
(
is_writable
(
$WAYFLogFile
))
{
// Create log entry
$entry
=
date
(
'Y-m-d H:i:s'
)
.
' '
.
$_SERVER
[
'REMOTE_ADDR'
]
.
' '
.
$protocol
.
' '
.
$type
.
' '
.
$idp
.
' '
.
$sp
.
"
\n
"
;
// We are opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if
(
!
$handle
=
fopen
(
$WAYFLogFile
,
'a'
))
{
return
;
}
// Try getting lock
while
(
!
flock
(
$handle
,
LOCK_EX
)){
usleep
(
rand
(
10
,
100
));
}
// Write $somecontent to our opened file.
fwrite
(
$handle
,
$entry
);
// Release the lock
flock
(
$handle
,
LOCK_UN
);
// Close file handle
fclose
(
$handle
);
// Create log file if it does not exist yet
if
(
!
file_exists
(
$WAYFLogFile
)
&&
!
touch
(
$WAYFLogFile
)){
// File does not exist and cannot be written to
logFatalErrorAndExit
(
'WAYF log file '
.
$WAYFLogFile
.
' does not exist and could not be created.'
);
}
// Ensure that the file exists and is writable
if
(
!
is_writable
(
$WAYFLogFile
))
{
logFatalErrorAndExit
(
'Current file permission do not allow WAYF to write to its log file '
.
$WAYFLogFile
.
'.'
);
}
// Compose log entry
$entry
=
date
(
'Y-m-d H:i:s'
)
.
' '
.
$_SERVER
[
'REMOTE_ADDR'
]
.
' '
.
$protocol
.
' '
.
$type
.
' '
.
$idp
.
' '
.
$sp
.
"
\n
"
;
// Open file in append mode
if
(
!
$handle
=
fopen
(
$WAYFLogFile
,
'a'
))
{
logFatalErrorAndExit
(
'Could not open file '
.
$WAYFLogFile
.
' for appending log entries.'
);
}
// Try getting the lock
while
(
!
flock
(
$handle
,
LOCK_EX
)){
usleep
(
rand
(
10
,
100
));
}
// Write entry
fwrite
(
$handle
,
$entry
);
// Release the lock
flock
(
$handle
,
LOCK_UN
);
// Close file handle
fclose
(
$handle
);
}
/******************************************************************************/
// Logs an fatal error message
function
logFatalErrorAndExit
(
$errorMsg
){
syslog
(
LOG_ERR
,
$errorMsg
);
exit
;
}
/******************************************************************************/
// Returns true if PATH info indicates a request of type $type
function
isRequestType
(
$type
){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment