|
|
@ -62,28 +62,70 @@ class Room |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get totals |
|
|
|
|
|
|
|
$time = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$total = $this->_total( |
|
|
|
|
|
|
|
$namespace['namespaceId'], |
|
|
|
|
|
|
|
$time |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Format date |
|
|
|
|
|
|
|
if ($time) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$date = date( |
|
|
|
|
|
|
|
'Y-m-d ·', |
|
|
|
|
|
|
|
$time |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$date = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Add to room list |
|
|
|
// Add to room list |
|
|
|
$namespaces[$namespace['namespaceId']] = |
|
|
|
$namespaces[$namespace['namespaceId']] = |
|
|
|
[ |
|
|
|
[ |
|
|
|
'name' => $namespace['displayName'], |
|
|
|
'name' => $namespace['displayName'], |
|
|
|
'total' => $this->_total( |
|
|
|
'date' => $date, |
|
|
|
$namespace['namespaceId'] |
|
|
|
'total' => $total |
|
|
|
) |
|
|
|
|
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Get rooms contain pending data |
|
|
|
// Get rooms contain pending data |
|
|
|
foreach ((array) $this->_kevacoin->kevaPending() as $pending) |
|
|
|
foreach ((array) $this->_kevacoin->kevaPending() as $pending) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// Get totals |
|
|
|
|
|
|
|
$time = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$total = $this->_total( |
|
|
|
|
|
|
|
$pending['namespace'], |
|
|
|
|
|
|
|
$time |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Format date |
|
|
|
|
|
|
|
if ($time) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$date = date( |
|
|
|
|
|
|
|
'Y-m-d ·', |
|
|
|
|
|
|
|
$time |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$date = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Add to room list |
|
|
|
// Add to room list |
|
|
|
$namespaces[$pending['namespace']] = |
|
|
|
$namespaces[$pending['namespace']] = |
|
|
|
[ |
|
|
|
[ |
|
|
|
'name' => $this->_namespace( |
|
|
|
'name' => $this->_namespace( |
|
|
|
$pending['namespace'] |
|
|
|
$pending['namespace'] |
|
|
|
), |
|
|
|
), |
|
|
|
'total' => $this->_total( |
|
|
|
'date' => $date, |
|
|
|
$pending['namespace'] |
|
|
|
'total' => $total |
|
|
|
) |
|
|
|
|
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -108,12 +150,25 @@ class Room |
|
|
|
$rooms[] = str_replace( |
|
|
|
$rooms[] = str_replace( |
|
|
|
[ |
|
|
|
[ |
|
|
|
'{name}', |
|
|
|
'{name}', |
|
|
|
|
|
|
|
'{date}', |
|
|
|
'{total}', |
|
|
|
'{total}', |
|
|
|
'{link}' |
|
|
|
'{link}' |
|
|
|
], |
|
|
|
], |
|
|
|
[ |
|
|
|
[ |
|
|
|
$value['name'], |
|
|
|
$value['name'], |
|
|
|
$value['total'], |
|
|
|
$value['date'], |
|
|
|
|
|
|
|
sprintf( |
|
|
|
|
|
|
|
'%s %s', |
|
|
|
|
|
|
|
$value['total'], |
|
|
|
|
|
|
|
$this->_plural( |
|
|
|
|
|
|
|
$value['total'], |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
_('post'), |
|
|
|
|
|
|
|
_('posts'), |
|
|
|
|
|
|
|
_('posts') |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
), |
|
|
|
$this->_link( |
|
|
|
$this->_link( |
|
|
|
sprintf( |
|
|
|
sprintf( |
|
|
|
'/room/%s', |
|
|
|
'/room/%s', |
|
|
@ -330,8 +385,7 @@ class Room |
|
|
|
array $data, |
|
|
|
array $data, |
|
|
|
array $raw = [], |
|
|
|
array $raw = [], |
|
|
|
?string $field = null, |
|
|
|
?string $field = null, |
|
|
|
?int &$time = 0, |
|
|
|
?int &$time = 0 |
|
|
|
?int $cache = 31104000 |
|
|
|
|
|
|
|
): ?string |
|
|
|
): ?string |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Skip values with meta keys |
|
|
|
// Skip values with meta keys |
|
|
@ -364,6 +418,9 @@ class Room |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Return timestamp |
|
|
|
|
|
|
|
$time = $matches[1]; |
|
|
|
|
|
|
|
|
|
|
|
// Is raw field request |
|
|
|
// Is raw field request |
|
|
|
if ($field) |
|
|
|
if ($field) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -465,9 +522,6 @@ class Room |
|
|
|
true |
|
|
|
true |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Return timestamp |
|
|
|
|
|
|
|
$time = $matches[1]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Build final view and save to result |
|
|
|
// Build final view and save to result |
|
|
|
$result = preg_replace( |
|
|
|
$result = preg_replace( |
|
|
|
[ |
|
|
|
[ |
|
|
@ -844,10 +898,19 @@ class Room |
|
|
|
return $namespace; |
|
|
|
return $namespace; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function _total(string $namespace): int |
|
|
|
private function _total(string $namespace, ?int &$updated = 0): int |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Check for cache |
|
|
|
// Check for updated cache |
|
|
|
if (false !== $total = $this->_memory->get([__METHOD__, $namespace])) // can be 0 |
|
|
|
$updated = (int) $this->_memory->get( |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
__METHOD__, |
|
|
|
|
|
|
|
$namespace, |
|
|
|
|
|
|
|
'updated' |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check for total cache |
|
|
|
|
|
|
|
if ($updated && false !== $total = $this->_memory->get([__METHOD__, $namespace])) // can be 0 |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $total; |
|
|
|
return $total; |
|
|
|
} |
|
|
|
} |
|
|
@ -878,8 +941,15 @@ class Room |
|
|
|
foreach ($raw as $data) |
|
|
|
foreach ($raw as $data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Is valid post |
|
|
|
// Is valid post |
|
|
|
if ($this->_post($namespace, $data, [], 'txid')) |
|
|
|
if ($this->_post($namespace, $data, [], 'txid', $time)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// Get last post time |
|
|
|
|
|
|
|
if ($time && $time > $updated) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$updated = $time; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Increase totals |
|
|
|
$total++; |
|
|
|
$total++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -893,6 +963,15 @@ class Room |
|
|
|
$total |
|
|
|
$total |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->_memory->set( |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
__METHOD__, |
|
|
|
|
|
|
|
$namespace, |
|
|
|
|
|
|
|
'updated' |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
$updated |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return $total; |
|
|
|
return $total; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |