fix rss download link + migrate bencode to rhilip/bencode

This commit is contained in:
xiaomlove
2021-06-09 02:23:09 +08:00
parent bf49c8c298
commit 5c4c2ccf8f
9 changed files with 185 additions and 329 deletions
+1 -2
View File
@@ -52,8 +52,7 @@ class Test extends Command
*/
public function handle()
{
$file = storage_path('logs/11270.torrent');
$r = Bencode::load($file);
$r = 'https://hdtime.org/download.php?downhash=' . urlencode('1|Roqd');
dd($r);
}
+2 -2
View File
@@ -44,7 +44,7 @@ function block_browser()
function benc_resp($d)
{
benc_resp_raw(benc(array('type' => 'dictionary', 'value' => $d)));
benc_resp_raw(\Rhilip\Bencode\Bencode::encode($d));
}
function benc_resp_raw($x) {
do_log($x);
@@ -60,7 +60,7 @@ function benc_resp_raw($x) {
}
function err($msg, $userid = 0, $torrentid = 0)
{
benc_resp(array('failure reason' => array('type' => 'string', 'value' => $msg)));
benc_resp(['failure reason' => $msg]);
exit();
}
function check_cheater($userid, $torrentid, $uploaded, $downloaded, $anctime, $seeders=0, $leechers=0){
+31
View File
@@ -584,3 +584,34 @@ function isRunningInConsole(): bool
{
return php_sapi_name() == 'cli';
}
function get_base_announce_url()
{
global $https_announce_urls, $announce_urls;
$httpsAnnounceUrls = array_filter($https_announce_urls);
$log = "cookie: " . json_encode($_COOKIE) . ", https_announce_urls: " . json_encode($httpsAnnounceUrls);
if ((isset($_COOKIE["c_secure_tracker_ssl"]) && $_COOKIE["c_secure_tracker_ssl"] == base64("yeah")) || !empty($httpsAnnounceUrls)) {
$log .= ", c_secure_tracker_ssl = base64('yeah'): " . base64("yeah") . ", or not empty https_announce_urls";
$tracker_ssl = true;
} else {
$tracker_ssl = false;
}
$log .= ", tracker_ssl: $tracker_ssl";
if ($tracker_ssl == true){
$ssl_torrent = "https://";
if ($https_announce_urls[0] != "") {
$log .= ", https_announce_urls not empty, use it";
$base_announce_url = $https_announce_urls[0];
} else {
$log .= ", https_announce_urls empty, use announce_urls[0]";
$base_announce_url = $announce_urls[0];
}
}
else{
$ssl_torrent = "http://";
$base_announce_url = $announce_urls[0];
}
do_log($log);
return $ssl_torrent . $base_announce_url;
}
+39 -47
View File
@@ -1,6 +1,6 @@
<?php
require_once('../include/bittorrent_announce.php');
require_once('../include/benc.php');
//require_once('../include/benc.php');
dbconn_announce();
do_log(nexus_json_encode($_SERVER));
//1. BLOCK ACCESS WITH WEB BROWSERS AND CHEATS!
@@ -150,58 +150,50 @@ $real_annnounce_interval = $anninterthree;
elseif ($annintertwoage && ($annintertwo > $announce_wait) && (TIMENOW - $torrent['ts']) >= ($annintertwoage * 86400))
$real_annnounce_interval = $annintertwo;
$resp = "d" . benc_str("interval") . "i" . $real_annnounce_interval . "e" . benc_str("min interval") . "i" . $announce_wait . "e". benc_str("complete") . "i" . $torrent["seeders"] . "e" . benc_str("incomplete") . "i" . $torrent["leechers"] . "e" . benc_str("peers");
//$resp = "d" . benc_str("interval") . "i" . $real_annnounce_interval . "e" . benc_str("min interval") . "i" . $announce_wait . "e". benc_str("complete") . "i" . $torrent["seeders"] . "e" . benc_str("incomplete") . "i" . $torrent["leechers"] . "e" . benc_str("peers");
$rep_dict = [
"interval" => (int)$real_annnounce_interval,
"min interval" => (int)$announce_wait,
"complete" => (int)$torrent["seeders"],
"incomplete" => (int)$torrent["leechers"],
"peers" => [] // By default it is a array object, only when `&compact=1` then it should be a string
];
if ($compact == 1) {
$rep_dict['peers'] = ''; // Change `peers` from array to string
$rep_dict['peers6'] = ''; // If peer use IPv6 address , we should add packed string in `peers6`
}
$peer_list = "";
$peer6_list = "";
unset($self);
// bencoding the peers info get for this announce
while ($row = mysql_fetch_assoc($res))
{
$row["peer_id"] = hash_pad($row["peer_id"]);
// $peer_id is the announcer's peer_id while $row["peer_id"] is randomly selected from the peers table
if ($row["peer_id"] === $peer_id)
{
$self = $row;
continue;
}
if ($compact == 1){
$longip = ip2long($row['ip']);
if ($longip) //Ignore ipv6 address
$peer_list .= pack("Nn", sprintf("%d",$longip), $row['port']);
else
{
$ipv6_packed = inet_pton($row['ip']);
if ($ipv6_packed)
$peer6_list .= $ipv6_packed . pack("n", $row['port']);
if (isset($event) && $event == "stopped") {
// Don't fetch peers for stopped event
} else {
// bencoding the peers info get for this announce
while ($row = mysql_fetch_assoc($res)) {
$row["peer_id"] = hash_pad($row["peer_id"]);
// $peer_id is the announcer's peer_id while $row["peer_id"] is randomly selected from the peers table
if ($row["peer_id"] === $peer_id) {
$self = $row;
continue;
}
if ($compact == 1) {
$peerField = filter_var($row['ip'],FILTER_VALIDATE_IP,FILTER_FLAG_IPV6) ? 'peers6' : 'peers';
$rep_dict[$peerField] .= inet_pton($row["ip"]) . pack("n", $row["port"]);
} else {
$peer = [
'ip' => $row["ip"],
'port' => (int) $row["port"]
];
if ($no_peer_id == 1) $peer['peer id'] = $row["peer_id"];
$rep_dict['peers'][] = $peer;
}
}
elseif ($no_peer_id == 1)
$peer_list .= "d" .
benc_str("ip") . benc_str($row["ip"]) .
benc_str("port") . "i" . $row["port"] . "e" .
"e";
else
$peer_list .= "d" .
benc_str("ip") . benc_str($row["ip"]) .
benc_str("peer id") . benc_str($row["peer_id"]) .
benc_str("port") . "i" . $row["port"] . "e" .
"e";
}
if ($compact == 1)
$resp .= benc_str($peer_list);
else
$resp .= "l".$peer_list."e";
if ($compact == 1 && strlen($peer6_list) > 0)
{
$resp .= benc_str("peers6").benc_str($peer6_list);
}
$resp .= "e";
$selfwhere = "torrent = $torrentid AND " . hash_where("peer_id", $peer_id);
//no found in the above random selection
if (!isset($self))
{
@@ -482,5 +474,5 @@ try {
do_log("add exam progress fail: " . $exception->getMessage());
}
benc_resp_raw($resp);
benc_resp($rep_dict);
?>
+12 -17
View File
@@ -64,23 +64,8 @@ if (@ini_get('output_handler') == 'ob_gzhandler' AND @ob_get_length() !== false)
header('Content-Encoding:');
}
*/
if ((isset($_COOKIE["c_secure_tracker_ssl"]) && $_COOKIE["c_secure_tracker_ssl"] == base64("yeah")) || !empty($https_announce_urls))
$tracker_ssl = true;
else
$tracker_ssl = false;
if ($tracker_ssl == true){
$ssl_torrent = "https://";
if ($https_announce_urls[0] != "")
$base_announce_url = $https_announce_urls[0];
else
$base_announce_url = $announce_urls[0];
}
else{
$ssl_torrent = "http://";
$base_announce_url = $announce_urls[0];
}
$base_announce_url = get_base_announce_url();
$res = sql_query("SELECT torrents.name, torrents.filename, torrents.save_as, torrents.size, torrents.owner, torrents.banned, categories.mode as search_box_id FROM torrents left join categories on torrents.category = categories.id WHERE torrents.id = ".sqlesc($id)) or sqlerr(__FILE__, __LINE__);
$row = mysql_fetch_assoc($res);
@@ -97,7 +82,7 @@ if (($row['banned'] == 'yes' && get_user_class() < $seebanned_class) || !can_acc
sql_query("UPDATE torrents SET hits = hits + 1 WHERE id = ".sqlesc($id)) or sqlerr(__FILE__, __LINE__);
require_once "include/benc.php";
//require_once "include/benc.php";
if (strlen($CURUSER['passkey']) != 32) {
$CURUSER['passkey'] = md5($CURUSER['username'].date("Y-m-d H:i:s").$CURUSER['passhash']);
@@ -108,6 +93,16 @@ $trackerReportAuthKey = $torrentRep->getTrackerReportAuthKey($id, $CURUSER['id']
$dict = \Rhilip\Bencode\Bencode::load($fn);
$dict['announce'] = $ssl_torrent . $base_announce_url . "?authkey=$trackerReportAuthKey";
if (count($announce_urls) > 1) {
foreach ($announce_urls as $announce_url) {
/** d['announce-list'] = [[ tracker1, tracker2, tracker3 ]] */
$dict['announce-list'][0][] = $ssl_torrent . $announce_url . "?authkey=$trackerReportAuthKey";
/** d['announce-list'] = [ [tracker1], [backup1], [backup2] ] */
//$dict['announce-list'][] = [$ssl_torrent . $announce_url . "?passkey=" . $CURUSER['passkey']];
}
}
//$dict = bdec_file($fn, $max_torrent_size);
//$dict['value']['announce']['value'] = $ssl_torrent . $base_announce_url . "?passkey=$CURUSER[passkey]";
//$dict['value']['announce']['value'] = $ssl_torrent . $base_announce_url . "?authkey=$trackerReportAuthKey";
+9 -8
View File
@@ -1,6 +1,6 @@
<?php
require_once('../include/bittorrent_announce.php');
require_once('../include/benc.php');
//require_once('../include/benc.php');
dbconn_announce();
// BLOCK ACCESS WITH WEB BROWSERS AND CHEATS!
@@ -24,13 +24,14 @@ if (mysql_num_rows($res) < 1){
err("Torrent not registered with this tracker.");
}
$torrent_details = [];
while ($row = mysql_fetch_assoc($res)) {
$r .= "20:" . hash_pad($row["info_hash"]) . "d" .
benc_str("complete") . "i" . $row["seeders"] . "e" .
benc_str("downloaded") . "i" . $row["times_completed"] . "e" .
benc_str("incomplete") . "i" . $row["leechers"] . "e" .
"e";
$torrent_details[$row['info_hash']] = [
'complete' => (int)$row['seeders'],
'downloaded' => (int)$row['times_completed'],
'incomplete' => (int)$row['leechers']
];
}
$r .= "ee";
benc_resp_raw($r);
$d = ['files' => $torrent_details];
benc_resp($d);
+54 -104
View File
@@ -1,5 +1,5 @@
<?php
require_once("../include/benc.php");
//require_once("../include/benc.php");
require_once("../include/bittorrent.php");
ini_set("upload_max_filesize",$max_torrent_size);
@@ -94,122 +94,77 @@ bark("eek");
if (!filesize($tmpname))
bark($lang_takeupload['std_empty_file']);
$dict = bdec_file($tmpname, $max_torrent_size);
if (!isset($dict))
bark($lang_takeupload['std_not_bencoded_file']);
function dict_check($d, $s) {
global $lang_takeupload;
if ($d["type"] != "dictionary")
bark($lang_takeupload['std_not_a_dictionary']);
$a = explode(":", $s);
$dd = $d["value"];
$ret = array();
foreach ($a as $k) {
unset($t);
if (preg_match('/^(.*)\((.*)\)$/', $k, $m)) {
$k = $m[1];
$t = $m[2];
}
if (!isset($dd[$k]))
bark($lang_takeupload['std_dictionary_is_missing_key']);
if (isset($t)) {
if ($dd[$k]["type"] != $t)
bark($lang_takeupload['std_invalid_entry_in_dictionary']);
$ret[] = $dd[$k]["value"];
}
else
$ret[] = $dd[$k];
}
return $ret;
try {
$dict = \Rhilip\Bencode\Bencode::load($tmpname);
} catch (\Rhilip\Bencode\ParseErrorException $e) {
bark($lang_takeupload['std_not_bencoded_file']);
}
function dict_get($d, $k, $t) {
global $lang_takeupload;
if ($d["type"] != "dictionary")
bark($lang_takeupload['std_not_a_dictionary']);
$dd = $d["value"];
if (!isset($dd[$k]))
return;
$v = $dd[$k];
if ($v["type"] != $t)
bark($lang_takeupload['std_invalid_dictionary_entry_type']);
return $v["value"];
}
//list($ann, $info) = dict_check($dict, "announce(string):info");
//@see https://blog.rhilip.info/archives/1036/
list($info) = dict_check($dict, "info");
list($dname, $plen, $pieces) = dict_check($info, "name(string):piece length(integer):pieces(string)");
/*
if (!in_array($ann, $announce_urls, 1))
function checkTorrentDict($dict, $key, $type = null)
{
$aok=false;
foreach($announce_urls as $au)
{
if($ann=="$au?passkey=$CURUSER[passkey]") $aok=true;
}
if(!$aok)
bark("Invalid announce url! Must be: " . $announce_urls[0] . "?passkey=$CURUSER[passkey]");
}
*/
global $lang_takeupload;
if (!is_array($dict)) bark($lang_takeupload['std_not_a_dictionary']);
$value = $dict[$key];
if (!isset($value)) bark($lang_takeupload['std_dictionary_is_missing_key']);
if (!is_null($type)) {
$isFunction = 'is_' . $type;
if (function_exists($isFunction) && !$isFunction($value)) {
bark($lang_takeupload['std_invalid_entry_in_dictionary']);
}
}
return $value;
}
$info = checkTorrentDict($dict, 'info');
$plen = checkTorrentDict($info, 'piece length', 'integer'); // Only Check without use
$dname = checkTorrentDict($info, 'name', 'string');
$pieces = checkTorrentDict($info, 'pieces', 'string');
if (strlen($pieces) % 20 != 0)
bark($lang_takeupload['std_invalid_pieces']);
$filelist = array();
$totallen = dict_get($info, "length", "integer");
$totallen = $info['length'];
if (isset($totallen)) {
$filelist[] = array($dname, $totallen);
$type = "single";
}
else {
$flist = dict_get($info, "files", "list");
if (!isset($flist))
bark($lang_takeupload['std_missing_length_and_files']);
if (!count($flist))
bark("no files");
$totallen = 0;
foreach ($flist as $fn) {
list($ll, $ff) = dict_check($fn, "length(integer):path(list)");
$totallen += $ll;
$ffa = array();
foreach ($ff as $ffe) {
if ($ffe["type"] != "string")
bark($lang_takeupload['std_filename_errors']);
$ffa[] = $ffe["value"];
}
if (!count($ffa))
bark($lang_takeupload['std_filename_errors']);
$ffe = implode("/", $ffa);
$filelist[] = array($ffe, $ll);
}
$type = "multi";
$flist = checkTorrentDict($info, 'files', 'array');
if (!isset($flist)) bark($lang_takeupload['std_missing_length_and_files']);
if (!count($flist)) bark("no files");
$totallen = 0;
foreach ($flist as $fn) {
$ll = checkTorrentDict($fn, 'length', 'integer');
$path_key = isset($fn['path.utf-8']) ? 'path.utf-8' : 'path';
$ff = checkTorrentDict($fn, $path_key, 'list');
$totallen += $ll;
$ffa = array();
foreach ($ff as $ffe) {
if (!is_string($ffe)) bark($lang_takeupload['std_filename_errors']);
$ffa[] = $ffe;
}
if (!count($ffa)) bark($lang_takeupload['std_filename_errors']);
$ffe = implode("/", $ffa);
$filelist[] = array($ffe, $ll);
}
$type = "multi";
}
$dict['value']['announce']=bdec(benc_str( get_protocol_prefix() . $announce_urls[0])); // change announce url to local
$dict['value']['info']['value']['private']=bdec('i1e'); // add private tracker flag
$dict['announce'] = get_protocol_prefix() . $announce_urls[0]; // change announce url to local
$dict['info']['private'] = 1;
//The following line requires uploader to re-download torrents after uploading
//even the torrent is set as private and with uploader's passkey in it.
$dict['value']['info']['value']['source']=bdec(benc_str( "[$BASEURL] $SITENAME"));
unset($dict['value']['announce-list']); // remove multi-tracker capability
unset($dict['value']['nodes']); // remove cached peers (Bitcomet & Azareus)
$dict=bdec(benc($dict)); // double up on the becoding solves the occassional misgenerated infohash
list($ann, $info) = dict_check($dict, "announce(string):info");
$dict['info']['source'] = "[$BASEURL] $SITENAME";
unset ($dict['announce-list']); // remove multi-tracker capability
unset ($dict['nodes']); // remove cached peers (Bitcomet & Azareus)
$infohash = pack("H*", sha1($info["string"]));
function hex_esc2($matches) {
return sprintf("%02x", ord($matches[0]));
}
//die(phpinfo());
//die("\\' pos:" . strpos($infohash,"\\") . ", after sqlesc:" . (strpos(sqlesc($infohash),"\\") == false ? "gone" : strpos(sqlesc($infohash),"\\")));
//die(preg_replace_callback('/./s', "hex_esc2", $infohash));
$infohash = pack("H*", sha1(\Rhilip\Bencode\Bencode::encode($dict['info']))); // double up on the becoding solves the occassional misgenerated infohash
// ------------- start: check upload authority ------------------//
$allowtorrents = user_can_upload("torrents");
@@ -380,12 +335,7 @@ foreach ($filelist as $file) {
}
//move_uploaded_file($tmpname, "$torrent_dir/$id.torrent");
$fp = fopen(ROOT_PATH . "$torrent_dir/$id.torrent", "w");
if ($fp)
{
@fwrite($fp, benc($dict), strlen(benc($dict)));
fclose($fp);
}
\Rhilip\Bencode\Bencode::dump(getFullDirectory("$torrent_dir/$id.torrent"),$dict);
//===add karma
KPS("+",$uploadtorrent_bonus,$CURUSER["id"]);
+36 -147
View File
@@ -1,58 +1,37 @@
<?php
require "../include/bittorrent.php";
require_once "include/benc.php";
function print_array($array, $offset_symbol = "|--", $offset = "", $parent = "")
if (!function_exists('is_indexed_array')) {
/** 索引数组:所有键名都为数值型,注意字符串类型的数字键名会被转换为数值型。
* 判断数组是否为索引数组
* @param array $arr
* @return bool
*/
function is_indexed_array(array $arr): bool
{
if (is_array($arr)) {
return count(array_filter(array_keys($arr), 'is_string')) === 0;
}
return false;
}
}
function torrent_structure_builder($array, $parent = "")
{
if (!is_array($array))
{
echo "[$array] is not an array!<br />";
return;
}
reset($array);
switch($array['type'] ?? '')
{
case "string":
printf("<li><div align=left class=string> - <span class=icon>[STRING]</span> <span class=title>[%s]</span> <span class=length>(%d)</span>: <span class=value>%s</span></div></li>",$parent,$array['strlen'],$array['value']);
break;
case "integer":
printf("<li><div align=left class=integer> - <span class=icon>[INT]</span> <span class=title>[%s]</span> <span class=length>(%d)</span>: <span class=value>%s</span></div></li>",$parent,$array['strlen'],$array['value']);
break;
case "list":
printf("<li><div align=left class=list> + <span class=icon>[LIST]</span> <span class=title>[%s]</span> <span class=length>(%d)</span></div>",$parent,$array['strlen']);
echo "<ul>";
print_array($array['value'], $offset_symbol, $offset.$offset_symbol);
echo "</ul></li>";
break;
case "dictionary":
printf("<li><div align=left class=dictionary> + <span class=icon>[DICT]</span> <span class=title>[%s]</span> <span class=length>(%d)</span></div>",$parent,$array['strlen']);
foreach ($array as $key => $val)
{
if (is_array($val))
{
echo "<ul>";
print_array($val, $offset_symbol, $offset.$offset_symbol,$key);
echo "</ul>";
}
}
echo "</li>";
break;
default:
foreach ($array as $key => $val)
{
if (is_array($val))
{
//echo $offset;
print_array($val, $offset_symbol, $offset, $key);
}
}
break;
}
$ret = '';
foreach ($array as $item => $value) {
$value_length = strlen(\Rhilip\Bencode\Bencode::encode($value));
if (is_iterable($value)) { // It may `dictionary` or `list`
$type = is_indexed_array($value) ? 'list' : 'dictionary';
$ret .= "<li><div align='left' class='" . $type . "'><a href='javascript:void(0);' onclick='jQuery(this).parent().next(\"ul\").toggle()'> + <span class=title>[" . $item . "]</span> <span class='icon'>(" . ucfirst($type) . ")</span> <span class=length>[" . $value_length . "]</span></a></div>";
$ret .= "<ul style='display:none'>" . torrent_structure_builder($value, $item) . "</ul></li>";
} else { // It may `interger` or `string`
$type = is_integer($value) ? 'integer' : 'string';
$value = ($parent == 'info' && $item == 'pieces') ? "0x" . bin2hex(substr($value, 0, 25)) . "..." : $value; // Cut the info pieces....
$ret .= "<li><div align=left class=" . $type . "> - <span class=title>[" . $item . "]</span> <span class=icon>(" . ucfirst($type) . ")</span> <span class=length>[" . $value_length . "]</span>: <span class=value>" . $value . "</span></div></li>";
}
}
return $ret;
}
dbconn();
@@ -110,104 +89,14 @@ li span.title {font-weight: bold;}
begin_main_frame();
// Heading
print("<div align=center><h1>{$row['name']}</h1>");
$dict = bdec_file($fn, (1024*1024));
// Start table
print("<table width=750 border=1 cellspacing=0 cellpadding=5><td>");
$dict['value']['info']['value']['pieces']['value'] = "0x".bin2hex(substr($dict['value']['info']['value']['pieces']['value'], 0, 25))."...";
echo "<ul id=colapse>";
print_array($dict,"*", "", "root");
$dict = \Rhilip\Bencode\Bencode::load($fn);
print("<div align=center><h1>$row[name]</h1>"); // Heading
print("<table width=750 border=1 cellspacing=0 cellpadding=5><td>"); // Start table
echo "<ul id='torrent-structure'>";
echo torrent_structure_builder(['root' => $dict]);
echo "</ul>";
print("</td></table>"); // End table
// End table
print("</td></table>");
?>
<script type="text/javascript" language="javascript1.2">
var openLists = [], oIcount = 0;
function compactMenu(oID,oAutoCol,oPlMn,oMinimalLink) {
if( !document.getElementsByTagName || !document.childNodes || !document.createElement ) { return; }
var baseElement = document.getElementById( oID ); if( !baseElement ) { return; }
compactChildren( baseElement, 0, oID, oAutoCol, oPlMn, baseElement.tagName.toUpperCase(), oMinimalLink && oPlMn );
}
function compactChildren( oOb, oLev, oBsID, oCol, oPM, oT, oML ) {
if( !oLev ) { oBsID = escape(oBsID); if( oCol ) { openLists[oBsID] = []; } }
for( var x = 0, y = oOb.childNodes; x < y.length; x++ ) { if( y[x].tagName ) {
//for each immediate LI child
var theNextUL = y[x].getElementsByTagName( oT )[0];
if( theNextUL ) {
//collapse the first UL/OL child
theNextUL.style.display = 'none';
//create a link for expanding/collapsing
var newLink = document.createElement('A');
newLink.setAttribute( 'href', '#' );
newLink.onclick = new Function( 'clickSmack(this,' + oLev + ',\'' + oBsID + '\',' + oCol + ',\'' + escape(oT) + '\');return false;' );
//wrap everything upto the child U/OL in the link
if( oML ) { var theHTML = ''; } else {
var theT = y[x].innerHTML.toUpperCase().indexOf('<'+oT);
var theA = y[x].innerHTML.toUpperCase().indexOf('<A');
var theHTML = y[x].innerHTML.substr(0, ( theA + 1 && theA < theT ) ? theA : theT );
while( !y[x].childNodes[0].tagName || ( y[x].childNodes[0].tagName.toUpperCase() != oT && y[x].childNodes[0].tagName.toUpperCase() != 'A' ) ) {
y[x].removeChild( y[x].childNodes[0] ); }
}
y[x].insertBefore(newLink,y[x].childNodes[0]);
y[x].childNodes[0].innerHTML = oPM + theHTML.replace(/^\s*|\s*$/g,'');
theNextUL.MWJuniqueID = oIcount++;
compactChildren( theNextUL, oLev + 1, oBsID, oCol, oPM, oT, oML );
} } } }
function clickSmack( oThisOb, oLevel, oBsID, oCol, oT ) {
if( oThisOb.blur ) { oThisOb.blur(); }
oThisOb = oThisOb.parentNode.getElementsByTagName( unescape(oT) )[0];
if( oCol ) {
for( var x = openLists[oBsID].length - 1; x >= oLevel; x-=1 ) { if( openLists[oBsID][x] ) {
openLists[oBsID][x].style.display = 'none'; if( oLevel != x ) { openLists[oBsID][x] = null; }
} }
if( oThisOb == openLists[oBsID][oLevel] ) { openLists[oBsID][oLevel] = null; }
else { oThisOb.style.display = 'block'; openLists[oBsID][oLevel] = oThisOb; }
} else { oThisOb.style.display = ( oThisOb.style.display == 'block' ) ? 'none' : 'block'; }
}
function stateToFromStr(oID,oFStr) {
if( !document.getElementsByTagName || !document.childNodes || !document.createElement ) { return ''; }
var baseElement = document.getElementById( oID ); if( !baseElement ) { return ''; }
if( !oFStr && typeof(oFStr) != 'undefined' ) { return ''; } if( oFStr ) { oFStr = oFStr.split(':'); }
for( var oStr = '', l = baseElement.getElementsByTagName(baseElement.tagName), x = 0; l[x]; x++ ) {
if( oFStr && MWJisInTheArray( l[x].MWJuniqueID, oFStr ) && l[x].style.display == 'none' ) { l[x].parentNode.getElementsByTagName('a')[0].onclick(); }
else if( l[x].style.display != 'none' ) { oStr += (oStr?':':'') + l[x].MWJuniqueID; }
}
return oStr;
}
function MWJisInTheArray(oNeed,oHay) { for( var i = 0; i < oHay.length; i++ ) { if( oNeed == oHay[i] ) { return true; } } return false; }
function selfLink(oRootElement,oClass,oExpand) {
if(!document.getElementsByTagName||!document.childNodes) { return; }
oRootElement = document.getElementById(oRootElement);
for( var x = 0, y = oRootElement.getElementsByTagName('a'); y[x]; x++ ) {
if( y[x].getAttribute('href') && !y[x].href.match(/#$/) && getRealAddress(y[x]) == getRealAddress(location) ) {
y[x].className = (y[x].className?(y[x].className+' '):'') + oClass;
if( oExpand ) {
oExpand = false;
for( var oEl = y[x].parentNode, ulStr = ''; oEl != oRootElement && oEl != document.body; oEl = oEl.parentNode ) {
if( oEl.tagName && oEl.tagName == oRootElement.tagName ) { ulStr = oEl.MWJuniqueID + (ulStr?(':'+ulStr):''); } }
stateToFromStr(oRootElement.id,ulStr);
} } } }
function getRealAddress(oOb) { return oOb.protocol + ( ( oOb.protocol.indexOf( ':' ) + 1 ) ? '' : ':' ) + oOb.hostname + ( ( typeof(oOb.pathname) == typeof(' ') && oOb.pathname.indexOf('/') != 0 ) ? '/' : '' ) + oOb.pathname + oOb.search; }
compactMenu('colapse',false,'');
</script>
<?php
// Standard html footers
end_main_frame();
stdfoot();
+1 -2
View File
@@ -105,7 +105,6 @@ get_where("audiocodecs", "audiocodec", "aud");
if ($where)
$where = "WHERE ".$where;
$query = "SELECT torrents.id, torrents.category, torrents.name, torrents.small_descr, torrents.descr, torrents.info_hash, torrents.size, torrents.added, torrents.anonymous, users.username AS username, categories.id AS cat_id, categories.name AS cat_name FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where ORDER BY torrents.added DESC LIMIT $limit";
$res = sql_query($query) or die(mysql_error());
$torrentRep = new \App\Repositories\TorrentRepository();
$url = get_protocol_prefix().$BASEURL;
@@ -152,7 +151,7 @@ while ($row = mysql_fetch_array($res))
else $author = $row['username'];
$itemurl = $url."/details.php?id=".$row['id'];
if ($dllink)
$itemdlurl = $url."/download.php?id=".$row['id']."&amp;downhash=".rawurlencode($torrentRep->encryptDownHash($row['id'], $user));
$itemdlurl = $url."/download.php?id=".$row['id']."&amp;downhash=" . rawurlencode( $user['id'] . '|'. $torrentRep->encryptDownHash($row['id'], $user));
else $itemdlurl = $url."/download.php?id=".$row['id'];
if (!empty($_GET['icat'])) $title .= "[".$row['cat_name']."]";
$title .= $row['name'];