09 Freeslots By pdq

Started by Mindless, July 21, 2012, 07:20:44 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

denede

anyone has the modification for free_details.php ? i think it needs some minor modification because when i am in details i get Notice: Undefined index: free on line 79
well, that's not a problem, but it came to my mind that it was done a modification on the old tbdev forum

Hyperion (noobKID)


ErikZown

Quote from: noobKID on August 05, 2012, 11:33:14 AM
a question, might be a stupid one.
but need to be sure,
is this (only) the freeslot mod?... or can i set global freeleech on all torrents also?...

with other words, is this the (Freeleech/freeslots mod) i have been searching for? :)...

-thanks

Yes this is the global freeleech mod too.
You can set Freeleech for all torrents and/or double upload . :)

Hyperion (noobKID)

a question, might be a stupid one.
but need to be sure,
is this (only) the freeslot mod?... or can i set global freeleech on all torrents also?...

with other words, is this the (Freeleech/freeslots mod) i have been searching for? :)...

-thanks

Mindless

#1
Quote

'pdq'

looked at the freeslots mod i made a while ago last night and thought it needed rewriting for the newer TBDev version 09,
so here is what i have so far (tested! and mostly complete!) :)

there are quite a few differences and additions compared to the other mod, here are some:


  • can set individual torrents free forever or time based
  • can set all torrents free, double upload or both and can be forever or time based
  • can set freeleech status on users forever or timebased
  • removed some uneeded mysql table fields from old freeslots mod
  • some admin scripts to manage these things

Start

you need this SQL :)
Code (sql) Select

ALTER TABLE `torrents` ADD `free` int(11) unsigned NOT NULL default '0';
ALTER TABLE `users` ADD `freeslots` int(11) unsigned NOT NULL default '5';
ALTER TABLE `users` ADD `free_switch` int(11) unsigned NOT NULL default '0';
ALTER TABLE `users` ADD INDEX (`free_switch`);


Updated
Code (sql) Select
CREATE TABLE `freeslots` (
  `tid` int(10) unsigned NOT NULL,
  `uid` int(10) unsigned NOT NULL,
  `double` int(10) unsigned NOT NULL default '0',
  `free` int(10) unsigned NOT NULL default '0',
  UNIQUE KEY `tid_uid` (`tid`,`uid`)
);



i have installed this and have it working now, i have edited main post with the proper changes.
here is an attachment with all the new files needed for this mod.

as well i have included another zip (replacement_files.rar) inside this attachemnt containing all the files modified in the main post.

Can use replacement_files.rar if using tbdevnet - Revision 211: /trunk/TB and a fresh install otherwise can ignore it and do the edits as posted below. :P

Updated 10-07-09
updated 10/06/09
The Edits

Now, find in bittorrent.php:
Code (php) Select
require_once("cleanup.php");
add this below:
Code (php) Select
require_once ROOT_PATH.'/cache/free_cache.php';

