function Clean_Free($id, $state, $endtime) { if ($state != "1" && $endtime != "0000-00-00 00:00:00") { if ($endtime < date("Y-m-d H:i:s", time())) { sql_query("UPDATE torrents SET sp_state = '1' WHERE id=" . sqlesc($id)) or sqlerr(__FILE__, __LINE__); return true; } } else { return false; } } // check torrent based on info_hash if (!($torrent = $Cache->get_value('torrent_hash_' . $info_hash . '_content'))) { $res = sql_query("SELECT id, owner, sp_state, endfree, seeders, leechers, UNIX_TIMESTAMP(added) AS ts, banned FROM torrents WHERE " . hash_where("info_hash", $info_hash)); $torrent = mysql_fetch_array($res); if (Clean_Free($torrent['id'], $torrent['sp_state'], $torrent['endfree'])) { $torrent['sp_state'] = "1"; } $Cache->cache_value('torrent_hash_' . $info_hash . '_content', $torrent, 350); } if (!$torrent) { err("torrent not registered with this tracker"); } elseif ($torrent['banned'] == 'yes' && $az['class'] < $seebanned_class) { err("torrent banned"); } // select peers info from peers table for this torrent $torrentid = $torrent["id"]; $numpeers = $torrent["seeders"] + $torrent["leechers"]; if ($seeder == 'yes') { //Don't report seeds to other seeders $only_leech_query = " AND seeder = 'no' ";
function torrenttable($res, $variant = "torrent", $mode = "normal") { global $Cache; global $lang_functions; global $CURUSER, $waitsystem; global $showextinfo; global $torrentmanage_class, $smalldescription_main, $enabletooltip_tweak; global $CURLANGDIR; if ($variant == "torrent"){ $last_browse = $CURUSER['last_browse']; $sectiontype = $browsecatmode; } elseif($variant == "music"){ $last_browse = $CURUSER['last_music']; $sectiontype = $specialcatmode; } else{ $last_browse = $CURUSER['last_browse']; $sectiontype = ""; } $time_now = TIMENOW; if ($last_browse > $time_now) { $last_browse=$time_now; } if (get_user_class() < UC_VIP && $waitsystem == "yes") { $ratio = get_ratio($CURUSER["id"], false); $gigs = $CURUSER["uploaded"] / (1024*1024*1024); if($gigs > 10) { if ($ratio < 0.4) $wait = 24; elseif ($ratio < 0.5) $wait = 12; elseif ($ratio < 0.6) $wait = 6; elseif ($ratio < 0.8) $wait = 3; else $wait = 0; } else $wait = 0; } ?> <table class="torrents" cellspacing="0" cellpadding="5" width="100%"> <tr> <?php $count_get = 0; $oldlink = ""; foreach ($_GET as $get_name => $get_value) { $get_name = mysql_real_escape_string(strip_tags(str_replace(array("\"","'"),array("",""),$get_name))); $get_value = mysql_real_escape_string(strip_tags(str_replace(array("\"","'"),array("",""),$get_value))); if ($get_name != "sort" && $get_name != "type") { if ($count_get > 0) { $oldlink .= "&" . $get_name . "=" . $get_value; } else { $oldlink .= $get_name . "=" . $get_value; } $count_get++; } } if ($count_get > 0) { $oldlink = $oldlink . "&"; } $sort = $_GET['sort']; $link = array(); for ($i=1; $i<=9; $i++){ if ($sort == $i) $link[$i] = ($_GET['type'] == "desc" ? "asc" : "desc"); else $link[$i] = ($i == 1 ? "asc" : "desc"); } ?> <td class="colhead" style="padding: 0px"><?php echo $lang_functions['col_type'] ?></td> <td class="colhead"><a href="?<?php echo $oldlink?>sort=1&type=<?php echo $link[1]?>"><?php echo $lang_functions['col_name'] ?></a></td> <?php if ($wait) { print("<td class=\"colhead\">".$lang_functions['col_wait']."</td>\n"); } if ($CURUSER['showcomnum'] != 'no') { ?> <td class="colhead"><a href="?<?php echo $oldlink?>sort=3&type=<?php echo $link[3]?>"><img class="comments" src="pic/trans.gif" alt="comments" title="<?php echo $lang_functions['title_number_of_comments'] ?>" /></a></td> <?php } ?> <td class="colhead"><a href="?<?php echo $oldlink?>sort=4&type=<?php echo $link[4]?>"><img class="time" src="pic/trans.gif" alt="time" title="<?php echo ($CURUSER['timetype'] != 'timealive' ? $lang_functions['title_time_added'] : $lang_functions['title_time_alive'])?>" /></a></td> <td class="colhead"><a href="?<?php echo $oldlink?>sort=5&type=<?php echo $link[5]?>"><img class="size" src="pic/trans.gif" alt="size" title="<?php echo $lang_functions['title_size'] ?>" /></a></td> <td class="colhead"><a href="?<?php echo $oldlink?>sort=7&type=<?php echo $link[7]?>"><img class="seeders" src="pic/trans.gif" alt="seeders" title="<?php echo $lang_functions['title_number_of_seeders'] ?>" /></a></td> <td class="colhead"><a href="?<?php echo $oldlink?>sort=8&type=<?php echo $link[8]?>"><img class="leechers" src="pic/trans.gif" alt="leechers" title="<?php echo $lang_functions['title_number_of_leechers'] ?>" /></a></td> <td class="colhead"><a href="?<?php echo $oldlink?>sort=6&type=<?php echo $link[6]?>"><img class="snatched" src="pic/trans.gif" alt="snatched" title="<?php echo $lang_functions['title_number_of_snatched']?>" /></a></td> <td class="colhead"><a href="?<?php echo $oldlink?>sort=9&type=<?php echo $link[9]?>"><?php echo $lang_functions['col_uploader']?></a></td> <?php if (get_user_class() >= $torrentmanage_class) { echo '<td class="colhead"></td>'; } if (get_user_class() >= $torrentmanage_class) { ?> <td class="colhead"><?php echo $lang_functions['col_action'] ?></td> <?php } ?> </tr> <?php $caticonrow = get_category_icon_row($CURUSER['caticon']); if ($caticonrow['secondicon'] == 'yes') $has_secondicon = true; else $has_secondicon = false; $counter = 0; if ($smalldescription_main == 'no' || $CURUSER['showsmalldescr'] == 'no') $displaysmalldescr = false; else $displaysmalldescr = true; while ($row = mysql_fetch_assoc($res)) { $id = $row["id"]; $sphighlight = get_torrent_bg_color($row['sp_state']); print("<tr" . $sphighlight . ">\n"); print("<td class=\"rowfollow nowrap\" valign=\"middle\" style='padding: 0px'>"); if (isset($row["category"])) { print(return_category_image($row["category"], "?")); print(return_sec_category_image($row['category'],$row["source"], "?"));//二级分类 if ($has_secondicon){ print(get_second_icon($row, "pic/".$catimgurl."additional/")); } } else print("-"); print("</td>\n"); //torrent name $dispname = trim($row["name"]); $short_torrent_name_alt = ""; $mouseovertorrent = ""; $tooltipblock = ""; $has_tooltip = false; if ($enabletooltip_tweak == 'yes') $tooltiptype = $CURUSER['tooltip']; else $tooltiptype = 'off'; switch ($tooltiptype){ case 'minorimdb' : { if ($showextinfo['imdb'] == 'yes' && $row["url"]) { $url = $row['url']; $cache = $row['cache_stamp']; $type = 'minor'; $has_tooltip = true; } break; } case 'medianimdb' : { if ($showextinfo['imdb'] == 'yes' && $row["url"]) { $url = $row['url']; $cache = $row['cache_stamp']; $type = 'median'; $has_tooltip = true; } break; } case 'off' : break; } if (!$has_tooltip) $short_torrent_name_alt = "title=\"".htmlspecialchars($dispname)."\""; else{ $torrent_tooltip[$counter]['id'] = "torrent_" . $counter; $torrent_tooltip[$counter]['content'] = ""; $mouseovertorrent = "onmouseover=\"get_ext_info_ajax('".$torrent_tooltip[$counter]['id']."','".$url."','".$cache."','".$type."'); domTT_activate(this, event, 'content', document.getElementById('" . $torrent_tooltip[$counter]['id'] . "'), 'trail', false, 'delay',600,'lifetime',6000,'fade','both','styleClass','niceTitle', 'fadeMax',87, 'maxWidth', 500);\""; } $count_dispname=mb_strlen($dispname,"UTF-8"); if (!$displaysmalldescr || $row["small_descr"] == "")// maximum length of torrent name $max_length_of_torrent_name = 150; elseif ($CURUSER['fontsize'] == 'large') $max_length_of_torrent_name = 85; elseif ($CURUSER['fontsize'] == 'small') $max_length_of_torrent_name = 100; else $max_length_of_torrent_name = 90; if($count_dispname > $max_length_of_torrent_name) $dispname=mb_substr($dispname, 0, $max_length_of_torrent_name-2,"UTF-8") . ".."; if ($row['pos_state'] == 'sticky' && $CURUSER['appendsticky'] == 'yes') $stickyicon = "<img class=\"sticky\" src=\"pic/trans.gif\" alt=\"Sticky\" title=\"".$lang_functions['title_sticky']."至".$row['endsticky']."\" /> "; else $stickyicon = ""; print("<td class=\"rowfollow\" width=\"100%\" align=\"left\"><table class=\"torrentname\" width=\"100%\"><tr" . $sphighlight . "><td class=\"embedded\">".$stickyicon."<a $short_torrent_name_alt $mouseovertorrent href=\"details.php?id=".$id."&hit=1\"><b>".htmlspecialchars($dispname)."</b></a>"); //判断种子免费置顶时间到期 if(Clean_Free($row['id'],$row['sp_state'],$row['endfree'])) $row['sp_state'] = "1"; if(Clean_Sticky($row['id'],$row['pos_state'],$row['endsticky'])) $row['pos_state'] = "normal"; $sp_torrent = get_torrent_promotion_append($row['sp_state'],"",true,$row["endfree"], $row['promotion_time_type'], $row['promotion_until']); $picked_torrent = ""; if ($CURUSER['appendpicked'] != 'no'){ if($row['picktype']=="hot") $picked_torrent = " <b>[<font class='hot'>".$lang_functions['text_hot']."</font>]</b>"; elseif($row['picktype']=="classic") $picked_torrent = " <b>[<font class='classic'>".$lang_functions['text_classic']."</font>]</b>"; elseif($row['picktype']=="recommended") $picked_torrent = " <b>[<font class='recommended'>".$lang_functions['text_recommended']."</font>]</b>"; } if ($CURUSER['appendnew'] != 'no' && strtotime($row["added"]) >= $last_browse) print("<b> (<font class='new'>".$lang_functions['text_new_uppercase']."</font>)</b>"); $banned_torrent = ($row["banned"] == 'yes' ? " <b>(<font class=\"striking\">".$lang_functions['text_banned']."</font>)</b>" : ""); print($banned_torrent.$picked_torrent.$sp_torrent); if ($displaysmalldescr){ //small descr $dissmall_descr = trim($row["small_descr"]); $count_dissmall_descr=mb_strlen($dissmall_descr,"UTF-8"); $max_lenght_of_small_descr=$max_length_of_torrent_name; // maximum length if($count_dissmall_descr > $max_lenght_of_small_descr) { $dissmall_descr=mb_substr($dissmall_descr, 0, $max_lenght_of_small_descr-2,"UTF-8") . ".."; } print($dissmall_descr == "" ? "" : "<br />".htmlspecialchars($dissmall_descr)); } print("</td>"); $act = ""; if ($CURUSER["dlicon"] != 'no' && $CURUSER["downloadpos"] != "no") $act .= "<a href=\"download.php?id=".$id."\"><img class=\"download\" src=\"pic/trans.gif\" style='padding-bottom: 2px;' alt=\"download\" title=\"".$lang_functions['title_download_torrent']."\" /></a>" ; if ($CURUSER["bmicon"] == 'yes'){ $bookmark = " href=\"javascript: bookmark(".$id.",".$counter.");\""; $act .= ($act ? "<br />" : "")."<a id=\"bookmark".$counter."\" ".$bookmark." >".get_torrent_bookmark_state($CURUSER['id'], $id)."</a>"; } print("<td width=\"20\" class=\"embedded\" style=\"text-align: right; \" valign=\"middle\">".$act."</td>\n"); print("</tr></table></td>"); if ($wait) { $elapsed = floor((TIMENOW - strtotime($row["added"])) / 3600); if ($elapsed < $wait) { $color = dechex(floor(127*($wait - $elapsed)/48 + 128)*65536); print("<td class=\"rowfollow nowrap\"><a href=\"faq.php#id46\"><font color=\"".$color."\">" . number_format($wait - $elapsed) . $lang_functions['text_h']."</font></a></td>\n"); } else print("<td class=\"rowfollow nowrap\">".$lang_functions['text_none']."</td>\n"); } if ($CURUSER['showcomnum'] != 'no') { print("<td class=\"rowfollow\">"); $nl = ""; //comments $nl = "<br />"; if (!$row["comments"]) { print("<a href=\"comment.php?action=add&pid=".$id."&type=torrent\" title=\"".$lang_functions['title_add_comments']."\">" . $row["comments"] . "</a>"); } else { if ($enabletooltip_tweak == 'yes' && $CURUSER['showlastcom'] != 'no') { if (!$lastcom = $Cache->get_value('torrent_'.$id.'_last_comment_content')){ $res2 = sql_query("SELECT user, added, text FROM comments WHERE torrent = $id ORDER BY id DESC LIMIT 1"); $lastcom = mysql_fetch_array($res2); $Cache->cache_value('torrent_'.$id.'_last_comment_content', $lastcom, 1855); } $timestamp = strtotime($lastcom["added"]); $hasnewcom = ($lastcom['user'] != $CURUSER['id'] && $timestamp >= $last_browse); if ($lastcom) { if ($CURUSER['timetype'] != 'timealive') $lastcomtime = $lang_functions['text_at_time'].$lastcom['added']; else $lastcomtime = $lang_functions['text_blank'].gettime($lastcom["added"],true,false,true); $lastcom_tooltip[$counter]['id'] = "lastcom_" . $counter; $lastcom_tooltip[$counter]['content'] = ($hasnewcom ? "<b>(<font class='new'>".$lang_functions['text_new_uppercase']."</font>)</b> " : "").$lang_functions['text_last_commented_by'].get_username($lastcom['user']) . $lastcomtime."<br />". format_comment(mb_substr($lastcom['text'],0,100,"UTF-8") . (mb_strlen($lastcom['text'],"UTF-8") > 100 ? " ......" : "" ),true,false,false,true,600,false,false); $onmouseover = "onmouseover=\"domTT_activate(this, event, 'content', document.getElementById('" . $lastcom_tooltip[$counter]['id'] . "'), 'trail', false, 'delay', 500,'lifetime',3000,'fade','both','styleClass','niceTitle','fadeMax', 87,'maxWidth', 400);\""; } } else { $hasnewcom = false; $onmouseover = ""; } print("<b><a href=\"details.php?id=".$id."&hit=1&cmtpage=1#startcomments\" ".$onmouseover.">". ($hasnewcom ? "<font class='new'>" : ""). $row["comments"] .($hasnewcom ? "</font>" : ""). "</a></b>"); } print("</td>"); } $time = $row["added"]; $time = gettime($time,false,true); print("<td class=\"rowfollow nowrap\">". $time. "</td>"); //size print("<td class=\"rowfollow\">" . mksize_compact($row["size"])."</td>"); if ($row["seeders"]) { $ratio = ($row["leechers"] ? ($row["seeders"] / $row["leechers"]) : 1); $ratiocolor = get_slr_color($ratio); print("<td class=\"rowfollow\" align=\"center\"><b><a href=\"details.php?id=".$id."&hit=1&dllist=1#seeders\">".($ratiocolor ? "<font color=\"" . $ratiocolor . "\">" . number_format($row["seeders"]) . "</font>" : number_format($row["seeders"]))."</a></b></td>\n"); } else print("<td class=\"rowfollow\"><span class=\"" . linkcolor($row["seeders"]) . "\">" . number_format($row["seeders"]) . "</span></td>\n"); if ($row["leechers"]) { print("<td class=\"rowfollow\"><b><a href=\"details.php?id=".$id."&hit=1&dllist=1#leechers\">" . number_format($row["leechers"]) . "</a></b></td>\n"); } else print("<td class=\"rowfollow\">0</td>\n"); if ($row["times_completed"] >=1) print("<td class=\"rowfollow\"><a href=\"viewsnatches.php?id=".$row[id]."\"><b>" . number_format($row["times_completed"]) . "</b></a></td>\n"); else print("<td class=\"rowfollow\">" . number_format($row["times_completed"]) . "</td>\n"); if ($row["anonymous"] == "yes" && get_user_class() >= $torrentmanage_class) { print("<td class=\"rowfollow\" align=\"center\"><i>".$lang_functions['text_anonymous']."</i><br />".(isset($row["owner"]) ? "(" . get_username($row["owner"]) .")" : "<i>".$lang_functions['text_orphaned']."</i>") . "</td>\n"); } elseif ($row["anonymous"] == "yes") { print("<td class=\"rowfollow\"><i>".$lang_functions['text_anonymous']."</i></td>\n"); } else { print("<td class=\"rowfollow\">" . (isset($row["owner"]) ? get_username($row["owner"]) : "<i>".$lang_functions['text_orphaned']."</i>") . "</td>\n"); } if (get_user_class() >= $torrentmanage_class) { //print("<br /><a href=\"edit.php?returnto=" . rawurlencode($_SERVER["REQUEST_URI"]) . "&id=" . $row["id"] . "\"><img class=\"staff_edit\" src=\"pic/trans.gif\" alt=\"E\" title=\"".$lang_functions['text_edit']."\" /></a></td>\n"); print("<td class=\"rowfollow\"><input type=\"checkbox\" value=\"{$row['id']}\" name=\"id[]\" class=\"checkbox\"></td>"); if ($mode == "normal") { print("<td class=\"rowfollow\"><a href=\"".htmlspecialchars("edit.php?id=".$row[id])."\"><img class=\"staff_edit\" src=\"pic/trans.gif\" alt=\"D\" title=\"".$lang_functions['text_delete']."\" /></a>"); } else { print("<td class=\"rowfollow\"><a href=\"".htmlspecialchars("edit.php?id=".$row[id])."\">编辑</a>"); print("<br/><a href=\"".htmlspecialchars("delete.php?id=".$row[id])."&recycle_mode=release\">发布</a></td>"); } } print("</tr>\n"); $counter++; } if (get_user_class() >= $torrentmanage_class) { print("<tr><td class=\"rowfollow\" colspan=\"11\"><input type=\"button\" value=\"全选\" onclick=\"checkAll();\">"); print("<input type=\"button\" value=\"反选\" onclick=\"reverseCheck();\">"); print(" | <input type=\"button\" id=\"delete\" value=\"删除\">"); if ($mode != "normal") { print("<input type=\"submit\" formaction=\"delete.php?recycle_mode=release\" value=\"发布\"></tr>"); } } print("</table>"); if ($CURUSER['appendpromotion'] == 'highlight') print("<p align=\"center\"> ".$lang_functions['text_promoted_torrents_note']."</p>\n"); if($enabletooltip_tweak == 'yes' && (!isset($CURUSER) || $CURUSER['showlastcom'] == 'yes')) create_tooltip_container($lastcom_tooltip, 400); create_tooltip_container($torrent_tooltip, 500); }