finish seed box basic

This commit is contained in:
xiaomlove
2022-07-23 15:05:32 +08:00
parent b507c41bf0
commit 42bf8f0467
32 changed files with 644 additions and 249 deletions
+1
View File
@@ -99,6 +99,7 @@ function addSeedBoxRecord($params)
$rep = new \App\Repositories\SeedBoxRepository();
$params['uid'] = $CURUSER['id'];
$params['type'] = \App\Models\SeedBoxRecord::TYPE_USER;
$params['status'] = \App\Models\SeedBoxRecord::STATUS_UNAUDITED;
return $rep->store($params);
}
+134 -115
View File
@@ -120,6 +120,7 @@ if (!$az) err("Invalid passkey! Re-download the .torrent from $BASEURL");
$userid = intval($az['id'] ?? 0);
unset($GLOBALS['CURUSER']);
$CURUSER = $GLOBALS["CURUSER"] = $az;
$isDonor = $az['donor'] == 'yes' && ($az['donoruntil'] === null || $az['donoruntil'] == '0000-00-00 00:00:00' || $az['donoruntil'] > date('Y-m-d H:i:s'));
//3. CHECK IF CLIENT IS ALLOWED
//$clicheck_res = check_client($peer_id,$agent,$client_familyid);
@@ -152,7 +153,7 @@ elseif ($az['showclienterror'] == 'yes'){
}
// check torrent based on info_hash
$checkTorrentSql = "SELECT id, owner, sp_state, seeders, leechers, UNIX_TIMESTAMP(added) AS ts, banned, hr, approval_status FROM torrents WHERE " . hash_where("info_hash", $info_hash);
$checkTorrentSql = "SELECT id, size, owner, sp_state, seeders, leechers, UNIX_TIMESTAMP(added) AS ts, banned, hr, approval_status FROM torrents WHERE " . hash_where("info_hash", $info_hash);
if (!$torrent = $Cache->get_value('torrent_hash_'.$info_hash.'_content')){
$res = sql_query($checkTorrentSql);
$torrent = mysql_fetch_array($res);
@@ -284,6 +285,12 @@ if(isset($self) && empty($_GET['event']) && $self['prevts'] > (TIMENOW - $announ
}
$isSeedBoxRuleEnabled = get_setting('seed_box.enabled') == 'yes';
$isIPSeedBox = false;
if ($isSeedBoxRuleEnabled && !($az['class'] >= \App\Models\User::CLASS_VIP || $isDonor)) {
$isIPSeedBox = isIPSeedBox($ip, $userid);
}
// current peer_id, or you could say session with tracker not found in table peers
if (!isset($self))
{
@@ -296,7 +303,7 @@ if (!isset($self))
elseif ($az["parked"] == "yes")
err("Your account is parked! (Read the FAQ)");
elseif ($az["downloadpos"] == "no")
err("Your downloading priviledges have been disabled! (Read the rules)");
err("Your downloading privileges have been disabled! (Read the rules)");
if ($az["class"] < UC_VIP)
{
@@ -336,10 +343,18 @@ if (!isset($self))
}
else // continue an existing session
{
$snatchInfo = mysql_fetch_assoc(sql_query(sprintf('select * from snatched where torrentid = %s and userid = %s order by id desc limit 1', $torrentid, $userid)));
$upthis = $trueupthis = max(0, $uploaded - $self["uploaded"]);
$downthis = $truedownthis = max(0, $downloaded - $self["downloaded"]);
$announcetime = ($self["seeder"] == "yes" ? "seedtime = seedtime + {$self['announcetime']}" : "leechtime = leechtime + {$self['announcetime']}");
$is_cheater = false;
$notSeedBoxMaxSpeedMbps = get_setting('seed_box.not_seed_box_max_speed');
$upSpeedMbps = ($trueupthis / $self['announcetime']) * 8;
if ($isSeedBoxRuleEnabled && !$isIPSeedBox && $upSpeedMbps > $notSeedBoxMaxSpeedMbps) {
sql_query("update users set downloadpos = 'no' where id = $userid");
do_log("user: $userid downloading privileges have been disabled! (over speed)", 'error');
err("Your downloading privileges have been disabled! (over speed)");
}
if ($cheaterdet_security){
if ($az['class'] < $nodetect_security && $self['announcetime'] > 10)
@@ -352,92 +367,106 @@ else // continue an existing session
if (!$is_cheater && ($trueupthis > 0 || $truedownthis > 0))
{
$global_promotion_state = get_global_sp_state();
if (isset($torrent['__ignore_global_sp_state']) && $torrent['__ignore_global_sp_state']) {
do_log("[IGNORE_GLOBAL_SP_STATE], sp_state: {$torrent['sp_state']}");
$global_promotion_state = 1;
}
if($global_promotion_state == 1)// Normal, see individual torrent
{
if($torrent['sp_state']==3) //2X
{
$USERUPDATESET[] = "uploaded = uploaded + 2*$trueupthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis";
}
elseif($torrent['sp_state']==4) //2X Free
{
$USERUPDATESET[] = "uploaded = uploaded + 2*$trueupthis";
}
elseif($torrent['sp_state']==6) //2X 50%
{
$USERUPDATESET[] = "uploaded = uploaded + 2*$trueupthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis/2";
}
else{
if ($torrent['owner'] == $userid && $uploaderdouble_torrent > 0)
$upthis = $trueupthis * $uploaderdouble_torrent;
if ($isSeedBoxRuleEnabled && $isIPSeedBox) {
$tmpLog = "[SEED_BOX_RULE_ENABLED_AND_IS_IP_SEED_BOX]";
$maxUploadedTimes = get_setting('seed_box.max_uploaded');
$userUploadedIncrement = $trueupthis;
$userDownloadedIncrement = $truedownthis;
if (!empty($snatchInfo) && isset($torrent['size']) && $snatchInfo['uploaded'] >= $torrent['size'] * $maxUploadedTimes) {
$tmpLog .= ", uploaded >= torrentSize * times($maxUploadedTimes), userUploadedIncrement = 0";
$userUploadedIncrement = 0;
}
$USERUPDATESET[] = "uploaded = uploaded + $userUploadedIncrement";
$USERUPDATESET[] = "downloaded = downloaded + $userDownloadedIncrement";
do_log($tmpLog);
} else {
$global_promotion_state = get_global_sp_state();
if (isset($torrent['__ignore_global_sp_state']) && $torrent['__ignore_global_sp_state']) {
do_log("[IGNORE_GLOBAL_SP_STATE], sp_state: {$torrent['sp_state']}");
$global_promotion_state = 1;
}
if($global_promotion_state == 1)// Normal, see individual torrent
{
if($torrent['sp_state']==3) //2X
{
$USERUPDATESET[] = "uploaded = uploaded + 2*$trueupthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis";
}
elseif($torrent['sp_state']==4) //2X Free
{
$USERUPDATESET[] = "uploaded = uploaded + 2*$trueupthis";
}
elseif($torrent['sp_state']==6) //2X 50%
{
$USERUPDATESET[] = "uploaded = uploaded + 2*$trueupthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis/2";
}
else{
if ($torrent['owner'] == $userid && $uploaderdouble_torrent > 0)
$upthis = $trueupthis * $uploaderdouble_torrent;
if($torrent['sp_state']==2) //Free
{
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
}
elseif($torrent['sp_state']==5) //50%
{
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis/2";
}
elseif($torrent['sp_state']==7) //30%
{
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis*3/10";
}
elseif($torrent['sp_state']==1) //Normal
{
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis";
}
}
}
elseif($global_promotion_state == 2) //Free
{
if ($torrent['owner'] == $userid && $uploaderdouble_torrent > 0)
$upthis = $trueupthis * $uploaderdouble_torrent;
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
}
elseif($global_promotion_state == 3) //2X
{
if ($uploaderdouble_torrent > 2 && $torrent['owner'] == $userid && $uploaderdouble_torrent > 0)
$upthis = $trueupthis * $uploaderdouble_torrent;
else $upthis = 2*$trueupthis;
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis";
}
elseif($global_promotion_state == 4) //2X Free
{
if ($uploaderdouble_torrent > 2 && $torrent['owner'] == $userid && $uploaderdouble_torrent > 0)
$upthis = $trueupthis * $uploaderdouble_torrent;
else $upthis = 2*$trueupthis;
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
}
elseif($global_promotion_state == 5){ // 50%
if ($torrent['owner'] == $userid && $uploaderdouble_torrent > 0)
$upthis = $trueupthis * $uploaderdouble_torrent;
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis/2";
}
elseif($global_promotion_state == 6){ //2X 50%
if ($uploaderdouble_torrent > 2 && $torrent['owner'] == $userid && $uploaderdouble_torrent > 0)
$upthis = $trueupthis * $uploaderdouble_torrent;
else $upthis = 2*$trueupthis;
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis/2";
}
elseif($global_promotion_state == 7){ //30%
if ($torrent['owner'] == $userid && $uploaderdouble_torrent > 0)
$upthis = $trueupthis * $uploaderdouble_torrent;
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis*3/10";
}
if($torrent['sp_state']==2) //Free
{
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
}
elseif($torrent['sp_state']==5) //50%
{
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis/2";
}
elseif($torrent['sp_state']==7) //30%
{
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis*3/10";
}
elseif($torrent['sp_state']==1) //Normal
{
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis";
}
}
}
elseif($global_promotion_state == 2) //Free
{
if ($torrent['owner'] == $userid && $uploaderdouble_torrent > 0)
$upthis = $trueupthis * $uploaderdouble_torrent;
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
}
elseif($global_promotion_state == 3) //2X
{
if ($uploaderdouble_torrent > 2 && $torrent['owner'] == $userid && $uploaderdouble_torrent > 0)
$upthis = $trueupthis * $uploaderdouble_torrent;
else $upthis = 2*$trueupthis;
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis";
}
elseif($global_promotion_state == 4) //2X Free
{
if ($uploaderdouble_torrent > 2 && $torrent['owner'] == $userid && $uploaderdouble_torrent > 0)
$upthis = $trueupthis * $uploaderdouble_torrent;
else $upthis = 2*$trueupthis;
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
}
elseif($global_promotion_state == 5){ // 50%
if ($torrent['owner'] == $userid && $uploaderdouble_torrent > 0)
$upthis = $trueupthis * $uploaderdouble_torrent;
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis/2";
}
elseif($global_promotion_state == 6){ //2X 50%
if ($uploaderdouble_torrent > 2 && $torrent['owner'] == $userid && $uploaderdouble_torrent > 0)
$upthis = $trueupthis * $uploaderdouble_torrent;
else $upthis = 2*$trueupthis;
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis/2";
}
elseif($global_promotion_state == 7){ //30%
if ($torrent['owner'] == $userid && $uploaderdouble_torrent > 0)
$upthis = $trueupthis * $uploaderdouble_torrent;
$USERUPDATESET[] = "uploaded = uploaded + $upthis";
$USERUPDATESET[] = "downloaded = downloaded + $truedownthis*3/10";
}
}
}
}
@@ -476,23 +505,14 @@ elseif(isset($self))
// $updateset[] = ($seeder == "yes" ? "seeders = seeders + 1, leechers = leechers - 1" : "seeders = seeders - 1, leechers = leechers + 1");
$hasChangeSeederLeecher = true;
}
$snatchInfo = \App\Models\Snatch::query()
->where('torrentid', $torrentid)
->where('userid', $userid)
->orderBy('id', 'desc')
->first();
if ($snatchInfo) {
if (!empty($snatchInfo)) {
sql_query("UPDATE snatched SET uploaded = uploaded + $trueupthis, downloaded = downloaded + $truedownthis, to_go = $left, $announcetime, last_action = ".$dt." $finished_snatched WHERE torrentid = $torrentid AND userid = $userid") or err("SL Err 2");
do_action('snatched_saved', $torrent, $snatchInfo->toArray());
if (
$event == 'completed'
&& $az['class'] < \App\Models\HitAndRun::MINIMUM_IGNORE_USER_CLASS
&& ($az['donor'] == 'no' || (!empty($az['donoruntil']) && $az['donoruntil'] != '0000-00-00 00:00:00' && $az['donoruntil'] < date("Y-m-d H:i:s")))
) {
do_action('snatched_saved', $torrent, $snatchInfo);
if ($event == 'completed' && $az['class'] < \App\Models\HitAndRun::MINIMUM_IGNORE_USER_CLASS && !$isDonor) {
//think about H&R
$hrMode = get_setting('hr.mode');
if ($hrMode == \App\Models\HitAndRun::MODE_GLOBAL || ($hrMode == \App\Models\HitAndRun::MODE_MANUAL && $torrent['hr'] == \App\Models\Torrent::HR_YES)) {
$sql = "insert into hit_and_runs (uid, torrent_id, snatched_id) values ($userid, $torrentid, {$snatchInfo->id}) on duplicate key update updated_at = " . sqlesc(date('Y-m-d H:i:s'));
$sql = "insert into hit_and_runs (uid, torrent_id, snatched_id) values ($userid, $torrentid, {$snatchInfo['id']}) on duplicate key update updated_at = " . sqlesc(date('Y-m-d H:i:s'));
$affectedRows = sql_query($sql);
do_log("[INSERT_H&R], $sql, affectedRows: $affectedRows");
}
@@ -504,21 +524,20 @@ else
{
if ($event != 'stopped') {
$isPeerExistResultSet = sql_query("select id from peers where $selfwhere limit 1");
if ($isPeerExistResultSet && !mysqli_fetch_assoc($isPeerExistResultSet)) {
if (strlen($ip) > 15) {
$sockres = @pfsockopen("tcp://[".$ip."]",$port,$errno,$errstr,1);
} else {
$sockres = @pfsockopen($ip, $port, $errno, $errstr, 1);
}
if (!$sockres)
{
$connectable = "no";
}
else
{
$connectable = "yes";
@fclose($sockres);
}
if (mysql_num_rows($isPeerExistResultSet) == 0) {
$cacheKey = 'peers:connectable:'.$ip.'-'.$port.'-'.$agent;
$connectable = \Nexus\Database\NexusDB::remember($cacheKey, 3600, function () use ($ip, $port) {
if (isIPV6($ip)) {
$sockres = @fsockopen("tcp://[".$ip."]",$port,$errno,$errstr,1);
} else {
$sockres = @fsockopen($ip, $port, $errno, $errstr, 1);
}
if (is_resource($sockres)) {
fclose($sockres);
return 'yes';
}
return 'no';
});
$insertPeerSql = "INSERT INTO peers (torrent, userid, peer_id, ip, port, connectable, uploaded, downloaded, to_go, started, last_action, seeder, agent, downloadoffset, uploadoffset, passkey, ipv4, ipv6) VALUES ($torrentid, $userid, ".sqlesc($peer_id).", ".sqlesc($ip).", $port, '$connectable', $uploaded, $downloaded, $left, $dt, $dt, '$seeder', ".sqlesc($agent).", $downloaded, $uploaded, ".sqlesc($passkey).",".sqlesc($ipv4).",".sqlesc($ipv6).")";
do_log("[INSERT PEER] peer not exists for $selfwhere, do insert with $insertPeerSql");
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

+21 -17
View File
@@ -923,12 +923,13 @@ if ($forumposts)
<?php
tr_small($lang_usercp['row_join_date'], $joindate, 1);
tr_small($lang_usercp['row_email_address'], $CURUSER['email'], 1);
$seedBoxIcon = (new \App\Repositories\SeedBoxRepository())->renderIcon($CURUSER['ip'], $CURUSER['id']);
if ($enablelocation_tweak == 'yes'){
list($loc_pub, $loc_mod) = get_ip_location($CURUSER["ip"]);
tr_small($lang_usercp['row_ip_location'], $CURUSER["ip"]." <span title='" . $loc_mod . "'>[" . $loc_pub . "]</span>", 1);
tr_small($lang_usercp['row_ip_location'], $CURUSER["ip"]." <span title='" . $loc_mod . "'>[" . $loc_pub . "]</span>$seedBoxIcon", 1);
}
else{
tr_small($lang_usercp['row_ip_location'], $CURUSER["ip"], 1);
tr_small($lang_usercp['row_ip_location'], $CURUSER["ip"] . $seedBoxIcon, 1);
}
if ($CURUSER["avatar"])
tr_small($lang_usercp['row_avatar'], "<img src=\"" . $CURUSER["avatar"] . "\" border=0>", 1);
@@ -948,25 +949,28 @@ tr_small($lang_usercp['row_written_comments'], $commentcount." [<a href=\"userhi
//start seed box
$seedBox = '';
$columnOperator = nexus_trans('label.seedbox_record.operator');
$columnBandwidth = nexus_trans('label.seedbox_record.bandwidth');
$columnIPBegin = nexus_trans('label.seedbox_record.ip_begin');
$columnIPEnd = nexus_trans('label.seedbox_record.ip_end');
$columnIP = nexus_trans('label.seedbox_record.ip');
$columnIPHelp = nexus_trans('label.seedbox_record.ip_help');
$columnOperator = nexus_trans('label.seed_box_record.operator');
$columnBandwidth = nexus_trans('label.seed_box_record.bandwidth');
$columnIPBegin = nexus_trans('label.seed_box_record.ip_begin');
$columnIPEnd = nexus_trans('label.seed_box_record.ip_end');
$columnIP = nexus_trans('label.seed_box_record.ip');
$columnIPHelp = nexus_trans('label.seed_box_record.ip_help');
$columnComment = nexus_trans('label.comment');
$res = sql_query(sprintf("SELECT * from seedbox_records where type = %s and uid = %s", \App\Models\SeedBoxRecord::TYPE_USER, $CURUSER['id']));
if (mysql_num_rows($res) > 0)
$columnStatus = nexus_trans('label.seed_box_record.status');
$res = \App\Models\SeedBoxRecord::query()->where('uid', $CURUSER['id'])->where('type', \App\Models\SeedBoxRecord::TYPE_USER)->get();
if ($res->count() > 0)
{
$seedBox .= "<table border='1' cellspacing='0' cellpadding='5' id='seed-box-table'><tr><td class='colhead'>{$columnOperator}</td><td class='colhead'>{$columnBandwidth}</td><td class='colhead'>{$columnIP}</td><td class='colhead'>{$columnComment}</td><td class='colhead'></td></tr>";
while($arr = mysql_fetch_assoc($res))
$seedBox .= "<table border='1' cellspacing='0' cellpadding='5' id='seed-box-table'><tr><td class='colhead'>ID</td><td class='colhead'>{$columnOperator}</td><td class='colhead'>{$columnBandwidth}</td><td class='colhead'>{$columnIP}</td><td class='colhead'>{$columnComment}</td><td class='colhead'>{$columnStatus}</td><td class='colhead'></td></tr>";
foreach ($res as $seedBoxRecord)
{
$seedBox .= "<tr>";
$seedBox .= sprintf('<td>%s</td>', $arr['operator']);
$seedBox .= sprintf('<td>%s</td>', $arr['bandwidth'] ?: '');
$seedBox .= sprintf('<td>%s</td>', $arr['ip'] ?: sprintf('%s ~ %s', $arr['ip_begin'], $arr['ip_end']));
$seedBox .= sprintf('<td>%s</td>', $arr['comment']);
$seedBox .= sprintf('<td><img style="cursor: pointer" class="staff_delete remove-seed-box-btn" src="pic/trans.gif" alt="D" title="%s" data-id="%s"></td>', $lang_functions['text_delete'], $arr['id']);
$seedBox .= sprintf('<td>%s</td>', $seedBoxRecord->id);
$seedBox .= sprintf('<td>%s</td>', $seedBoxRecord->operator);
$seedBox .= sprintf('<td>%s</td>', $seedBoxRecord->bandwidth ?: '');
$seedBox .= sprintf('<td>%s</td>', $seedBoxRecord->ip ?: sprintf('%s ~ %s', $seedBoxRecord->ip_begin, $seedBoxRecord->ip_end));
$seedBox .= sprintf('<td>%s</td>', $seedBoxRecord->comment);
$seedBox .= sprintf('<td>%s</td>', $seedBoxRecord->statusText);
$seedBox .= sprintf('<td><img style="cursor: pointer" class="staff_delete remove-seed-box-btn" src="pic/trans.gif" alt="D" title="%s" data-id="%s"></td>', $lang_functions['text_delete'], $seedBoxRecord->id);
$seedBox .= "</tr>";
}
$seedBox .= '</table>';
+4 -2
View File
@@ -201,14 +201,16 @@ if (get_user_class() >= $userprofile_class) {
tr_small($lang_userdetails['row_ip_history'], $lang_userdetails['text_user_earlier_used']."<b><a href=\"iphistory.php?id=" . $user['id'] . "\">" . $iphistory. $lang_userdetails['text_different_ips'].add_s($iphistory, true)."</a></b>", 1);
}
$seedBoxRep = new \App\Repositories\SeedBoxRepository();
if (get_user_class() >= $userprofile_class || $user["id"] == $CURUSER["id"])
{
$seedBoxIcon = $seedBoxRep->renderIcon($CURUSER['ip'], $CURUSER['id']);
if ($enablelocation_tweak == 'yes'){
list($loc_pub, $loc_mod) = get_ip_location($user['ip']);
$locationinfo = "<span title=\"" . $loc_mod . "\">[" . $loc_pub . "]</span>";
}
else $locationinfo = "";
tr_small($lang_userdetails['row_ip_address'], $user['ip'].$locationinfo, 1);
tr_small($lang_userdetails['row_ip_address'], $user['ip'].$locationinfo.$seedBoxIcon, 1);
}
$clientselect = '';
$res = sql_query("SELECT peer_id, agent, ipv4, ipv6, port FROM peers WHERE userid = {$user['id']} GROUP BY agent") or sqlerr();
@@ -220,7 +222,7 @@ if (mysql_num_rows($res) > 0)
$clientselect .= "<tr>";
$clientselect .= sprintf('<td>%s</td>', get_agent($arr['peer_id'], $arr['agent']));
if (get_user_class() >= $userprofile_class || $user["id"] == $CURUSER["id"]) {
$clientselect .= sprintf('<td>%s</td><td>%s</td><td>%s</td>', $arr['ipv4'], $arr['ipv6'], $arr['port']);
$clientselect .= sprintf('<td>%s</td><td>%s</td><td>%s</td>', $arr['ipv4'].$seedBoxRep->renderIcon($arr['ipv4'], $CURUSER['id']), $arr['ipv6'].$seedBoxRep->renderIcon($arr['ipv6'], $CURUSER['id']), $arr['port']);
} else {
$clientselect .= sprintf('<td>%s</td><td>%s</td><td>%s</td>', '---', '---', '---');
}
+19 -3
View File
@@ -10,13 +10,15 @@ header("Pragma: no-cache" );
header("Content-Type: text/xml; charset=utf-8");
$id = intval($_GET['id'] ?? 0);
$seedBoxRep = new \App\Repositories\SeedBoxRepository();
if(isset($CURUSER))
{
function dltable($name, $arr, $torrent)
{
global $lang_viewpeerlist,$viewanonymous_class,$userprofile_class,$enablelocation_tweak;
global $CURUSER;
global $lang_functions;
global $lang_functions, $seedBoxRep;
$s = "<b>" . count($arr) . " $name</b>\n";
if (!count($arr))
return $s;
@@ -56,8 +58,22 @@ function dltable($name, $arr, $torrent)
$secs = max(1, ($e["la"] - $e["st"]));
if ($enablelocation_tweak == 'yes'){
list($loc_pub, $loc_mod) = get_ip_location(sprintf('%s,%s', $e['ipv4'], $e['ipv6']));
$location = get_user_class() >= $userprofile_class ? "<div title='" . $loc_mod . "'>" . $loc_pub . "</div>" : $loc_pub;
$address = $ips = [];
if (!empty($e['ipv4'])) {
list($loc_pub, $loc_mod) = get_ip_location($e['ipv4']);
$seedBoxIcon = $seedBoxRep->renderIcon($e['ipv4'], $e['userid']);
$address[] = $loc_pub . $seedBoxIcon;
$ips[] = $e['ipv4'];
}
if (!empty($e['ipv6'])) {
list($loc_pub, $loc_mod) = get_ip_location($e['ipv6']);
$seedBoxIcon = $seedBoxRep->renderIcon($e['ipv6'], $e['userid']);
$address[] = $loc_pub . $seedBoxIcon;
$ips[] = $e['ipv6'];
}
$title = sprintf('%s%s%s', $lang_functions['text_user_ip'], ':&nbsp;', implode(', ', $ips));
$addressStr = implode(' + ', $address);
$location = get_user_class() >= $userprofile_class ? "<div title='" . $title . "'>" . $addressStr . "</div>" : $addressStr;
$s .= "<td class=rowfollow align=center width=1%><nobr>" . $location . "</nobr></td>\n";
}
elseif (get_user_class() >= $userprofile_class){