Now, find in bittorrent.php:
Code (php) Select
function stdhead($title = "", $msgalert = true) {
    global $CURUSER, $TBDEV;

change to:
Code (php) Select
function stdhead($title = "", $msgalert = true) {
    global $CURUSER, $TBDEV, $free;


Now, find in bittorrent.php:

Code (php) Select
if (isset($unread) && !empty($unread))

above that add:
Code (php) Select

//=== free addon start
if ($CURUSER) {
if (isset($free))
{
  foreach ($free as $fl)
    {
        switch ($fl['modifier'])
        {
            case 1:
                $mode = 'All Torrents Free';
                break;

            case 2:
                $mode = 'All Double Upload';
                break;

            case 3:
                $mode = 'All Torrents Free and Double Upload';
                break;

            default:
                $mode = 0;
        }
       
$htmlout .= ($fl['modifier'] != 0 ? '<table width="50%"><tr>
     <td class="colhead" colspan="3" align="center">'.$fl['title'].'<br />'.$mode.'</td>
   </tr>
   <tr>
     <td width="42" align="center">
     <img src="'.$TBDEV['baseurl'].'/pic/cat_free.gif" alt="FREE!" /></td>
     <td align="center">'.$fl['message'].' set by '.$fl['setby'].'<br />'.($fl['expires'] != 1 ?
'Until '.get_date($fl['expires'], 'DATE').' ('.mkprettytime($fl['expires'] - time()).' to go)' : '').'</td>
     <td width="42" align="center">
     <img src="'.$TBDEV['baseurl'].'/pic/cat_free.gif" alt="FREE!" /></td>
</tr></table>
<br />' : '');
}
}
}
//=== free addon end


userdetails.php, find:
Code (php) Select
$HTMLOUT .= "<tr><td class='rowhead'>Class</td><td align='left'>" . get_user_class_name($user["class"]) . "</td></tr>\n";
add this below:   
Code (php) Select

$HTMLOUT .= "<tr><td class='rowhead'>Freeleech Slots</td>
                 <td align='left'>".(int)$user['freeslots']."</td></tr>";
    $HTMLOUT .= "<tr><td class='rowhead'>Freeleech Status</td>
                 <td align='left'>".($user['free_switch'] != 0 ? 'FREE Status '.($user['free_switch'] > 1 ? 'Expires: '.get_date($user['free_switch'], 'DATE').' ('.mkprettytime($user['free_switch'] - time()).' to go) <br />':'Unlimited<br />'):'None')."</td></tr>";


and in the modcomment area:
find:
Code (php) Select
$HTMLOUT .= "<tr><td class='rowhead'>Reset passkey</td><td colspan=2><input type='checkbox' name='resetpasskey' value='1' /><font class='small'>Any active torrents must be downloaded again to continue leeching/seeding.</font></td></tr>";

above that add:
Code (php) Select
  if ($CURUSER['class'] >= UC_MODERATOR)
$HTMLOUT .= "<tr><td class='rowhead'>Freeleech Slots:</td><td colspan='2' align='left'>
<input type='text' size='6' name='freeslots' value='".(int)$user['freeslots']."' /></td></tr>";

if ($CURUSER['class'] == UC_SYSOP) {

$free_switch = $user['free_switch'] != 0;

$HTMLOUT .= "<tr><td class='rowhead'".(!$free_switch ? ' rowspan="2"' : '').
    ">Freeleech Status</td>
<td align='left' width='20%'>".($free_switch ?
    "<input name='free_switch' value='42' type='radio' />Remove Freeleech Status" :
    "No Freeleech Status Set")."</td>\n";

if ($free_switch)
{
    if ($user['free_switch'] == 1)
        $HTMLOUT .= '<td align="center">(Unlimited Duration)</td></tr>';
    else
        $HTMLOUT .= "<td align='center'>Until ".get_date($user['free_switch'], 'DATE'). " (".
            mkprettytime($user['free_switch'] - time()). " to go)</td></tr>";
} else
{
    $HTMLOUT .= '<td>Freeleech for <select name="free_switch">
    <option value="0">------</option>
    <option value="1">1 week</option>
    <option value="2">2 weeks</option>
    <option value="4">4 weeks</option>
    <option value="8">8 weeks</option>
    <option value="255">Unlimited</option>
    </select>       </td></tr>
    <tr><td colspan="2" align="left">PM comment:<input type="text" size="60" name="free_pm" /></td></tr>';
}
}


modtask.php
find:
Code (php) Select
// Add ModComment to the update set...
    $updateset[] = "modcomment = " . sqlesc($modcomment);

above that add:
Code (php) Select
// change freeslots
if ((isset($_POST['freeslots'])) && (($freeslots = $_POST['freeslots']) != ($curfreeslots = $user['freeslots'])))
{
    $modcomment = get_date(time(), 'DATE', 1)." - freeslots amount changed to '".$freeslots."' from '".
$curfreeslots."' by " . $CURUSER['username'] . ".\n" . $modcomment;
}
$updateset[] = 'freeslots = '.sqlesc($freeslots);

/// Set Freeleech Status Time based
if (isset($_POST['free_switch']) && ($free_switch =
    0 + $_POST['free_switch']))
{
    unset($free_pm);
    if (isset($_POST['free_pm']))
        $free_pm = $_POST['free_pm'];
    $subject = sqlesc('Notification!');
    $added = time();

    if ($free_switch == 255)
    {
        $modcomment = get_date($added, 'DATE', 1)." - Freeleech Status enabled by ".
$CURUSER['username'].".\nReason: $free_pm\n".$modcomment;
        $msg = sqlesc("You have received Freeleech Status from ".$CURUSER['username'].($free_pm ?
            "\n\nReason: $free_pm" : ''));
        $updateset[] = 'free_switch = 1';
    } elseif ($free_switch == 42)
    {
        $modcomment = get_date($added, 'DATE', 1)." - Freeleech Status removed by ".
$CURUSER['username'].".\n".$modcomment;
        $msg = sqlesc("Your Freeleech Status has been removed by ".
$CURUSER['username'].".");
$updateset[] = 'free_switch = 0';
    } else
    {
        $free_until = ($added + $free_switch * 604800);
        $dur = $free_switch.' week'.($free_switch > 1 ? 's' : '');
        $msg = sqlesc("You have received $dur Freeleech Status from ".
$CURUSER['username'].($free_pm ? "\n\nReason: $free_pm" : ''));
        $modcomment = get_date($added, 'DATE', 1)." - Freeleech Status for $dur by ".
$CURUSER['username'].".\nReason: $free_pm\n".$modcomment;
        $updateset[] = "free_switch = ".$free_until;
    }

    mysql_query("INSERT INTO messages (sender, receiver, subject, msg, added)
             VALUES (0, $userid, $subject, $msg, $added)") or sqlerr(__file__, __line__);
}


download.php find:
Code (php) Select

  @mysql_query("UPDATE torrents SET hits = hits + 1 WHERE id = $id");

below that line add this:

Code (php) Select
/** free mod for TBDev 09 by pdq **/
include ROOT_PATH.'/mods/freeslots_inc.php';
/** end **/


announce.php
find:
Code (php) Select
$user_query = mysql_query("SELECT id, uploaded, downloaded, class, enabled FROM users WHERE passkey=".sqlesc($passkey)) or err("Tracker error 2");

if ( mysql_num_rows($user_query) != 1 )

err("Unknown passkey. Please redownload the torrent from {$TBDEV['baseurl']}.");

$user = mysql_fetch_assoc($user_query);
if( $user['enabled'] == 'no' ) err('Permission denied, you\'re not enabled');


$res = mysql_query("SELECT id, banned, seeders + leechers AS numpeers, added AS ts FROM torrents WHERE info_hash = " .sqlesc($info_hash));//" . hash_where("info_hash", $info_hash));


change to:
Code (php) Select
$user_query = mysql_query("SELECT id, uploaded, downloaded, class, free_switch, enabled FROM users WHERE passkey=".sqlesc($passkey)) or err("Tracker error 2");

if ( mysql_num_rows($user_query) != 1 )

err("Unknown passkey. Please redownload the torrent from {$TBDEV['baseurl']}.");

$user = mysql_fetch_assoc($user_query);
if( $user['enabled'] == 'no' ) err('Permission denied, you\'re not enabled');


$res = mysql_query("SELECT torrents.id, torrents.banned, torrents.free, torrents.seeders + torrents.leechers AS numpeers, torrents.added AS ts, freeslots.free AS freeslot, freeslots.double AS doubleslot FROM torrents LEFT JOIN freeslots ON (torrents.id=freeslots.tid AND freeslots.uid=".sqlesc($user['id']).") WHERE info_hash = ".sqlesc($info_hash));//" . hash_where("info_hash", $info_hash));


new code for announce.php
change:
Code (php) Select
if ($upthis > 0 || $downthis > 0)
mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=".$user['id']) or err("Tracker error 3");


to:
Code (php) Select
if ($upthis > 0 || $downthis > 0)
{
/** free addon start **/
$isfree =   '';
$isdouble = '';
include 'cache/free_cache.php';
if (isset($free))
{
foreach ($free as $fl) {
$isfree =   ($fl['modifier'] == 1 || $fl['modifier'] == 3) && $fl['expires'] > TIME_NOW;
$isdouble = ($fl['modifier'] == 2 || $fl['modifier'] == 3) && $fl['expires'] > TIME_NOW;
}
}

if (!($user['free_switch'] != 0 || $isfree || $torrent['free'] != 0 || ($torrent['freeslot'] != 0)
))
$updq[0] = "downloaded = downloaded + $downthis";

$updq[1] = "uploaded = uploaded + ".(($torrent['doubleslot'] != 0 || $isdouble) ? ($upthis*2) : $upthis);

$udq=implode(',',$updq);
mysql_query("UPDATE users SET $udq WHERE id=".$user['id']) or err('Tracker error 3');
}



add this to your css file (1.css, 2.css):
Code (php) Select
.balloonstyle{
position:absolute;
top: -500px;
left: 0;
padding: 5px;
visibility: hidden;
border:1px solid #EAFF08;
font:normal 12px Verdana;
color: #FF6600;
line-height: 18px;
z-index: 100;
background-color: #FFFFD4;
width: 400px;
/*Remove below line to remove shadow. Below line should always appear last within this CSS*/
filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135,Strength=5);
}
#arrowhead{
z-index: 99;
position:absolute;
top: -500px;
left: 0;
visibility: hidden;
}
a.info{
    position:relative; /*this is the key*/
    z-index:24; /*background-color:#ccc;*/
    color:#000;
    text-decoration:none}
