mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
Limit execution time for forum file-listing (#1211)
* Limit execution time for forum file-listing * Prevent multiple ajax calling --------- Co-authored-by: Roman Kelesidis <roman25052006.kelesh@gmail.com>
This commit is contained in:
parent
4295a2c4c6
commit
0b499dc137
6 changed files with 82 additions and 42 deletions
14
common.php
14
common.php
|
@ -302,8 +302,18 @@ function make_rand_str(int $length = 10): string
|
|||
return $randomString;
|
||||
}
|
||||
|
||||
function array_deep(&$var, $fn, $one_dimensional = false, $array_only = false)
|
||||
function array_deep(&$var, $fn, $one_dimensional = false, $array_only = false, $timeout = false)
|
||||
{
|
||||
if ($timeout) {
|
||||
static $recursions = 0;
|
||||
if (time() > (TIMENOW + $timeout)) {
|
||||
return [
|
||||
'timeout' => true,
|
||||
'recs' => $recursions
|
||||
];
|
||||
}
|
||||
$recursions++;
|
||||
}
|
||||
if (is_array($var)) {
|
||||
foreach ($var as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
|
@ -312,7 +322,7 @@ function array_deep(&$var, $fn, $one_dimensional = false, $array_only = false)
|
|||
} elseif ($array_only) {
|
||||
$var[$k] = $fn($v);
|
||||
} else {
|
||||
array_deep($var[$k], $fn);
|
||||
array_deep($var[$k], $fn, timeout: $timeout);
|
||||
}
|
||||
} elseif (!$array_only) {
|
||||
$var[$k] = $fn($v);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue