if (intval($forum_config['o_fancy_tracker_enable_scrape'], 10) === 0) { Fancy_Tracker::benc_error('The scrape interface is disabled.'); } if (!isset($_GET["info_hash"])) { Fancy_Tracker::benc_error('Invalid info_hash.'); } $info_hashes = array(); $querys = explode('&', $_SERVER['QUERY_STRING']); foreach ($querys as $q) { if (substr($q, 0, 10) == 'info_hash=') { list(, $_hash) = explode('=', $q); //$_hash = forum_trim($_hash); if (strlen($_hash) === 20) { $_hash = bin2hex($_hash); } if (Fancy_Tracker::is_info_hash($_hash)) { array_push($info_hashes, $_hash); continue; } } } $response = array(); $response['flags'] = $response['files'] = array(); foreach ($info_hashes as $hash) { // GET TORRENT INFO $query = array('SELECT' => 't.name, t.completed', 'FROM' => 'torrents AS t', 'WHERE' => 'UPPER(t.info_hash) = UPPER(\'' . $forum_db->escape($hash) . '\')'); $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); $torrent_info = $forum_db->fetch_assoc($result); if (!$torrent_info) { continue; }
require FORUM_ROOT . 'extensions/fancy_tracker/lang/' . $forum_user['language'] . '/fancy_tracker.php'; } else { require FORUM_ROOT . 'extensions/fancy_tracker/lang/English/fancy_tracker.php'; } $query = array('SELECT' => 'COUNT(*) AS enabled', 'FROM' => 'extensions', 'WHERE' => 'id=\'fancy_tracker\' AND disabled=0'); $result = $forum_db->query_build($query) or Fancy_Tracker::benc_error('Unable to check for extension.'); if ($forum_db->result($result) != '1') { message($lang_common['Bad request']); } if ($forum_user['g_use_tracker'] == '0') { message($lang_common['No view']); } $action = isset($_GET['action']) ? forum_trim($_GET['action']) : FALSE; if ($action == 'get') { $info_hash = isset($_GET['hash']) ? forum_trim($_GET['hash']) : ''; if (!Fancy_Tracker::is_info_hash($info_hash)) { message($lang_common['Bad request']); } if (!file_exists(FORUM_ROOT . 'extensions/fancy_tracker/torrents/' . $info_hash . '.torrent')) { message($lang_tracker['File not exists']); } $query = array('SELECT' => 't.name', 'FROM' => 'torrents AS t', 'WHERE' => 'UPPER(t.info_hash) = UPPER(\'' . $forum_db->escape($info_hash) . '\')'); $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); $name = $forum_db->result($result); if (is_null($name) || $name === false) { message($lang_common['Bad request']); } if (strlen($forum_user['passkey']) != 32) { $forum_user['passkey'] = md5($forum_user['salt'] . $forum_user['id'] . time() . $forum_user['username'] . $forum_user['password']); $query = array('UPDATE' => 'users', 'SET' => 'passkey=\'' . $forum_db->escape($forum_user['passkey']) . '\'', 'WHERE' => 'id=' . $forum_user['id']); $forum_db->query_build($query) or error(__FILE__, __LINE__);