a.info:hover{z-index:25; background-color:#ff0}
a.info span{display: none}
a.info:hover span{ /*the span will display just on :hover state*/
    display:block;
    position:absolute;
    top:2em; left:2em; width:15em;
    border:1px solid #0cf;
    background-color:#cff; color:#000;
    text-align: center}


in details.php
change:
Code (php) Select
$res = mysql_query("SELECT torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, LENGTH(torrents.nfo) AS nfosz, torrents.last_action AS lastseed, torrents.numratings, torrents.name, IF(torrents.numratings < {$TBDEV['minvotes']}, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.comments, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, categories.name AS cat_name, users.username FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN users ON torrents.owner = users.id WHERE torrents.id = $id")

to:
Code (php) Select
$res = mysql_query("SELECT torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, LENGTH(torrents.nfo) AS nfosz, torrents.last_action AS lastseed, torrents.numratings, torrents.name, IF(torrents.numratings < {$TBDEV['minvotes']}, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.comments, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, categories.name AS cat_name, users.username, freeslots.free AS freeslot, freeslots.double AS doubleslot, freeslots.tid AS slotid, freeslots.uid AS slotuid FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN users ON torrents.owner = users.id LEFT JOIN freeslots ON (torrents.id=freeslots.tid AND freeslots.uid = {$CURUSER['id']}) WHERE torrents.id = $id")


find:
Code (php) Select
$HTMLOUT .= "<h1>$s</h1>\n";
below that add:
Code (php) Select
/** free mod for TBDev 09 by pdq **/
$clr = '#FF6600'; /// font color
$freeimg = '<img src="pic/freedownload.gif" border="0" alt="" />';
$doubleimg = '<img src="pic/doubleseed.gif" border="0" alt="" />';

$HTMLOUT .= '
<div id="balloon1" class="balloonstyle">
Once chosen this torrent will be Freeleech '.$freeimg.' until '.get_date($row['freeslot'], 'DATE').' and can be resumed or started over using the regular download link. Doing so will result in one Freeleech Slot being taken away from your total.</div>
<div id="balloon2" class="balloonstyle">
Once chosen this torrent will be Doubleseed '.$doubleimg.' until '.get_date($row['doubleslot'], 'DATE').' and can be resumed or started over using the regular download link. Doing so will result in one Freeleech Slot being taken away from your total.</div>

<script type="text/javascript" src="scripts/balloontip.js"></script>';
/** end **/




change:
Code (php) Select
$HTMLOUT .= "<tr><td class='rowhead' width='1%'>Download</td><td width='99%' align='left'><a class='index' href='download.php?torrent=$id'>" . htmlspecialchars($row["filename"]) . "</a></td></tr>";

to:
Code (php) Select

/** free mod for TBDev 09 by pdq **/
include ROOT_PATH.'/mods/free_details.php';
/** end **/


in browse.php
replace:
Code (php) Select
$query = "SELECT torrents.id, torrents.category, torrents.leechers, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.type,  torrents.comments,torrents.numfiles,torrents.filename,torrents.owner,IF(torrents.nfo <> '', 1, 0) as nfoav," .
// "IF(torrents.numratings < {$TBDEV['minvotes']}, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby $limit";
"categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby {$pager['limit']}";


with:
Code (php) Select
  $query = "SELECT torrents.id, torrents.category, torrents.leechers, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.type, torrents.free, torrents.comments,torrents.numfiles,torrents.filename,torrents.owner,IF(torrents.nfo <> '', 1, 0) as nfoav," .
// "IF(torrents.numratings < {$TBDEV['minvotes']}, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby $limit";
"categories.name AS cat_name, categories.image AS cat_pic, users.username, freeslots.tid, freeslots.uid, freeslots.free AS freeslot, freeslots.double AS doubleup FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id LEFT JOIN freeslots ON (torrents.id=freeslots.tid AND freeslots.uid={$CURUSER['id']}) $where $orderby {$pager['limit']}";



in include/torrenttable_functions.php
to show slots in use on browse, find:
Code (php) Select
$htmlout .= "'><b>$dispname</b></a>\n";
change it to:

Code (php) Select

/** FREE Torrent **/
$free_tag = ' <a class=info href="#">
            <b>[FREE]</b>
            <span>'.($row['free'] != 0 ? ($row['free'] > 1 ? '
            Expires: '.get_date($row['free'], 'DATE').'<br />
            ('.mkprettytime($row['free'] - time()).' to go)<br />' : 'Unlimited<br />') : '').'
            </span></a>';

/** Freeslot Slot in Use **/
$isdlfree = ($row['tid'] == $id && $row['uid'] == $CURUSER['id'] &&
            $row['freeslot'] != 0 ? '<a class=info href="#">
            <img src="'.$TBDEV['baseurl'].'/pic/freedownload.gif" alt="" />
            <span>Freeleech slot in use<br />'.($row['freeslot'] != 0 ? ($row['freeslot'] > 1 ? '
            Expires: '.get_date($row['freeslot'], 'DATE').'<br />                                             ('.mkprettytime($row['freeslot'] - time()).' to go)<br />' : 'Unlimited<br />') : '') : '').'
            </span></a>';

/** Double Upload Slot in Use **/
$isdouble = ($row['tid'] == $id && $row['uid'] == $CURUSER['id'] &&
            $row['doubleup'] != 0 ? ' <a class=info href="#">
            <img src="'.$TBDEV['baseurl'].'/pic/doubleseed.gif" alt="" />
            <span>Double Upload slot in use<br />'.($row['doubleup'] != 0 ? ($row['doubleup'] > 1 ? '
            Expires: '.get_date($row['doubleup'], 'DATE').'<br />
            ('.mkprettytime($row['doubleup'] - time()).' to go)<br />' : 'Unlimited<br />') : '') : '').'
           </span></a>';

$htmlout .= "'><b>$dispname</b></a>".$free_tag."<br />".$isdlfree.$isdouble;


in admin/index.php below:
Code (php) Select
<span class="btn"><a href="admin.php?action=news">Add/Edit News</a></span>

add:
Code (php) Select
<span class="btn"><a href="admin.php?action=freeslots">Manage Freeslots</a></span>

<span class="btn"><a href="admin.php?action=freeleech">Freeleech</a></span>

<span class="btn"><a href="admin.php?action=freeusers">Freeleech Users</a></span>


in admin.php find:
Code (php) Select
'news'            => 'news'

change it to:
Code (php) Select
'news'            => 'news',
'freeleech'       => 'freeleech',
'freeslots'       => 'freeslots',
'freeusers'       => 'freeusers'



and incleanup.php
Code (php) Select

mysql_query("UPDATE `freeslots` SET `double` = 0 WHERE `double` != 0 AND `double` < ".TIME_NOW) or sqlerr(__FILE__, __LINE__);
mysql_query("UPDATE `freeslots` SET `free` = 0 WHERE `free` != 0 AND `free` < ".TIME_NOW) or sqlerr(__FILE__, __LINE__);
mysql_query("DELETE FROM `freeslots` WHERE `double` = 0 AND `free` = 0") or sqlerr(__FILE__, __LINE__);
mysql_query("UPDATE `users` SET `free_switch` = 0 WHERE `free_switch` > 1 AND `free_switch` < ".TIME_NOW) or sqlerr(__FILE__, __LINE__);
mysql_query("UPDATE `torrents` SET `free` = 0 WHERE `free` > 1 AND `free` < ".TIME_NOW) or sqlerr(__FILE__, __LINE__);


takeedit.php
find:
Code (php) Select
if ($CURUSER['class'] > UC_MODERATOR) {
      if ( isset($_POST["banned"]) ) {
        $updateset[] = "banned = 'yes'";
        $_POST["visible"] = 0;
      }
      else
        $updateset[] = "banned = 'no'";
    }

replace with:
Code (php) Select
if ($CURUSER['class'] > UC_MODERATOR)
{
    if (isset($_POST["banned"]))
    {
        $updateset[] = "banned = 'yes'";
        $_POST["visible"] = 0;
    } else
        $updateset[] = "banned = 'no'";


        /// Set Freeleech on Torrent Time Based
    if (isset($_POST['free_length']) && ($free_length = 0 + $_POST['free_length']))
    {
        if ($free_length == 255)
            $free = 1;

        elseif ($free_length == 42)
            $free = (86400 + time());

        else
            $free = (time() + $free_length * 604800);

        $updateset[] = "free = ".sqlesc($free);
        write_log("Torrent $id ($name) set Free for ".($free != 1 ? "
Until ".get_date($free, 'DATE') : 'Unlimited')." by $CURUSER[username]");
    }
   
     if (isset($_POST['fl']) && ($_POST['fl'] == 1))
    {
        $updateset[] = "free = '0'";
        write_log("Torrent $id ($name) No Longer Free. Removed by $CURUSER[username]");
    }
    /// end freeleech mod
}

edit.php
find:
Code (php) Select
if (get_user_class() >= UC_MODERATOR) //($CURUSER["admin"] == "yes")
    {
      $HTMLOUT  .= tr("Banned", "<input type='checkbox' name='banned'" . (($row["banned"] == "yes") ? " checked='checked'" : "" ) . " value='1' /> Banned", 1);
    }

below that add:
Code (php) Select

if ($CURUSER['class'] >= UC_MODERATOR)
    {
      $HTMLOUT  .= tr("Free Leech", ($row['free'] != 0 ?
  "<input type='checkbox' name='fl' value='1' /> Remove Freeleech" : "
    <select name='free_length'>
    <option value='0'>------</option>
    <option value='42'>Free for 1 day</option>
    <option value='1'>Free for 1 week</option>
    <option value='2'>Free for 2 weeks</option>
    <option value='4'>Free for 4 weeks</option>
    <option value='8'>Free for 8 weeks</option>
    <option value='255'>Unlimited</option>
    </select>"), 1);
    }
   
    if ($row['free'] != 0) {
    $HTMLOUT  .= tr("Free Leech Duration",
($row['free'] != 1 ? "Until ".get_date($row['free'],'DATE')."
(".mkprettytime($row['free'] - time())." to go)" : 'Unlimited'), 1);


    }


upload.php
find:
Code (php) Select
$HTMLOUT .= "<tr>
        <td class='heading' valign='top' align='right'>Type</td>
        <td valign='top' align='left'>$s</td>
      </tr>

below that add:
Code (php) Select
<tr>
        <td class='heading' valign='top' align='right'>Free Leech</td>
        <td valign='top' align='left'>
    <select name='free_length'>
    <option value='0'>Not Free</option>
    <option value='42'>Free for 1 day</option>
    <option value='1'>Free for 1 week</option>
    <option value='2'>Free for 2 weeks</option>
    <option value='4'>Free for 4 weeks</option>
    <option value='8'>Free for 8 weeks</option>
    <option value='255'>Unlimited</option>
    </select></td>
      </tr>

takeupload.php
below:
Code (php) Select
/////////////////////// NFO FILE END /////////////////////

add:
Code (php) Select
/// Set Freeleech on Torrent Time Based
$free = 0;
if (isset($_POST['free_length']) && ($free_length = 0 + $_POST['free_length']))
{
    if ($free_length == 255)
        $free = 1;

    elseif ($free_length == 42)
        $free = (86400 + time());

    else
        $free = (time() + $free_length * 604800);
}
/// end


now find the query and add free, and $free, into it like so:
Code (php) Select
$ret = mysql_query("INSERT INTO torrents (search_text, filename, owner, visible, info_hash, name, size, numfiles, type, descr, ori_descr, category, free, save_as, added, last_action, nfo, client_created_by) VALUES (".
    implode(",", array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"),
    $fname, $CURUSER["id"], "no", $infohash, $torrent, $totallen, count($filelist),
    $type, $descr, $descr, 0 + $_POST["type"], $free, $dname))).", ".time().", ".time().
    ", $nfo, $tmaker)");



Optional:
if you use seedbonus, can add like this
Code (sql) Select
INSERT INTO `bonus` VALUES (11, '3 Freeleech Slots', 999.9, 'With enough bonus points acquired, you are able to exchange them for some Freeleech Slots. The points are then removed from your Bonus Bank and the slots are added to your free slots amount.', 'freeslots', 3);

mybonus.php
Code (php) Select
case ($_GET['freeslots_success']):
I_smell_a_rat($_GET['freeslots_success']);

stdhead($CURUSER['username'] . "'s Karma Bonus Page");
echo'<table width="80%"><tr><td class="colhead" align="left" colspan="2"><h1>Success!</h1></td></tr><tr><td align="left" class="clearalt6">',
'<img src="'.$TBDEV['baseurl'].'/pic/smilies/karma.gif" alt="good karma" /></td><td align="left" class="clearalt6">',
'<b>Congratulations! </b>'.$CURUSER['username'].' you have got your self 3 freeleech slots! <img src="'.$TBDEV['baseurl'].'/pic/smilies/w00t.gif" alt="w00t" /><br /><br />'.
' click to go back to your <a class="altlink" href="mybonus.php">Karma Bonus Point</a> page.<br /><br /></td></tr></table>';
stdfoot();
die;


and
Code (php) Select
case 'freeslots':
//=== trade for freeslots
$freeslots = $CURUSER['freeslots'];
$slots = $freeslots+$arr_points['menge'];
$bonuscomment = gmdate("Y-m-d") . " - " .$points. " Points for freeslots.\n " .$bonuscomment;
mysql_query("UPDATE users SET freeslots = '$slots', seedbonus = '$seedbonus' WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__);
header("Refresh: 0; url={$TBDEV['baseurl']}/pic/karma?freeslots_success=1");
die;
break;


suggestions and testing welcomed =]

[attachment deleted by admin]