mirror of
https://github.com/Mibew/design.git
synced 2025-01-23 02:20:34 +03:00
Create Thread::connectionLimitReached method
This commit is contained in:
parent
9d19afcdf2
commit
2ba492d94f
@ -309,6 +309,31 @@ Class Thread {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if connection limit reached
|
||||||
|
*
|
||||||
|
* @param string $remote User IP
|
||||||
|
* @return boolean TRUE if connection limit reached and FALSE otherwise
|
||||||
|
*/
|
||||||
|
public static function connectionLimitReached($remote) {
|
||||||
|
if (Settings::get('max_connections_from_one_host') == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = Database::getInstance();
|
||||||
|
$result = $db->query(
|
||||||
|
"select count(*) as opened from {chatthread} " .
|
||||||
|
"where remote = ? AND istate <> ? AND istate <> ?",
|
||||||
|
array($remote, Thread::STATE_CLOSED, Thread::STATE_LEFT),
|
||||||
|
array('return_rows' => Database::RETURN_ONE_ROW)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($result && isset($result['opened'])) {
|
||||||
|
return $result['opened'] >= Settings::get('max_connections_from_one_host');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next revision number (last revision number plus one)
|
* Return next revision number (last revision number plus one)
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user