Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > FreeTSP
Reply
  #1  
Old 24th March 2016, 00:50
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.

https://github.com/CouchPotato/Couch...rrent-provider

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

Code:
<?php

/*
* Written By: AtheistP3ace
* -> PiXELHD.me
* 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."));
die();
}

// 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());
exit();
}

$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."));
die();
}

$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
id,
name,
filename,
size,
imdbcode,
leechers,
seeders
FROM torrents
WHERE";
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 = "http://site.com/details.php?id=".$ResultRow['id'];

// Build download URL
$DownloadURL = "http://site.com/download.php/".$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
  #2  
Old 22nd August 2016, 17:20
firefly007's Avatar
firefly007 firefly007 is offline
SUPPORT GURU
 
Join Date: Jun 2010
P2P
Posts: 721
Default
Hi, welcome to Bvlist :)

I'm having a look...
__________________




Please Support Majority Report


You can contact me on Skype live:phesadent.elect but please let me know first.


If you are ever need me desperately then please email me at dan.oak44@gmail.com and I will contact u within a week.


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
Reply

Tags
couchpotatophp

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 23:38. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.