Bravo List
Go Back   > Bravo List > Source Code > Active Trackers > FreeTSP
Old 24th March 2016, 00:50
Atmosos's Avatar
Atmosos Atmosos is offline
Senior Member
Join Date: Feb 2016
Posts: 23
Default couchpotato.php
Hi all,

I was wondering if someone could port this for freetsp. I tried to edit the script but i failed. If someone needs an invite for my site to test please send me your email.
i have created a db field for the imdb ttcode and its also populated.

Bump: fixed it myself... only need some help on how to download the torrent without login in...


* Written By: AtheistP3ace
* ->
* Adjusted by Atmosos for freetsp!
* Most of this code will work on gazelle based trackers.
* Added some extra security in as well. Some of that extra security
* will require code added to other parts of your site. All this code
* does not use any of the wrappers from original gazelle code
* except Cache which also can be stripped out if your site is small.
* Mostly you only need your specific SQL added to match your tables.

$mysql_host = "localhost"; # Your mysql host name -- localhost is the default
$mysql_user = ""; # Your mysql username
$mysql_pass = ""; # Your mysql password
$mysql_db = ""; # Your mysql data base name

// Set content type
header('Content-Type: application/json');

// Do parameters match what we expect?

if (empty($_REQUEST['passkey']) || strlen($_REQUEST['passkey']) != 32 || (empty($_REQUEST['imdbid'])) || empty($_REQUEST['user'])) {
echo json_encode(array("error" => "Incorrect parameters."));

// Connect to DB manually for exposed service. Variables below come from config.php loaded above
$mysqli = new mysqli($mysql_host, $mysql_user, $mysql_pass, $mysql_db);

if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());

$Username = $mysqli->escape_string($_REQUEST['user']);
$PassKey = $mysqli->escape_string($_REQUEST['passkey']);
$IMDbID = $mysqli->escape_string($_REQUEST['imdbid']);

// Get needed data on user attached to Username and passkey
// Forcing both values to be passed makes security a bit harder and allows us to make a couch potato key
$FindUserQuery = $mysqli->query("SELECT id FROM users WHERE passkey = '$PassKey' AND username = '$Username'");
// Does user exist?

if ($FindUserQuery->num_rows == 0) {
echo json_encode(array("error" => "Death by authorization."));

$FindUserResult = mysqli_fetch_array($FindUserQuery);
$UserID = $FindUserResult['id'];

* The next bit is all for security. You can remove this if you don't care about that.
* It basically checks if user is an enabled user, has permissions to access service,
* user enabled access from their profile to generate a hashed passkey. None is
* necessary but helpful if security is your thing.

$MediaQuery = "SELECT
FROM torrents
if (!empty($IMDbID)) {
$MediaQuery .= " imdbcode = '$IMDbID'";

$MediaLookupResults = $mysqli->query($MediaQuery);

// Check for results
$TotalResults = $MediaLookupResults->num_rows;
if ($TotalResults == 0) {
echo json_encode(array("total_results" => $TotalResults));
else {
// Initialize for output
$JSONOutput = array();

// For each returned row build JSON output
while($ResultRow = mysqli_fetch_array($MediaLookupResults)) {

// Release Name
$Name = $ResultRow['name'];

// Torrent ID
$TorrentID = $ResultRow['id'];

// Build details page URL
$DetailsURL = "".$ResultRow['id'];

// Build download URL
$DownloadURL = "".$ResultRow['id']."/".$ResultRow['filename']."";

// Add in IMDb ID for searches by text
$IMDB_ID = $ResultRow['imdbcode'];

// Get download size (B -> KB -> MB)
$MediaSize = round(intval($ResultRow['size']) / 1024 / 1024, 0);

// Get Leechers
$Leechers = intval($ResultRow['leechers']);

// Get Seeders
$Seeders = intval($ResultRow['seeders']);

// movie_name + edition + movie_year + resolution + audio + media + release_type
$ReleaseName = str_replace(" ", ".", $Name);

// Build array for JSON encoding
$Details = array(
"release_name" => $ReleaseName,
"torrent_id" => $TorrentID,
"details_url" => $DetailsURL,
"download_url" => $DownloadURL,
"imdb_id" => $IMDB_ID,
"size" => $MediaSize,
"leechers" => $Leechers,
"seeders" => $Seeders);

// Add to final output array
array_push($JSONOutput, $Details);

// Encode and return data!!
echo json_encode(array("results" => $JSONOutput, "total_results" => $TotalResults));
Reply With Quote
Old 22nd August 2016, 17:20
firefly007's Avatar
firefly007 firefly007 is offline
Join Date: Jun 2010
Posts: 682
Hi, welcome to Bvlist :)

I'm having a look...

Due to free time I'm able to help interested member's with their tracker.

Please Note!
Depending on your requests I will charge you for my assistance for Tracker installs and mods.
All my mods are custom and prices will very depending on the request.

I'm able to install any tracker and mods including themes.

Please PM me

Reply With Quote


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 06:11. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2020, vBulletin Solutions Inc.