forked from leftypol/leftypol
functions.php: add has_any_history function
This commit is contained in:
parent
aaa725dd06
commit
2981859ac1
1 changed files with 20 additions and 0 deletions
|
@ -918,6 +918,26 @@ function checkBan($board = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the given IP has any previous posts.
|
||||||
|
*
|
||||||
|
* @param string $ip The IP to check.
|
||||||
|
* @return bool True if the ip has already sent at least one post, false otherwise.
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
$query->execute() or error(db_error());
|
||||||
|
|
||||||
|
if ($query->fetchColumn() !== false) {
|
||||||
|
// Found a post.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function threadLocked($id) {
|
function threadLocked($id) {
|
||||||
global $board;
|
global $board;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue