forked from leftypol/leftypol
functions.php: add optional password check for has_any_history
This commit is contained in:
parent
1f05efd2dd
commit
850958a45e
1 changed files with 10 additions and 3 deletions
|
@ -922,9 +922,10 @@ function checkBan($board = false) {
|
|||
* Checks if the given IP has any previous posts.
|
||||
*
|
||||
* @param string $ip The IP to check.
|
||||
* @param ?string $passwd If not null, check also by password.
|
||||
* @return bool True if the ip has already sent at least one post, false otherwise.
|
||||
*/
|
||||
function has_any_history(string $ip): bool {
|
||||
function has_any_history(string $ip, ?string $passwd): bool {
|
||||
global $config;
|
||||
|
||||
if ($config['cache']['enabled']) {
|
||||
|
@ -935,8 +936,14 @@ function has_any_history(string $ip): bool {
|
|||
}
|
||||
|
||||
foreach (listBoards(true) as $board_uri) {
|
||||
$query = prepare(sprintf('SELECT `id` FROM ``posts_%s`` WHERE `ip` = :ip LIMIT 1', $board_uri));
|
||||
$query->bindValue(':ip', $ip);
|
||||
if ($passwd === null) {
|
||||
$query = prepare(sprintf('SELECT `id` FROM ``posts_%s`` WHERE `ip` = :ip LIMIT 1', $board_uri));
|
||||
$query->bindValue(':ip', $ip);
|
||||
} else {
|
||||
$query = prepare(sprintf('SELECT `id` FROM ``posts_%s`` WHERE `ip` = :ip OR `password` = :passwd LIMIT 1', $board_uri));
|
||||
$query->bindValue(':ip', $ip);
|
||||
$query->bindValue(':passwd', $passwd);
|
||||
}
|
||||
$query->execute() or error(db_error());
|
||||
|
||||
if ($query->fetchColumn() !== false) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue