From 6bc378e094a039e1e2707c6ed171a6b7fe23c628 Mon Sep 17 00:00:00 2001 From: Git Date: Tue, 24 Apr 2012 08:00:23 +0000 Subject: [PATCH] Empty commit --- sections/index/private.php | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/sections/index/private.php b/sections/index/private.php index 5dc11dfe..603a5671 100644 --- a/sections/index/private.php +++ b/sections/index/private.php @@ -221,27 +221,33 @@ if(($PeerStats = $Cache->get_value('stats_peers')) === false) { //Cache lock! - $Lock = $Cache->get_value('stats_peers_lock'); - if($Lock) { - ?>cache_value('stats_peers_lock', '1', 10); + $PeerStatsLocked = $Cache->get_value('stats_peers_lock'); + if(!$PeerStatsLocked) { + $Cache->cache_value('stats_peers_lock', 1, 30); $DB->query("SELECT IF(remaining=0,'Seeding','Leeching') AS Type, COUNT(uid) FROM xbt_files_users WHERE active=1 GROUP BY Type"); $PeerCount = $DB->to_array(0, MYSQLI_NUM, false); - $SeederCount = isset($PeerCount['Seeding'][1]) ? $PeerCount['Seeding'][1] : 0; - $LeecherCount = isset($PeerCount['Leeching'][1]) ? $PeerCount['Leeching'][1] : 0; - $Cache->cache_value('stats_peers',array($LeecherCount,$SeederCount),0); + $SeederCount = $PeerCount['Seeding'][1] ?: 0; + $LeecherCount = $PeerCount['Leeching'][1] ?: 0; + $Cache->cache_value('stats_peers', array($LeecherCount,$SeederCount), 0); + $Cache->delete_value('stats_peers_lock'); } } else { + $PeerStatsLocked = false; list($LeecherCount,$SeederCount) = $PeerStats; } -$Ratio = ratio($SeederCount, $LeecherCount); -$PeerCount = $SeederCount + $LeecherCount; +if(!$PeerStatsLocked) { + $Ratio = ratio($SeederCount, $LeecherCount); + $PeerCount = number_format($SeederCount + $LeecherCount); + $SeederCount = number_format($SeederCount); + $LeecherCount = number_format($LeecherCount); +} else { + $PeerCount = $SeederCount = $LeecherCount = $Ratio = 'Server busy'; +} ?> -
  • Peers:
  • -
  • Seeders:
  • -
  • Leechers:
  • +
  • Peers:
  • +
  • Seeders:
  • +
  • Leechers:
  • Seeder/Leecher Ratio: