Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Photogram Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mohamed ashmar
Photogram Project
Commits
dbbdc4a7
Commit
dbbdc4a7
authored
2 years ago
by
Sibidharan
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into 'dev'
Master See merge request
!11
parents
81ff01a4
a4797f9e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
_templates/_head.php
+16
-1
16 additions, 1 deletion
_templates/_head.php
_templates/_login.php
+1
-0
1 addition, 0 deletions
_templates/_login.php
libs/includes/UserSession.class.php
+13
-3
13 additions, 3 deletions
libs/includes/UserSession.class.php
with
30 additions
and
4 deletions
_templates/_head.php
+
16
−
1
View file @
dbbdc4a7
...
...
@@ -8,7 +8,22 @@
<!-- Bootstrap core CSS -->
<link
href=
"
<?=
get_config
(
'base_path'
)
?>
assets/dist/css/bootstrap.min.css"
rel=
"stylesheet"
>
<title>
Photogram by LAHTP
</title>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"
></script>
<script>
// Initialize the agent at application startup.
const
fpPromise
=
import
(
'
https://openfpcdn.io/fingerprintjs/v3
'
)
.
then
(
FingerprintJS
=>
FingerprintJS
.
load
())
// Get the visitor identifier when you need it.
fpPromise
.
then
(
fp
=>
fp
.
get
())
.
then
(
result
=>
{
// This is the visitor identifier:
const
visitorId
=
result
.
visitorId
console
.
log
(
visitorId
)
$
(
'
#fingerprint
'
).
val
(
visitorId
);
})
</script>
<?
if
(
file_exists
(
$_SERVER
[
'DOCUMENT_ROOT'
]
.
get_config
(
'base_path'
)
.
'css/'
.
basename
(
$_SERVER
[
'PHP_SELF'
],
".php"
)
.
".css"
))
{
?>
<link
href=
"
<?=
get_config
(
'base_path'
)
?>
css/
<?=
basename
(
$_SERVER
[
'PHP_SELF'
],
".php"
)
?>
.css"
rel=
"stylesheet"
>
<?
}
?>
...
...
This diff is collapsed.
Click to expand it.
_templates/_login.php
+
1
−
0
View file @
dbbdc4a7
...
...
@@ -23,6 +23,7 @@ if ($result) {
<form
method=
"post"
action=
"login.php"
>
<img
class=
"mb-4"
src=
"https://git.selfmade.ninja/uploads/-/system/appearance/logo/1/Logo_Dark.png"
alt=
""
height=
"50"
>
<input
name=
"fingerprint"
type=
"hidden"
id=
"fingerprint"
value=
""
>
<h1
class=
"h3 mb-3 fw-normal"
>
Please sign in
</h1>
<div
class=
"form-floating"
>
...
...
This diff is collapsed.
Click to expand it.
libs/includes/UserSession.class.php
+
13
−
3
View file @
dbbdc4a7
...
...
@@ -15,11 +15,13 @@ class UserSession
$conn
=
Database
::
getConnection
();
$ip
=
$_SERVER
[
'REMOTE_ADDR'
];
$agent
=
$_SERVER
[
'HTTP_USER_AGENT'
];
$fingerprint
=
$_POST
[
'fingerprint'
];
$token
=
md5
(
rand
(
0
,
9999999
)
.
$ip
.
$agent
.
time
());
$sql
=
"INSERT INTO `session` (`uid`, `token`, `login_time`, `ip`, `user_agent`, `active`)
VALUES ('
$user->id
', '
$token
', now(), '
$ip
', '
$agent
', '1')"
;
$sql
=
"INSERT INTO `session` (`uid`, `token`, `login_time`, `ip`, `user_agent`, `active`
, `fingerprint`
)
VALUES ('
$user->id
', '
$token
', now(), '
$ip
', '
$agent
', '1'
, '
$fingerprint
'
)"
;
if
(
$conn
->
query
(
$sql
))
{
Session
::
set
(
'session_token'
,
$token
);
Session
::
set
(
'fingerprint'
);
return
$token
;
}
else
{
return
false
;
...
...
@@ -46,7 +48,9 @@ class UserSession
if
(
$session
->
isValid
()
and
$session
->
isActive
())
{
if
(
$_SERVER
[
'REMOTE_ADDR'
]
==
$session
->
getIP
())
{
if
(
$_SERVER
[
'HTTP_USER_AGENT'
]
==
$session
->
getUserAgent
())
{
return
true
;
if
(
$session
->
getFingerprint
()
==
$_SESSION
[
'fingerprint'
]){
return
true
;
}
else
throw
new
Exception
(
"FingerPrint doesn't match"
);
}
else
throw
new
Exception
(
"User agent does't match"
);
}
else
throw
new
Exception
(
"IP does't match"
);
}
else
{
...
...
@@ -123,6 +127,12 @@ class UserSession
}
}
public
function
getFingerprint
(){
if
(
isset
(
$this
->
data
[
'fingerprint'
]))
{
return
$this
->
data
[
'fingerprint'
]
?
true
:
false
;
}
}
//This function remove current session
public
function
removeSession
()
{
...
...
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