mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
revert peer count
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.4');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-04-19');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-04-22');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', true);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -2563,12 +2563,12 @@ else {
|
||||
//// check every 60 seconds //////////////////
|
||||
$activeseed = $Cache->get_value('user_'.$CURUSER["id"].'_active_seed_count');
|
||||
if ($activeseed == ""){
|
||||
$activeseed = count_peer(sprintf("userid = %s and seeder = 'yes'", $CURUSER['id']), 'torrent');
|
||||
$activeseed = get_row_count("peers","WHERE userid=" . sqlesc($CURUSER["id"]) . " AND seeder='yes'");
|
||||
$Cache->cache_value('user_'.$CURUSER["id"].'_active_seed_count', $activeseed, 60);
|
||||
}
|
||||
$activeleech = $Cache->get_value('user_'.$CURUSER["id"].'_active_leech_count');
|
||||
if ($activeleech == ""){
|
||||
$activeleech = count_peer(sprintf("userid = %s and seeder = 'no'", $CURUSER['id']), 'torrent');
|
||||
$activeleech = get_row_count("peers","WHERE userid=" . sqlesc($CURUSER["id"]) . " AND seeder='no'");
|
||||
$Cache->cache_value('user_'.$CURUSER["id"].'_active_leech_count', $activeleech, 60);
|
||||
}
|
||||
$unread = $Cache->get_value('user_'.$CURUSER["id"].'_unread_message_count');
|
||||
|
||||
@@ -704,22 +704,3 @@ function isIPV6 ($ip)
|
||||
{
|
||||
return filter_var($ip,FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
|
||||
}
|
||||
|
||||
function count_peer($whereStr, $field = 'peer_id')
|
||||
{
|
||||
if (empty($whereStr)) {
|
||||
throw new \InvalidArgumentException("require whereStr");
|
||||
}
|
||||
if (IN_NEXUS) {
|
||||
$sql = "select count(distinct($field)) as counts from peers where $whereStr";
|
||||
$res = sql_query($sql);
|
||||
$count = mysql_fetch_assoc($res);
|
||||
return $count['counts'];
|
||||
} else {
|
||||
$res = \Illuminate\Support\Facades\DB::table('peers')
|
||||
->whereRaw($whereStr)
|
||||
->selectRaw("count(distinct($field)) as counts")
|
||||
->first();
|
||||
return $res->counts;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user