Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
f0108fe6
Commit
f0108fe6
authored
Jan 19, 2016
by
Daniel Ruf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check PHP version for password_hash
parent
563fa715
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
users.php
qa-include/db/users.php
+19
-0
No files found.
qa-include/db/users.php
View file @
f0108fe6
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
return
sha1
(
substr
(
$salt
,
0
,
8
)
.
$password
.
substr
(
$salt
,
8
));
return
sha1
(
substr
(
$salt
,
0
,
8
)
.
$password
.
substr
(
$salt
,
8
));
}
}
function
qa_db_user_create
(
$email
,
$password
,
$handle
,
$level
,
$ip
)
function
qa_db_user_create
(
$email
,
$password
,
$handle
,
$level
,
$ip
)
/*
/*
Create a new user in the database with $email, $password, $handle, privilege $level, and $ip address
Create a new user in the database with $email, $password, $handle, privilege $level, and $ip address
...
@@ -45,11 +46,20 @@
...
@@ -45,11 +46,20 @@
$salt
=
isset
(
$password
)
?
qa_random_alphanum
(
16
)
:
null
;
$salt
=
isset
(
$password
)
?
qa_random_alphanum
(
16
)
:
null
;
if
(
!
qa_php_version_below
(
'5.3.7'
)){
qa_db_query_sub
(
qa_db_query_sub
(
'INSERT INTO ^users (created, createip, email, passhash, level, handle, loggedin, loginip) '
.
'INSERT INTO ^users (created, createip, email, passhash, level, handle, loggedin, loginip) '
.
'VALUES (NOW(), COALESCE(INET_ATON($), 0), $, $, $, #, $, NOW(), COALESCE(INET_ATON($), 0))'
,
'VALUES (NOW(), COALESCE(INET_ATON($), 0), $, $, $, #, $, NOW(), COALESCE(INET_ATON($), 0))'
,
$ip
,
$email
,
isset
(
$password
)
?
password_hash
(
$password
,
PASSWORD_BCRYPT
)
:
null
,
(
int
)
$level
,
$handle
,
$ip
$ip
,
$email
,
isset
(
$password
)
?
password_hash
(
$password
,
PASSWORD_BCRYPT
)
:
null
,
(
int
)
$level
,
$handle
,
$ip
);
);
}
else
{
qa_db_query_sub
(
'INSERT INTO ^users (created, createip, email, passsalt, passcheck, level, handle, loggedin, loginip) '
.
'VALUES (NOW(), COALESCE(INET_ATON($), 0), $, $, UNHEX($), #, $, NOW(), COALESCE(INET_ATON($), 0))'
,
$ip
,
$email
,
$salt
,
isset
(
$password
)
?
qa_db_calc_passcheck
(
$password
,
$salt
)
:
null
,
(
int
)
$level
,
$handle
,
$ip
);
}
return
qa_db_last_insert_id
();
return
qa_db_last_insert_id
();
}
}
...
@@ -153,10 +163,19 @@
...
@@ -153,10 +163,19 @@
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
if
(
qa_php_version_below
(
'5.3.7'
))
$salt
=
qa_random_alphanum
(
16
);
if
(
!
qa_php_version_below
(
'5.3.7'
)){
qa_db_query_sub
(
qa_db_query_sub
(
'UPDATE ^users SET passhash=$, passsalt=NULL, passcheck=NULL WHERE userid=$'
,
'UPDATE ^users SET passhash=$, passsalt=NULL, passcheck=NULL WHERE userid=$'
,
password_hash
(
$password
,
PASSWORD_BCRYPT
),
$userid
password_hash
(
$password
,
PASSWORD_BCRYPT
),
$userid
);
);
}
else
{
qa_db_query_sub
(
'UPDATE ^users SET passsalt=$, passcheck=UNHEX($) WHERE userid=$'
,
$salt
,
qa_db_calc_passcheck
(
$password
,
$salt
),
$userid
);
}
}
}
...
...
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