" . htmlspecialchars($x) . "
\n");
stdfoot();
exit();
}
function mksecret($len = 20) {
$ret = "";
for ($i = 0; $i < $len; $i++)
$ret .= chr(mt_rand(100, 120));
return $ret;
}
function httperr($code = 404) {
header("HTTP/1.0 404 Not found");
print("\n");
$secs = 900;
$dt = sqlesc(date("Y-m-d H:i:s",(TIMENOW - $secs))); // calculate date.
print("\n");
print("| ".return_avatar_image($avatar)." | \n");
print(" ".$text.$text_editby." | \n");
print("
\n");
$actionbar = "
".
"
".(get_user_class() >= $commanage_class ? "
" : "").($row["user"] == $CURUSER["id"] || get_user_class() >= $commanage_class ? "
"."" : "");
print(" ".("'".$userRow['last_access']."'"> $dt ? " ":" " )."![\"".$lang_functions['title_send_message_to'].htmlspecialchars($userRow["username"])."\" \"PM\"](\"pic/trans.gif\") ![\"".$lang_functions['title_report_this_comment']."\" \"Report\"](\"pic/trans.gif\") | ".$actionbar." | ");
print("
\n");
$count++;
}
end_frame();
end_main_frame();
}
function searchfield($s) {
return preg_replace(array('/[^a-z0-9]/si', '/^\s*/s', '/\s*$/s', '/\s+/s'), array(" ", "", "", " "), $s);
}
function genrelist($catmode = 1) {
global $Cache;
if (!$ret = $Cache->get_value('category_list_mode_'.$catmode)){
$ret = array();
$res = sql_query("SELECT id, mode, name, image FROM categories WHERE mode = ".sqlesc($catmode)." ORDER BY sort_index, id");
while ($row = mysql_fetch_array($res))
$ret[] = $row;
$Cache->cache_value('category_list_mode_'.$catmode, $ret, 152800);
}
return $ret;
}
function searchbox_item_list($table = "sources"){
global $Cache;
if (!$ret = $Cache->get_value($table.'_list')){
$ret = array();
$res = sql_query("SELECT * FROM ".$table." ORDER BY sort_index, id");
while ($row = mysql_fetch_array($res))
$ret[] = $row;
$Cache->cache_value($table.'_list', $ret, 152800);
}
return $ret;
}
function langlist($type, $enabled = null) {
global $Cache;
$cacheKey = $type.'_lang_list';
return \Nexus\Database\NexusDB::remember($cacheKey, 600, function () use ($type, $enabled) {
$query = \App\Models\Language::query()->where($type, 1);
if ($enabled !== null) {
$query->whereIn('site_lang_folder', \App\Models\Language::listEnabled(true));
}
return $query->get()->toArray();
});
// if (!$ret = $Cache->get_value($type.'_lang_list')){
// $ret = array();
// $res = sql_query("SELECT id, lang_name, flagpic, site_lang_folder FROM language WHERE ". $type ."=1 ORDER BY site_lang DESC, id ASC");
// while ($row = mysql_fetch_array($res))
// $ret[] = $row;
// $Cache->cache_value($type.'_lang_list', $ret, 152800);
// }
// return $ret;
}
function linkcolor($num) {
if (!$num)
return "red";
// if ($num == 1)
// return "yellow";
return "green";
}
function writecomment($userid, $comment, $oldModcomment = null) {
if (is_null($oldModcomment)) {
$res = sql_query("SELECT modcomment FROM users WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_assoc($res);
$modcomment = date("Y-m-d") . " - " . $comment . "" . ($arr['modcomment'] != "" ? "\n" : "") . $arr['modcomment'];
} else {
$modcomment = date("Y-m-d") . " - " . $comment . "" . ($oldModcomment != "" ? "\n" : "") .$oldModcomment;
}
$modcom = sqlesc($modcomment);
do_log("update user: $userid prepend modcomment: $comment, with oldModcomment: $oldModcomment");
return sql_query("UPDATE users SET modcomment = $modcom WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__);
}
function return_torrent_bookmark_array($userid)
{
global $Cache;
static $ret;
if (!$ret){
if (!$ret = $Cache->get_value('user_'.$userid.'_bookmark_array')){
$ret = array();
$res = sql_query("SELECT * FROM bookmarks WHERE userid=" . sqlesc($userid));
if (mysql_num_rows($res) != 0){
while ($row = mysql_fetch_array($res))
$ret[] = $row['torrentid'];
$Cache->cache_value('user_'.$userid.'_bookmark_array', $ret, 132800);
} else {
$Cache->cache_value('user_'.$userid.'_bookmark_array', array(0), 132800);
$ret[] = 0;
}
}
}
return $ret;
}
function get_torrent_bookmark_state($userid, $torrentid, $text = false)
{
global $lang_functions;
$userid = intval($userid ?? 0);
$torrentid = intval($torrentid ?? 0);
$ret = array();
$ret = return_torrent_bookmark_array($userid);
if (!count($ret) || !in_array($torrentid, $ret, false)) // already bookmarked
$act = ($text == true ? $lang_functions['title_bookmark_torrent'] : "
$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");
}
?>
|
|
".$lang_functions['col_wait']."\n");
}
if ($CURUSER['showcomnum'] != 'no') { ?>
|
![<?php echo ($CURUSER['timetype'] != 'timealive' ? $lang_functions['title_time_added'] : $lang_functions['title_time_alive'])?> time](pic/trans.gif) |
![<?php echo $lang_functions['title_size'] ?> size](pic/trans.gif) |
![<?php echo $lang_functions['title_number_of_seeders'] ?> seeders](pic/trans.gif) |
![<?php echo $lang_functions['title_number_of_leechers'] ?> leechers](pic/trans.gif) |
![<?php echo $lang_functions['title_number_of_snatched']?> snatched](pic/trans.gif) |
|
= $torrentmanage_class) { ?>
|
\n");
print("");
if (isset($row["category"])) {
print(return_category_image($row["category"], "?"));
if ($has_secondicon){
print(get_second_icon($row));
}
}
else
print("-");
print(" | \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 = 200;
elseif ($CURUSER['fontsize'] == 'large')
$max_length_of_torrent_name = 120;
elseif ($CURUSER['fontsize'] == 'small')
$max_length_of_torrent_name = 160;
else $max_length_of_torrent_name = 140;
if($count_dispname > $max_length_of_torrent_name)
$dispname=mb_substr($dispname, 0, $max_length_of_torrent_name-2,"UTF-8") . "..";
if ($CURUSER['appendsticky'] == 'yes') {
$posStates = \App\Models\Torrent::listPosStates();
$stickyicon = str_repeat("
", $posStates[$row['pos_state']]['icon_counts'] ?? 0);
} else {
$stickyicon = "";
}
$stickyicon = apply_filter('sticky_icon', $stickyicon, $row);
$sp_torrent = get_torrent_promotion_append($row['sp_state'],"",true,$row["added"], $row['promotion_time_type'], $row['promotion_until'], $row['__ignore_global_sp_state'] ?? false);
$hrImg = get_hr_img($row);
print("".$stickyicon."".htmlspecialchars($dispname)."");
$picked_torrent = "";
if ($CURUSER['appendpicked'] != 'no'){
if($row['picktype']=="hot")
$picked_torrent = " [".$lang_functions['text_hot']."]";
elseif($row['picktype']=="classic")
$picked_torrent = " [".$lang_functions['text_classic']."]";
elseif($row['picktype']=="recommended")
$picked_torrent = " [".$lang_functions['text_recommended']."]";
}
if ($CURUSER['appendnew'] != 'no' && strtotime($row["added"]) >= $last_browse)
print(" (".$lang_functions['text_new_uppercase'].")");
$banned_torrent = ($row["banned"] == 'yes' ? " (".$lang_functions['text_banned'].")" : "");
$sp_torrent_sub = get_torrent_promotion_append_sub($row['sp_state'],"",true,$row['added'], $row['promotion_time_type'], $row['promotion_until'], $row['__ignore_global_sp_state'] ?? false);
$approvalStatusIcon = $torrentRep->renderApprovalStatus($row['approval_status']);
$titleSuffix = $banned_torrent.$picked_torrent.$sp_torrent.$sp_torrent_sub. $hrImg . $approvalStatusIcon;
$titleSuffix = apply_filter('torrent_title_suffix', $titleSuffix, $row);
print($titleSuffix);
//$tags = torrentTags($row['tags'], 'span');
/**
* render tags
*/
$tagOwns = $torrentTagResult->get($id);
if ($tagOwns) {
$tags = $tagRep->renderSpan($tagKeyById, $tagOwns->pluck('tag_id')->toArray());
} else {
$tags = '';
}
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") . "..";
}
$dissmall_descr = $tags . htmlspecialchars($dissmall_descr);
print($dissmall_descr == "" ? "" : " ".$dissmall_descr);
} else {
print($tags ? " $tags" : "");
}
//progress bar
if (isset($torrentSeedingLeechingStatus[$row['id']])) {
echo $torrent->renderProgressBar($torrentSeedingLeechingStatus[$row['id']]['active_status'], $torrentSeedingLeechingStatus[$row['id']]['progress']);
}
print(" | ");
echo $torrent->renderTorrentsPageAverageRating($row);
$act = "";
if ($CURUSER["dlicon"] != 'no' && $CURUSER["downloadpos"] != "no")
$act .= " " ;
if ($CURUSER["bmicon"] == 'yes'){
$bookmark = " href=\"javascript: bookmark(".$id.",".$counter.");\"";
$act .= ($act ? " " : "")."".get_torrent_bookmark_state($CURUSER['id'], $id)."";
}
print("".$act." | \n");
print("
| ");
if ($wait)
{
$elapsed = floor((TIMENOW - strtotime($row["added"])) / 3600);
if ($elapsed < $wait)
{
$color = dechex(floor(127*($wait - $elapsed)/48 + 128)*65536);
print("" . number_format($wait - $elapsed) . $lang_functions['text_h']." | \n");
}
else
print("".$lang_functions['text_none']." | \n");
}
if ($CURUSER['showcomnum'] != 'no')
{
print("");
$nl = "";
//comments
$nl = " ";
if (!$row["comments"]) {
print("" . $row["comments"] . "");
} 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 ? "(".$lang_functions['text_new_uppercase'].") " : "").$lang_functions['text_last_commented_by'].get_username($lastcom['user']) . $lastcomtime." ". 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("". ($hasnewcom ? "" : ""). $row["comments"] .($hasnewcom ? "" : ""). "");
}
print(" | ");
}
$time = $row["added"];
$time = gettime($time,false,true);
print("". $time. " | ");
//size
print("" . mksize_compact($row["size"])." | ");
if ($row["seeders"]) {
$ratio = ($row["leechers"] ? ($row["seeders"] / $row["leechers"]) : 1);
$ratiocolor = get_slr_color($ratio);
print("".($ratiocolor ? "" . number_format($row["seeders"]) . "" : number_format($row["seeders"]))." | \n");
}
else
print("" . number_format($row["seeders"]) . " | \n");
if ($row["leechers"]) {
print("" .
number_format($row["leechers"]) . " | \n");
}
else
print("0 | \n");
if ($row["times_completed"] >=1)
print("" . number_format($row["times_completed"]) . " | \n");
else
print("" . number_format($row["times_completed"]) . " | \n");
if ($row["anonymous"] == "yes" && get_user_class() >= $torrentmanage_class)
{
print("".$lang_functions['text_anonymous']." ".(isset($row["owner"]) ? "(" . get_username($row["owner"]) .")" : "".$lang_functions['text_orphaned']."") . " | \n");
}
elseif ($row["anonymous"] == "yes")
{
print("".$lang_functions['text_anonymous']." | \n");
}
else
{
print("" . (isset($row["owner"]) ? get_username($row["owner"]) : "".$lang_functions['text_orphaned']."") . " | \n");
}
if (get_user_class() >= $torrentmanage_class)
{
print(" ");
print("
![\"".$lang_functions['text_edit']."\" \"E\"](\"pic/trans.gif\") | \n");
}
print("\n");
$counter++;
}
print("
");
if ($CURUSER['appendpromotion'] == 'highlight')
print("