© nexus 2005

Details  
Author: nexus (apk)
Date: 22/11/2005
Version: 1.0
Source: tbsource-0705 & tbdev 0905
Greets:
MrMister Original author this guide - great work, it just needed updating a little!
 Redbeard For creating torrentbits.org!thanks :)
Skorpias For some code work!
ColdFusion For carrying on with the great work! Thanks tbdev.net!

Introduction  
Disclaimer
This guide was originally written in 2004 my MrMister. Since then the tbsource has been chopped and changed and is now tbdev. This guide is for the updated version. Its only version 1.0 so please be nice. This is only to be used as a reference so if it fucks up, please dont have a go at me:). Instead head over to http://www.tbdev.net

Table Of Contents
  I. Introduction To TorrentBits
II. Requirements
III. Installation
A. Extraction
1. .tar.bz2
2. .tar.gz
B. SQL
1. DB Creation
2. Code Insertion
C. Editing Config
1. Setting secrets.php
2. Setting up bittorrent.php
3. Static Edits
a. URL on HomePage
b. FAQ
c. Staff Page
1. Dynamic Staff Page
2. Static Staff Page
D. Making Yourself Staff
E. Filling in the Blanks
1. Adding the Poll
2. Creating Forums
3. Deleting the Call of Duty section
4. Adding Other Staff
F. Finalization
1. Allowing Uploads
2. Updating PeerGuardian
IV. Bugfixing
V. Upgrading
I.
Introduction to TorrentBits
TorrentBits.org was a revolutionary torrent tracker script. The site was very popular but was closed for sharing illegal files. However tbsource still lives on! The script has since grown and grown with more fixes being released all the time.
II.
Requirements
  • Apache
  • PHP4 or PHP5
  • MySQL
  • A way to edit your MySQL databases, preferably PHPMyAdmin
III.
Installation
This guide is for all to use. Although it does take about 20 minutes to complete. Make sure you have a nice cold beer (no American beer!) or glass of water. Please note: This can be a little confusing for people who are new to php and sql.
A.
Extraction
Get the latest version of tbsource/tbdev from:
http://sourceforge.net/projects/tbdevnet/
Once you have downloaded it unrar the file and upload to your server using a good ftp tool (like flashfxp). Once you have uploaded carry on reading. It is best to upload the content to a subdomain such as http://sub.yoursite.com rather than http://www.yoursite.com/sub however for this guide we are going to use http://www.yoursite.com/tb as the example as it takes less time to write.
B.
SQL
This section is divided into 2 parts; (1) & (2). Part 1 is for people without phpmyadmin. Part 2 is for people with it installed.
1.
DB Creation
Note: I'm expecting you to know how to make a DB, if you don't, look around on the internet, or read the doc:
http://dev.mysql.com/doc/mysql/en/create-database.html
If you have cPanel, go to the SQL page and create a new database.  I'd reccomend the name 'tb'. After it's made it, it will be username_tb (replace username with whatever your username is).

Then create a user (tbusr is a good choice) and pass. It will turn into username_tbusr (again, username = your username). The pass will not be altered, though.

Now that you have created the database and the user (in cpanel), select the username_tbusr and username_tb in the dropdown boxes right under the list of databases. Then click "Add User to DB".

Congrats, the DB has been made. Please note what database, username, and pass you used, you will need this information later. If you didn't use cpanel, you shouldn't have even needed this section, as you're a pro.
2.
Insertion
Note: This is LOTS easier when you have phpmyadmin installed.  If you want to get it, go to http://www.phpmyadmin.net/ , but I will not assist you in setting it up.

When you have extracted the file, there will be several .sql files included, and they are ALL important. Open them up one by one and insert them into your database. Make sure you insert database.sql first.
C. Editing Config
There are quite a few parts to the configuration, some confusing.  You were warned when you started reading this.
1.
Setting up secrets.php
This is one of the easiest parts of the installation, apart from extracting the php.

Go to the directory/folder you extracted the TBSource into.
Open the 'includes' directory.
Edit " secrets.php ". It is easy to understand, it should come out like so.
<?

$mysql_host = "localhost";
$mysql_user = "username_tbusr";
$mysql_pass = "password";
$mysql_db = "username_tb";

?>


Where the 'mysql_user' is the username you used earlier, the mysql_pass is the pass you set earlier, and the mysql_db is the database you made earlier.
2.
Setting up bittorrent.php

You'll be editing the part at the top, please do NOT touch the code at the bottom unless instructed to by me.

