2020-12-26 01:42:23 +08:00
< ? php
2021-01-13 19:32:26 +08:00
require " ../include/bittorrent.php " ;
2020-12-26 01:42:23 +08:00
dbconn ();
require_once ( get_langfile_path ());
//Send some headers to keep the user's browser from caching the response.
2021-06-21 02:01:26 +08:00
header ( " Expires: Mon, 26 Jul 1997 05:00:00 GMT " );
header ( " Last-Modified: " . gmdate ( " D, d M Y H:i:s " ) . " GMT " );
header ( " Cache-Control: no-cache, must-revalidate " );
2020-12-26 01:42:23 +08:00
header ( " Pragma: no-cache " );
2021-06-22 15:55:52 +08:00
//header("Content-Type: text/xml; charset=utf-8");
2022-06-24 14:55:10 +08:00
$torrentRep = new \App\Repositories\TorrentRepository ();
2022-09-05 19:23:10 +08:00
$claimRep = new \App\Repositories\ClaimRepository ();
2022-10-16 04:52:44 +08:00
$seedBoxRep = new \App\Repositories\SeedBoxRepository ();
2022-09-06 20:56:08 +08:00
$claimTorrentTTL = \App\Models\Claim :: getConfigTorrentTTL ();
2022-06-27 13:22:16 +08:00
$id = intval ( $_GET [ 'userid' ] ? ? 0 );
2025-05-12 16:46:01 +07:00
$type = $_GET [ 'type' ] ? ? '' ;
2022-06-27 13:22:16 +08:00
if ( ! in_array ( $type , array ( 'uploaded' , 'seeding' , 'leeching' , 'completed' , 'incomplete' )))
die ;
2022-08-20 19:11:28 +08:00
if ( ! user_can ( 'torrenthistory' ) && $id != $CURUSER [ " id " ])
2022-06-27 13:22:16 +08:00
permissiondenied ();
2020-12-26 01:42:23 +08:00
function maketable ( $res , $mode = 'seeding' )
{
2022-06-27 13:22:16 +08:00
global $lang_getusertorrentlistajax , $CURUSER , $smalldescription_main , $lang_functions , $id ;
2022-10-16 04:52:44 +08:00
global $torrentRep , $claimRep , $claimTorrentTTL , $seedBoxRep ;
2022-10-14 20:48:42 +08:00
$showActionClaim = $showClient = false ;
2020-12-26 01:42:23 +08:00
switch ( $mode )
{
case 'uploaded' : {
$showsize = true ;
$showsenum = true ;
$showlenum = true ;
$showuploaded = true ;
$showdownloaded = false ;
$showratio = false ;
$showsetime = true ;
$showletime = false ;
$showcotime = false ;
$showanonymous = true ;
2021-06-21 09:55:20 +08:00
$showtotalsize = true ;
2020-12-26 01:42:23 +08:00
$columncount = 8 ;
break ;
}
case 'seeding' : {
$showsize = true ;
$showsenum = true ;
$showlenum = true ;
$showuploaded = true ;
$showdownloaded = true ;
$showratio = true ;
2022-09-02 19:49:41 +08:00
$showsetime = true ;
2020-12-26 01:42:23 +08:00
$showletime = false ;
$showcotime = false ;
$showanonymous = false ;
2021-06-21 09:55:20 +08:00
$showtotalsize = true ;
2020-12-26 01:42:23 +08:00
$columncount = 8 ;
2022-09-05 19:38:01 +08:00
$showActionClaim = true ;
2022-10-14 20:48:42 +08:00
$showClient = true ;
2020-12-26 01:42:23 +08:00
break ;
}
case 'leeching' : {
$showsize = true ;
$showsenum = true ;
$showlenum = true ;
$showuploaded = true ;
$showdownloaded = true ;
$showratio = true ;
$showsetime = false ;
$showletime = false ;
$showcotime = false ;
$showanonymous = false ;
2021-06-21 09:55:20 +08:00
$showtotalsize = true ;
2022-10-14 20:48:42 +08:00
$showClient = true ;
2020-12-26 01:42:23 +08:00
$columncount = 8 ;
break ;
}
case 'completed' : {
2022-09-02 00:07:11 +08:00
$showsize = true ;
2020-12-26 01:42:23 +08:00
$showsenum = false ;
$showlenum = false ;
$showuploaded = true ;
$showdownloaded = false ;
$showratio = false ;
$showsetime = true ;
$showletime = true ;
$showcotime = true ;
$showanonymous = false ;
2021-06-21 09:55:20 +08:00
$showtotalsize = false ;
2020-12-26 01:42:23 +08:00
$columncount = 8 ;
2022-09-05 19:23:10 +08:00
$showActionClaim = true ;
2020-12-26 01:42:23 +08:00
break ;
}
case 'incomplete' : {
2022-09-02 00:07:11 +08:00
$showsize = true ;
2020-12-26 01:42:23 +08:00
$showsenum = false ;
$showlenum = false ;
$showuploaded = true ;
$showdownloaded = true ;
$showratio = true ;
$showsetime = false ;
$showletime = true ;
$showcotime = false ;
$showanonymous = false ;
2021-06-21 09:55:20 +08:00
$showtotalsize = false ;
2020-12-26 01:42:23 +08:00
$columncount = 7 ;
break ;
}
default : break ;
}
2022-10-16 04:52:44 +08:00
$shouldShowClient = false ;
if ( $showClient && ( user_can ( 'userprofile' ) || $CURUSER [ 'id' ] == $id )) {
$shouldShowClient = true ;
}
2022-06-27 13:22:16 +08:00
$results = $torrentIdArr = [];
while ( $row = mysql_fetch_assoc ( $res )) {
$results [] = $row ;
$torrentIdArr [] = $row [ 'torrent' ];
}
if ( $mode == 'uploaded' ) {
//get seedtime, uploaded from snatch
$seedTimeAndUploaded = \App\Models\Snatch :: query ()
-> where ( 'userid' , $id )
-> whereIn ( 'torrentid' , $torrentIdArr )
-> select ([ 'seedtime' , 'uploaded' , 'torrentid' ])
-> get ()
-> keyBy ( 'torrentid' );
}
2022-09-05 19:23:10 +08:00
if ( $showActionClaim ) {
$claimData = \App\Models\Claim :: query ()
-> where ( 'uid' , $CURUSER [ 'id' ])
-> whereIn ( 'torrent_id' , $torrentIdArr )
-> get ()
-> keyBy ( 'torrent_id' );
}
2022-06-27 13:22:16 +08:00
2022-09-01 23:48:50 +08:00
$ret = " <table border= \" 1 \" cellspacing= \" 0 \" cellpadding= \" 5 \" width= \" 100% \" ><tr><td class= \" colhead \" style= \" padding: 0px \" > " . $lang_getusertorrentlistajax [ 'col_type' ] . " </td><td class= \" colhead \" align= \" center \" > " . $lang_getusertorrentlistajax [ 'col_name' ] . " </td><td class= \" colhead \" align= \" center \" > " . $lang_getusertorrentlistajax [ 'col_added' ] . " </td> " .
2022-09-05 19:23:10 +08:00
( $showsize ? " <td class= \" colhead \" align= \" center \" ><img class= \" size \" src= \" pic/trans.gif \" alt= \" size \" title= \" " . $lang_getusertorrentlistajax [ 'title_size' ] . " \" /></td> " : " " ) . ( $showsenum ? " <td class= \" colhead \" align= \" center \" ><img class= \" seeders \" src= \" pic/trans.gif \" alt= \" seeders \" title= \" " . $lang_getusertorrentlistajax [ 'title_seeders' ] . " \" /></td> " : " " ) . ( $showlenum ? " <td class= \" colhead \" align= \" center \" ><img class= \" leechers \" src= \" pic/trans.gif \" alt= \" leechers \" title= \" " . $lang_getusertorrentlistajax [ 'title_leechers' ] . " \" /></td> " : " " ) . ( $showuploaded ? " <td class= \" colhead \" align= \" center \" > " . $lang_getusertorrentlistajax [ 'col_uploaded' ] . " </td> " : " " ) . ( $showdownloaded ? " <td class= \" colhead \" align= \" center \" > " . $lang_getusertorrentlistajax [ 'col_downloaded' ] . " </td> " : " " ) . ( $showratio ? " <td class= \" colhead \" align= \" center \" > " . $lang_getusertorrentlistajax [ 'col_ratio' ] . " </td> " : " " ) . ( $showsetime ? " <td class= \" colhead \" align= \" center \" > " . $lang_getusertorrentlistajax [ 'col_se_time' ] . " </td> " : " " ) . ( $showletime ? " <td class= \" colhead \" align= \" center \" > " . $lang_getusertorrentlistajax [ 'col_le_time' ] . " </td> " : " " ) . ( $showcotime ? " <td class= \" colhead \" align= \" center \" > " . $lang_getusertorrentlistajax [ 'col_time_completed' ] . " </td> " : " " ) . ( $showanonymous ? " <td class= \" colhead \" align= \" center \" > " . $lang_getusertorrentlistajax [ 'col_anonymous' ] . " </td> " : " " );
2022-10-16 04:52:44 +08:00
if ( $shouldShowClient ) {
2022-10-14 20:48:42 +08:00
$ret .= sprintf ( '<td class="colhead" align="center">%s</td><td class="colhead" align="center">IP</td>' , $lang_getusertorrentlistajax [ 'col_client' ]);
}
2022-09-08 01:52:28 +08:00
$ret .= sprintf ( '<td class="colhead" align="center">%s</td>' , $lang_functions [ 'std_action' ]);
2022-09-05 19:23:10 +08:00
$ret .= " </tr> " ;
$total_size = 0 ;
2022-06-27 13:22:16 +08:00
foreach ( $results as $arr )
2020-12-26 01:42:23 +08:00
{
2022-06-27 13:22:16 +08:00
if ( $mode == 'uploaded' ) {
$seedTimeAndUploadedData = $seedTimeAndUploaded -> get ( $arr [ 'torrent' ]);
$arr [ 'seedtime' ] = $seedTimeAndUploadedData ? $seedTimeAndUploadedData -> seedtime : 0 ;
$arr [ 'uploaded' ] = $seedTimeAndUploadedData ? $seedTimeAndUploadedData -> uploaded : 0 ;
}
2020-12-26 01:42:23 +08:00
$catimage = htmlspecialchars ( $arr [ " image " ]);
$catname = htmlspecialchars ( $arr [ " catname " ]);
$sphighlight = get_torrent_bg_color ( $arr [ 'sp_state' ]);
2022-06-14 01:07:05 +08:00
$banned_torrent = ( $arr [ " banned " ] == 'yes' ? " <b>(<font class= \" striking \" > " . $lang_functions [ 'text_banned' ] . " </font>)</b> " : " " );
2022-06-08 14:15:59 +08:00
$sp_torrent = get_torrent_promotion_append ( $arr [ 'sp_state' ], '' , false , '' , 0 , '' , $arr [ '__ignore_global_sp_state' ] ? ? false );
2021-06-21 09:55:20 +08:00
//Total size
if ( $showtotalsize ){
$total_size += $arr [ 'size' ];
}
2022-10-01 03:08:57 +08:00
$hrImg = get_hr_img ( $arr , $arr [ 'search_box_id' ]);
2022-06-24 14:55:10 +08:00
$approvalStatusIcon = $torrentRep -> renderApprovalStatus ( $arr [ " approval_status " ]);
2020-12-26 01:42:23 +08:00
//torrent name
$dispname = $nametitle = htmlspecialchars ( $arr [ " torrentname " ]);
$count_dispname = mb_strlen ( $dispname , " UTF-8 " );
$max_lenght_of_torrent_name = ( $CURUSER [ 'fontsize' ] == 'large' ? 70 : 80 );
if ( $count_dispname > $max_lenght_of_torrent_name )
$dispname = mb_substr ( $dispname , 0 , $max_lenght_of_torrent_name , " UTF-8 " ) . " .. " ;
if ( $smalldescription_main == 'yes' ){
//small description
$dissmall_descr = htmlspecialchars ( trim ( $arr [ " small_descr " ]));
$count_dissmall_descr = mb_strlen ( $dissmall_descr , " UTF-8 " );
$max_lenght_of_small_descr = 80 ; // maximum length
if ( $count_dissmall_descr > $max_lenght_of_small_descr )
{
$dissmall_descr = mb_substr ( $dissmall_descr , 0 , $max_lenght_of_small_descr , " UTF-8 " ) . " .. " ;
}
}
else $dissmall_descr == " " ;
$ret .= " <tr " . $sphighlight . " ><td class= \" rowfollow nowrap \" valign= \" middle \" style='padding: 0px'> " . return_category_image ( $arr [ 'category' ], " torrents.php?allsec=1& " ) . " </td> \n " .
2022-06-24 14:55:10 +08:00
" <td class= \" rowfollow \" width= \" 100% \" align= \" left \" ><a href= \" " . htmlspecialchars ( " details.php?id= " . $arr [ 'torrent' ] . " &hit=1 " ) . " \" title= \" " . $nametitle . " \" ><b> " . $dispname . " </b></a> " . $banned_torrent . $sp_torrent . $hrImg . $approvalStatusIcon . ( $dissmall_descr == " " ? " " : " <br /> " . $dissmall_descr ) . " </td> " ;
2022-09-01 23:48:50 +08:00
$ret .= sprintf ( '<td class="rowfollow nowrap" align="center">%s<br/>%s</td>' , substr ( $arr [ 'added' ], 0 , 10 ), substr ( $arr [ 'added' ], 11 ));
2020-12-26 01:42:23 +08:00
//size
if ( $showsize )
$ret .= " <td class= \" rowfollow \" align= \" center \" > " . mksize_compact ( $arr [ 'size' ]) . " </td> " ;
//number of seeders
if ( $showsenum )
$ret .= " <td class= \" rowfollow \" align= \" center \" > " . $arr [ 'seeders' ] . " </td> " ;
//number of leechers
if ( $showlenum )
$ret .= " <td class= \" rowfollow \" align= \" center \" > " . $arr [ 'leechers' ] . " </td> " ;
//uploaded amount
if ( $showuploaded ){
$uploaded = mksize_compact ( $arr [ " uploaded " ]);
$ret .= " <td class= \" rowfollow \" align= \" center \" > " . $uploaded . " </td> " ;
}
//downloaded amount
if ( $showdownloaded ){
$downloaded = mksize_compact ( $arr [ " downloaded " ]);
$ret .= " <td class= \" rowfollow \" align= \" center \" > " . $downloaded . " </td> " ;
}
//ratio
if ( $showratio ){
if ( $arr [ 'downloaded' ] > 0 )
{
$ratio = number_format ( $arr [ 'uploaded' ] / $arr [ 'downloaded' ], 3 );
$ratio = " <font color= \" " . get_ratio_color ( $ratio ) . " \" > " . $ratio . " </font> " ;
}
elseif ( $arr [ 'uploaded' ] > 0 ) $ratio = " Inf. " ;
else $ratio = " --- " ;
$ret .= " <td class= \" rowfollow \" align= \" center \" > " . $ratio . " </td> " ;
}
if ( $showsetime ){
$ret .= " <td class= \" rowfollow \" align= \" center \" > " . mkprettytime ( $arr [ 'seedtime' ]) . " </td> " ;
}
if ( $showletime ){
$ret .= " <td class= \" rowfollow \" align= \" center \" > " . mkprettytime ( $arr [ 'leechtime' ]) . " </td> " ;
}
if ( $showcotime )
$ret .= " <td class= \" rowfollow \" align= \" center \" > " . " " . str_replace ( " " , " <br /> " , gettime ( $arr [ 'completedat' ], false )) . " </td> " ;
if ( $showanonymous )
$ret .= " <td class= \" rowfollow \" align= \" center \" > " . $arr [ 'anonymous' ] . " </td> " ;
2022-10-16 04:52:44 +08:00
if ( $shouldShowClient ) {
2022-10-14 20:48:42 +08:00
$ipArr = array_filter ([ $arr [ 'ipv4' ], $arr [ 'ipv6' ]]);
2022-10-16 04:52:44 +08:00
foreach ( $ipArr as & $_ip ) {
$_ip = sprintf ( '<span class="nowrap">%s</span>' , $_ip . $seedBoxRep -> renderIcon ( $_ip , $arr [ 'userid' ]));
}
2022-10-14 20:48:42 +08:00
$ret .= sprintf (
'<td class="rowfollow" align="center">%s<br/>%s</td><td class="rowfollow" align="center">%s</td>' ,
get_agent ( $arr [ 'peer_id' ], $arr [ 'agent' ]), $arr [ 'port' ],
implode ( '<br/>' , $ipArr )
);
}
2022-09-06 20:56:08 +08:00
$claimButton = '' ;
2022-09-08 01:42:59 +08:00
if (
$showActionClaim
&& \App\Models\Claim :: getConfigIsEnabled ()
&& \Carbon\Carbon :: parse ( $arr [ 'added' ]) -> addDays ( $claimTorrentTTL ) -> lte ( \Carbon\Carbon :: now ())
) {
$claim = $claimData -> get ( $arr [ 'torrent' ]);
if ( $CURUSER [ 'id' ] == $arr [ 'userid' ]) {
$claimButton = $claimRep -> buildActionButtons ( $arr [ 'torrent' ], $claim );
} else {
if ( $claim ) {
$claimText = nexus_trans ( 'claim.already_claimed' );
} else {
$claimText = nexus_trans ( 'claim.not_claim_yet' );
}
$claimButton = sprintf ( '<button style="width: max-content;display: flex;align-items: center" disabled>%s</button>' , $claimText );
}
2022-09-05 19:23:10 +08:00
}
2022-09-06 20:56:08 +08:00
$ret .= sprintf ( '<td class="rowfollow" align="center">%s</td>' , $claimButton );
2020-12-26 01:42:23 +08:00
$ret .= " </tr> \n " ;
2021-06-21 02:01:26 +08:00
2020-12-26 01:42:23 +08:00
}
$ret .= " </table> \n " ;
2021-06-22 15:55:52 +08:00
return [ $ret , $total_size ];
2020-12-26 01:42:23 +08:00
}
2022-09-01 23:48:50 +08:00
$count = 0 ;
2024-09-25 00:00:21 +08:00
$torrentlist = $pagertop = $pagerbottom = " " ;
2020-12-26 01:42:23 +08:00
switch ( $type )
{
case 'uploaded' :
{
2022-06-27 13:22:16 +08:00
// $res = sql_query("SELECT torrents.id AS torrent, torrents.name as torrentname, small_descr, seeders, leechers, anonymous, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, snatched.seedtime, snatched.uploaded FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories ON torrents.category = categories.id WHERE torrents.owner=$id AND snatched.userid=$id " . (($CURUSER["id"] != $id)?((get_user_class() < $viewanonymous_class) ? " AND anonymous = 'no'":""):"") ." ORDER BY torrents.added DESC") or sqlerr(__FILE__, __LINE__);
2022-09-01 23:48:50 +08:00
// $res = sql_query("SELECT torrents.id AS torrent, torrents.name as torrentname, small_descr, seeders, leechers, anonymous, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, torrents.added FROM torrents LEFT JOIN categories ON torrents.category = categories.id WHERE torrents.owner=$id " . (($CURUSER["id"] != $id)?((!user_can('viewanonymous')) ? " AND anonymous = 'no'":""):"") ." ORDER BY torrents.id DESC") or sqlerr(__FILE__, __LINE__);
2022-10-01 03:08:57 +08:00
$fields = " torrents.id AS torrent, torrents.name as torrentname, small_descr, seeders, leechers, anonymous, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, torrents.added,torrents.owner as userid, categories.mode as search_box_id " ;
2022-09-01 23:48:50 +08:00
$tableWhere = " torrents LEFT JOIN categories ON torrents.category = categories.id WHERE torrents.owner= $id " ;
if ( $CURUSER [ 'id' ] != $id && ! user_can ( 'viewanonymous' )) {
$tableWhere .= " AND anonymous = 'no' " ;
}
$order = " torrents.id DESC " ;
2020-12-26 01:42:23 +08:00
break ;
}
// Current Seeding
case 'seeding' :
{
2022-09-01 23:48:50 +08:00
// $res = sql_query("SELECT torrent,added,snatched.uploaded,snatched.downloaded,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, torrents.banned, torrents.approval_status, categories.name as catname,size,torrents.hr,image,category,seeders,leechers FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='yes' ORDER BY torrents.id DESC") or sqlerr();
2022-10-14 20:48:42 +08:00
$fields = " torrent,added,snatched.uploaded,snatched.downloaded,snatched.seedtime,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, torrents.banned, torrents.approval_status, categories.name as catname,size,torrents.hr,image,category,seeders,leechers,snatched.userid, categories.mode as search_box_id, peers.peer_id, peers.agent, peers.port, peers.ipv4, peers.ipv6 " ;
2022-09-01 23:48:50 +08:00
$tableWhere = " peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid= $id AND snatched.userid = $id AND peers.seeder='yes' " ;
2024-12-24 01:10:48 +08:00
$order = " peers.id DESC " ;
2020-12-26 01:42:23 +08:00
break ;
}
// Current Leeching
case 'leeching' :
{
2022-09-01 23:48:50 +08:00
// $res = sql_query("SELECT torrent,snatched.uploaded,snatched.downloaded,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, torrents.banned, torrents.approval_status, categories.name as catname,size,torrents.hr,image,category,seeders,leechers, torrents.added FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='no' ORDER BY torrents.id DESC") or sqlerr();
2022-10-14 20:48:42 +08:00
$fields = " torrent,snatched.uploaded,snatched.downloaded,snatched.seedtime,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, torrents.banned, torrents.approval_status, categories.name as catname,size,torrents.hr,image,category,seeders,leechers, torrents.added,snatched.userid, categories.mode as search_box_id, peers.peer_id, peers.agent, peers.port, peers.ipv4, peers.ipv6 " ;
2022-09-01 23:48:50 +08:00
$tableWhere = " peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid= $id AND snatched.userid = $id AND peers.seeder='no' " ;
2024-12-24 01:10:48 +08:00
$order = " peers.id DESC " ;
2020-12-26 01:42:23 +08:00
break ;
}
// Completed torrents
case 'completed' :
{
2022-09-01 23:48:50 +08:00
// $res = sql_query("SELECT torrents.id AS torrent, torrents.name AS torrentname, small_descr, categories.name AS catname, torrents.banned, torrents.approval_status, categories.image, category, sp_state, size, torrents.hr, torrents.added,snatched.uploaded, snatched.seedtime, snatched.leechtime, snatched.completedat FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='yes' AND torrents.owner != $id AND userid=$id ORDER BY snatched.id DESC") or sqlerr();
2022-10-01 03:08:57 +08:00
$fields = " torrents.id AS torrent, torrents.name AS torrentname, small_descr, categories.name AS catname, torrents.banned, torrents.approval_status, categories.image, category, sp_state, size, torrents.hr, torrents.added,snatched.uploaded, snatched.seedtime,snatched.uploaded, snatched.leechtime, snatched.completedat,snatched.userid, categories.mode as search_box_id " ;
2022-09-01 23:48:50 +08:00
$tableWhere = " torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='yes' AND userid= $id AND torrents.owner != $id " ;
$order = " snatched.id DESC " ;
2020-12-26 01:42:23 +08:00
break ;
}
// Incomplete torrents
case 'incomplete' :
{
2022-09-05 19:23:10 +08:00
// $res = sql_query("SELECT torrents.id AS torrent, torrents.name AS torrentname, small_descr, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, torrents.added,snatched.uploaded, snatched.downloaded, snatched.leechtime FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='no' AND userid=$id AND torrents.owner != $id ORDER BY snatched.id DESC") or sqlerr();
2022-10-14 20:48:42 +08:00
$fields = " torrents.id AS torrent, torrents.name AS torrentname, small_descr, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, torrents.added,snatched.uploaded, snatched.downloaded, snatched.leechtime,snatched.seedtime,snatched.userid, categories.mode as search_box_id " ;
2022-09-01 23:48:50 +08:00
$tableWhere = " torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='no' AND userid= $id AND torrents.owner != $id " ;
$order = " snatched.id DESC " ;
2020-12-26 01:42:23 +08:00
break ;
}
}
2022-09-01 23:48:50 +08:00
if ( isset ( $tableWhere )) {
$cacheKey = sprintf ( 'user:%s:type:%s:total_size' , $id , $type );
$page = $_GET [ 'page' ] ? ? 0 ;
$sumSql = " select count(*) as count, sum(torrents.size) as total_size from $tableWhere limit 1 " ;
if ( $page == 0 ) {
$sumRes = mysql_fetch_assoc ( sql_query ( $sumSql ));
\Nexus\Database\NexusDB :: cache_put ( $cacheKey , $sumRes );
} else {
$sumRes = \Nexus\Database\NexusDB :: remember ( $cacheKey , 3600 , function () use ( $sumSql ) {
return mysql_fetch_assoc ( sql_query ( $sumSql ));
});
}
$count = $sumRes [ 'count' ];
$total_size = $sumRes [ 'total_size' ];
}
if ( $count > 0 && isset ( $tableWhere , $fields , $order ))
{
$pageSize = 100 ;
list ( $pagertop , $pagerbottom , $limit ) = pager ( $pageSize , $count , " getusertorrentlistajax.php? " );
$sql = " select $fields from $tableWhere order by $order $limit " ;
do_log ( " count: $count , list sql: $sql " );
$res = sql_query ( $sql );
list ( $torrentlist , $total_size_this_page ) = maketable ( $res , $type );
}
2023-03-13 17:41:03 +08:00
$table = $pagertop . $torrentlist . $pagerbottom ;
$hasData = false ;
$summary = sprintf ( '<b>%s</b>%s' , $count , $lang_getusertorrentlistajax [ 'text_record' ] . add_s ( $count ));
2021-12-14 16:22:03 +08:00
if ( isset ( $total_size ) && $total_size ){
2023-03-13 17:41:03 +08:00
$hasData = true ;
$summary .= $lang_getusertorrentlistajax [ 'text_total_size' ] . mksize ( $total_size );
} elseif ( $count ) {
$hasData = true ;
}
if ( $hasData ) {
2023-04-09 16:33:36 +08:00
$btnArr = apply_filter ( " user_seeding_top_btn " , [], $CURUSER [ 'id' ]);
$header = sprintf ( '<div style="display: flex;justify-content: space-between"><div>%s</div><div>%s</div></div>' , $summary , implode ( " " , $btnArr ));
2023-03-13 17:41:03 +08:00
echo '<br/>' . $header . $table ;
2021-12-14 16:22:03 +08:00
} else {
echo $lang_getusertorrentlistajax [ 'text_no_record' ];
2021-06-21 09:55:20 +08:00
}
2023-03-13 17:41:03 +08:00
2020-12-26 01:42:23 +08:00
?>