mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
Merge remote-tracking branch 'refs/remotes/origin/php8' into php8
This commit is contained in:
@@ -3021,7 +3021,7 @@ function get_torrent_bookmark_state($userid, $torrentid, $text = false)
|
|||||||
return $act;
|
return $act;
|
||||||
}
|
}
|
||||||
|
|
||||||
function torrenttable($res, $variant = "torrent") {
|
function torrenttable($rows, $variant = "torrent") {
|
||||||
global $Cache;
|
global $Cache;
|
||||||
global $lang_functions;
|
global $lang_functions;
|
||||||
global $CURUSER, $waitsystem;
|
global $CURUSER, $waitsystem;
|
||||||
@@ -3037,6 +3037,8 @@ function torrenttable($res, $variant = "torrent") {
|
|||||||
} elseif ($enableImdb) {
|
} elseif ($enableImdb) {
|
||||||
$imdb = new Nexus\Imdb\Imdb();
|
$imdb = new Nexus\Imdb\Imdb();
|
||||||
}
|
}
|
||||||
|
$torrent = new Nexus\Torrent\Torrent();
|
||||||
|
$torrentSeedingLeechingStatus = $torrent->listLeechingSeedingStatus($CURUSER['id'], array_column($rows, 'id'));
|
||||||
|
|
||||||
if ($variant == "torrent"){
|
if ($variant == "torrent"){
|
||||||
$last_browse = $CURUSER['last_browse'];
|
$last_browse = $CURUSER['last_browse'];
|
||||||
@@ -3132,7 +3134,8 @@ $counter = 0;
|
|||||||
if ($smalldescription_main == 'no' || $CURUSER['showsmalldescr'] == 'no')
|
if ($smalldescription_main == 'no' || $CURUSER['showsmalldescr'] == 'no')
|
||||||
$displaysmalldescr = false;
|
$displaysmalldescr = false;
|
||||||
else $displaysmalldescr = true;
|
else $displaysmalldescr = true;
|
||||||
while ($row = mysql_fetch_assoc($res))
|
//while ($row = mysql_fetch_assoc($res))
|
||||||
|
foreach ($rows as $row)
|
||||||
{
|
{
|
||||||
$id = $row["id"];
|
$id = $row["id"];
|
||||||
$sphighlight = get_torrent_bg_color($row['sp_state']);
|
$sphighlight = get_torrent_bg_color($row['sp_state']);
|
||||||
@@ -3234,6 +3237,9 @@ while ($row = mysql_fetch_assoc($res))
|
|||||||
print($dissmall_descr == "" ? "" : "<br />".$tags.htmlspecialchars($dissmall_descr));
|
print($dissmall_descr == "" ? "" : "<br />".$tags.htmlspecialchars($dissmall_descr));
|
||||||
} else {
|
} else {
|
||||||
print("<br />$tags");
|
print("<br />$tags");
|
||||||
|
}
|
||||||
|
if (isset($torrentSeedingLeechingStatus[$row['id']])) {
|
||||||
|
print('<div style="padding: 1px;margin-top: 2px;width: 100%;border: 1px solid #838383" title="' . $torrentSeedingLeechingStatus[$row['id']]['progress'] . '"><div style="width: 50%;background-color: red;height: 2px"></div></div>');
|
||||||
}
|
}
|
||||||
print("</td>");
|
print("</td>");
|
||||||
if ($enablePtGen && !empty($row['pt_gen'])) {
|
if ($enablePtGen && !empty($row['pt_gen'])) {
|
||||||
|
|||||||
@@ -187,4 +187,24 @@ class DB
|
|||||||
return mysql_fetch_assoc($res);
|
return mysql_fetch_assoc($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getAll($table, $whereStr, $fields = '*')
|
||||||
|
{
|
||||||
|
if ($fields != '*') {
|
||||||
|
if (is_array($fields)) {
|
||||||
|
$fields = implode(', ', $fields);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($fields)) {
|
||||||
|
do_log("args: " . json_encode(func_get_args()));
|
||||||
|
throw new DatabaseException("empty fields.");
|
||||||
|
}
|
||||||
|
$sql = "select $fields from $table where $whereStr";
|
||||||
|
$res = sql_query($sql);
|
||||||
|
$result = [];
|
||||||
|
while ($row = mysql_fetch_assoc($res)) {
|
||||||
|
$result[] = $row;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,10 +8,10 @@ class TechnicalInformation
|
|||||||
|
|
||||||
private $mediaInfoArr;
|
private $mediaInfoArr;
|
||||||
|
|
||||||
public function __construct(string $mediaInfo)
|
public function __construct($mediaInfo)
|
||||||
{
|
{
|
||||||
$this->mediaInfo = $mediaInfo;
|
$this->mediaInfo = (string)$mediaInfo;
|
||||||
$this->mediaInfoArr = $this->getMediaInfoArr($mediaInfo);
|
$this->mediaInfoArr = $this->getMediaInfoArr((string)$mediaInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMediaInfoArr(string $mediaInfo)
|
public function getMediaInfoArr(string $mediaInfo)
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Nexus\Torrent;
|
||||||
|
|
||||||
|
use Nexus\Database\DB;
|
||||||
|
|
||||||
|
class Torrent
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* get torrent seeching or downloading status, download progress for someone
|
||||||
|
*
|
||||||
|
* @param int $uid
|
||||||
|
* @param array $torrentIdArr
|
||||||
|
* @return array
|
||||||
|
* @throws \Nexus\Database\DatabaseException
|
||||||
|
*/
|
||||||
|
public function listLeechingSeedingStatus(int $uid, array $torrentIdArr)
|
||||||
|
{
|
||||||
|
$torrentIdStr = implode(',', $torrentIdArr);
|
||||||
|
//seeding or leeching, from peers
|
||||||
|
$whereStr = sprintf("userid = %s and torrent in (%s)", sqlesc($uid), $torrentIdStr);
|
||||||
|
$peerList = DB::getAll('peers', $whereStr, 'torrent, to_go');
|
||||||
|
$peerList = array_column($peerList,'to_go', 'torrent');
|
||||||
|
//download progress, from snatched
|
||||||
|
$sql = sprintf(
|
||||||
|
"select snatched.finished, snatched.to_go, snatched.torrentid, torrents.size from snatched inner join torrents on snatched.torrentid = torrents.id where snatched.userid = %s and snatched.torrentid in (%s)",
|
||||||
|
sqlesc($uid), $torrentIdStr
|
||||||
|
);
|
||||||
|
$snatchedList = [];
|
||||||
|
$res = sql_query($sql);
|
||||||
|
while ($row = mysql_fetch_assoc($res)) {
|
||||||
|
$id = $row['torrentid'];
|
||||||
|
$activeStatus = 'none';
|
||||||
|
if (isset($peerList[$id])) {
|
||||||
|
if ($peerList[$id]['to_go'] == 0) {
|
||||||
|
$activeStatus = 'seeding';
|
||||||
|
} else {
|
||||||
|
$activeStatus = 'leeching';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$realDownloaded = $row['size'] - $row['to_go'];
|
||||||
|
$progress = sprintf('%.4f', $realDownloaded / $row['size']);
|
||||||
|
$snatchedList[$id] = [
|
||||||
|
'finished' => $row['to_go'] == 0 ? 'yes' : 'no',
|
||||||
|
'progress' => $progress,
|
||||||
|
'active_status' => $activeStatus,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return $snatchedList;
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-3
@@ -1086,12 +1086,16 @@ elseif($inclbookmarked == 2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($count) {
|
if ($count) {
|
||||||
|
$rows = [];
|
||||||
|
while ($row = mysql_fetch_assoc($res)) {
|
||||||
|
$rows[] = $row;
|
||||||
|
}
|
||||||
print($pagertop);
|
print($pagertop);
|
||||||
if ($sectiontype == $browsecatmode)
|
if ($sectiontype == $browsecatmode)
|
||||||
torrenttable($res, "torrents");
|
torrenttable($rows, "torrents");
|
||||||
elseif ($sectiontype == $specialcatmode)
|
elseif ($sectiontype == $specialcatmode)
|
||||||
torrenttable($res, "music");
|
torrenttable($rows, "music");
|
||||||
else torrenttable($res, "bookmarks");
|
else torrenttable($rows, "bookmarks");
|
||||||
print($pagerbottom);
|
print($pagerbottom);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user