Maximum Users
First, $maxusers sets how many users can join your site. Set this to whatever number you like, when your user count hits that number, no more signups will be allowed until the automatic pruning opens a slot.

Torrent Directory
Next, $torrent_dir is where the .torrent files will be stored. This does NOT have to be in a public folder. However, since it's unlikely you'll be running this script on a dedicated server, please set it to full/path/to/account/tb/torrents. If you are unsure about the full path, please ask your host. Remember this directory, you'll need it later.

Annouce
Now, you need to sort out the $announce_urls array. Please change the first one to your domain with the location of the tbsource, and append announce.php:80 to it. (such as http://www.yoursite.com/tb/announce.php:80). I doubt you'll be using other ports, but if you ever do, you can easily add to or edit this area.

Base Address
After that, the $DEFAULTBASEURL is your websites URL. Please enter the address of your website (such as http://www.yoursite.com/tb (DO NOT put a slash at the end).

Private Site?
Now you are able to choose the made the site members only using $MEMBERSONLY and setting it to true or false. True means users must sign up to use it, false means anyone can use it.

Maximum Peers
The $PEERLIMIT option will not actually stop people from downloading, it will delete older torrents when the total amount of peers exceeds the limit, in order to make room. I recommend you leave this as a high number, the default (as of this writing) is 50000.

Sites Email Address
The $SITEEMAIL is the email address people will see as the 'sender' to their sign up emails. As well, the $SITENAME is the name people will see on the front page and in the email as well.

That's all for bittorrent.php.

3.
Static Edits
These edits will take place only on the page you edit them, unlike the dynamic edits in bittorrent.php which affect the whole site.
a.
URL on HomePage

Edit index.php
Scroll down to the bottom and find the Disclaimer. Replace the
(www.torrentbits.org)
with your own site, or this code (to make it depend on bittorrent.php, doesnt make ANY extra load on your server, so this is a good idea) provided here.
(<?PHP echo $DEFAULTBASEURL ?>)
Save the file, you're done.
b.
FAQ
You can edit the faq if you like, it's faq.php, but that's really up to you, I'm just here to tell you that you have to edit the php, it's not in the DB, and there is no tool to do this. You can open the file in dreamweaver (of whatever tool you use) and do a find and replace, search for torrentbits, http://www.torrentbits.org and RedBeard and replace with your site name/admin name (redbeard).
c.
Staff Page
You can have a static (current, but blank) page, which decreases load on the mysql server, but doesnt show if the users are online, and isn't as easy to make.

If your site isn't going to be used too stressfully, or it can handle the load, use the dynamic version. I'll cover both.
1.
Dynamic Staff Page
Warning! This adds a very small load onto the server.

It's a large piece of code, here's what it'll be replacing.
<? begin_frame("Staff"); ?>
<? end_frame(); ?>

<? begin_frame("Current uploaders"); ?>
<? end_frame(); ?>

<? begin_frame("Moderators"); ?>
<? end_frame(); ?>
That's the old code. Replace with:

<?
// Get current datetime
$dt = gmtime() - 180;
$dt = sqlesc(get_date_time($dt));
// Search User Database for Moderators and above and display in alphabetical order
$res = mysql_query("SELECT * FROM users WHERE class>=".UC_MODERATOR.
" AND status='confirmed' ORDER BY username" ) or sqlerr();
while ($arr = mysql_fetch_assoc($res))
{
$staff_table[$arr['class']]=$staff_table[$arr['class']].
"<td class=embedded><a class=altlink href=userdetails.php?id=".$arr['id'].">".
$arr['username']."</a><sup><font color=#".
("'".$arr['last_access']."'">$dt?"000066>On":"999999>Off" )."line</font></sup></td>".
"<td class=embedded><a href=sendmessage.php?receiver=".$arr['id'].">".
"<img src=".$pic_base_url."button_pm.gif border=0></a></td>".
"<td class=embedded><a href=mailto:".$arr['email'].">".
"<img src=".$pic_base_url."button_mail.gif border=0 alt=".$arr['email']."></a></td>";
// Show 3 staff per row, separated by an empty column
++ $col[$arr['class']];
if ($col[$arr['class']]<=3)
$staff_table[$arr['class']]=$staff_table[$arr['class']]."<td class=embedded>&nbsp;</td>";
else
{
$staff_table[$arr['class']]=$staff_table[$arr['class']]."</tr><tr height=15>";
$col[$arr['class']]=1;
}
}
?>

<table width=725 cellspacing=0>
<tr>
<!-- Define table column widths -->
<td class=embedded width="125"><b>SysOp</b></td>
<td class=embedded width="25">&nbsp;</td>
<td class=embedded width="35">&nbsp;</td>
<td class=embedded width="85">&nbsp;</td>
<td class=embedded width="125">&nbsp;</td>
<td class=embedded width="25">&nbsp;</td>
<td class=embedded width="35">&nbsp;</td>
<td class=embedded width="85">&nbsp;</td>
<td class=embedded width="125">&nbsp;</td>
<td class=embedded width="25">&nbsp;</td>
<td class=embedded width="35">&nbsp;</td>
</tr>
<tr>
<td class=embedded colspan=11><hr color="#4040c0" size=1></td>
</tr>
<tr height=15>
<?=$staff_table[UC_SYSOP]?>
</tr>
<tr><td class=embedded colspan=11>&nbsp;</td></tr>
<tr><td class=embedded colspan=11><b>Administrators</b></td></tr>
<tr><td class=embedded colspan=11><hr color="#4040c0" size=1></td></tr>
<tr height=15>
<?=$staff_table[UC_ADMINISTRATOR]?>
</tr>
<tr><td class=embedded colspan=11>&nbsp;</td></tr>
<tr><td class=embedded colspan=11><b>Moderators</b></td></tr>
<tr><td class=embedded colspan=11><hr color="#4040c0" size=1></td></tr>
<tr height=15>
<?=$staff_table[UC_MODERATOR]?>
</tr>
</table>

It includes the online status and such. I would recommend it, but please back up your original staff.php which you will use if you find this dynamic version too demanding (unlikely,lol)

2.
Static Staff Page
To use this I recommend you use the dynnamic code just once, copy the source code from that for the admins, paste it in the static, and repeat for all the groups. This will result in a very nice layout with a minimal amount of work.
D.
Making Yourself Staff
Now the hard part is over, this is the part where you become a user! Sign up as usual, entering all details. Now open your tbsource/tbdev database (phpmyadmin) and select the users table (near the bottom), then click browse. Find your name and change the 'class' to '6'.

Now your a sysop!

E.
Filling in the Blanks
Now when you load up the site you will see an error, it looks nasty but its not! All you need to do is add a poll to the site.
1.
Adding the Poll
Go to http://www.yoursite.com/tb/makepoll.php and make a poll. Now this should be fixed.
2.
Creating Forums
If you planning on using the forums you will need to create them. There is no easy way to do this, it has to be done in phpmyadmin. Open phpmyadmin again and select the forums table.

Now click the insert tab.
Fill in the ID (1 is fine, then the next one is 2, and so on)
Fill in the Name (Like "General")
Fill in the Description ("Talk about anything here")

The next two areas, minclassread and minclasswrite, can be left at 0 if these are public forums. If you want a forum for uploaders and above, make it 3 in both areas.

This list shows the user classes available.
  • User = 0
  • Power User = 1
  • VIP = 2
  • Uploader = 3
  • Moderator = 4
  • Admin = 5
  • SysOp = 6
4.
Adding More Staff
Find out the username of person you want to make staff. Open phpmyadmin and change their class. (look above for class)
F.
Finalization
Now we are nearly done. Just a few more steps.
1.
Allowing Uploads
Remember that directory you created earlier for uploads? Well open your ftp client and CHMOD the directory as 0777 or 777. If 'recursive' is an option, check it, if not dont worry.
2.
PeerGuardian Blocklist
This bans allot of IP address for well known government agencies etc. If you want to use this then open your browser and enter http://www.yoursite.com/tb/importpg.php
IV.
BugFixing
Most of the bugs should have been fixed, however if you still have some please look at this section or download a new snapshot.

If you get complaints from users that when they click to download a torrent and they get a 404 saying the torrent could not be found then please read the following:

Edit details.php
Go to Line 166 (or around it) to find this code
print("<tr><td class=rowhead width=1%>Download</td><td width=99% align=left>
<a class=\"index\" href=\"download/$id/" . rawurlencode($row["filename"]) .
"\">" . htmlspecialchars($row["filename"]) . "</a></td></tr>");

Find: href=\"download/$id/"

Replace with: href=\"download.php/$id/"
V. Upgrading
If you want to upgrade, please be very careful and backup everything. The safest way is to upgrade one file at a time.

If you need any further support then please visit http://tbdev.net.

This guide is © nexus (apk) 2005. Original guide © MrMister 2004.
 tbdev © TbDev.net. tbsource © TorrentBits.org