MCPT代码 ·

Karma donations for 24 hours torrent free !!!

[password key=1225308762]

Add to config.php beside all other memcached expires values :

  • $INSTALLER09['expires']['free_for_day_counter'] = 60; // 60 = 60 seconds
  • $INSTALLER09['expires']['torrent_free_points'] = 60; // 60 = 60 seconds

Add this lower :

$INSTALLER09['torrent']['free_target'] = 2500;

Add new sql :

 

ALTER TABLE coins ADD tf_points INT(10) UNSIGNED NOT NULL DEFAULT '0';

ALTER TABLE torrents ADD f_points INT(10) NOT NULL DEFAULT '0';

details.php find :

  1. $tor_fields_ar_int = array(
  2.         'id',
  3.         'leechers',
  4.         'seeders',
  5.         'thanks',
  6.         'comments',
  7.         'owner',
  8.         'size',
  9.         'added',
  10.         'views',
  11.         'hits',
  12.         'numfiles',
  13.         'times_completed',
  14.         'points',
  15.         'last_reseed',
  16.         'category',
  17.         'free',
  18.         'freetorrent',
  19.         'silver',
  20.         'rating_sum',
  21.         'checked_when',
  22.         'num_ratings',
  23.         'mtime',
  24.         'checked_when'

Change to :

 $tor_fields_ar_int = array(
        'id',
        'leechers',
        'seeders',
        'thanks',
        'comments',
        'owner',
        'size',
        'added',
        'views',
        'hits',
        'numfiles',
        'times_completed',
        'points',
        'last_reseed',
        'category',
        'free',
        'freetorrent',
        'silver',
        'rating_sum',
    'checked_when',
        'num_ratings',
        'mtime',
        'checked_when',
'f_points',
    );
details.php页面找到以下函数
/** Mod by dokty, rewrote by pdq **/
$my_points = 0;
if (($torrent['torrent_points_'] = $mc1->get_value('coin_points_' . $id)) === false) {
$sql_points = sql_query('SELECT userid, points FROM coins WHERE torrentid=' . sqlesc($id));
$torrent['torrent_points_'] = array();
if (mysqli_num_rows($sql_points) !== 0) {
while ($points_cache = mysqli_fetch_assoc($sql_points)) $torrent['torrent_points_'][$points_cache['userid']] = $points_cache['points'];
}
$mc1->add_value('coin_points_' . $id, $torrent['torrent_points_'], 0);
}
$my_points = (isset($torrent['torrent_points_'][$CURUSER['id']]) ? (int)$torrent['torrent_points_'][$CURUSER['id']] : 0);
$HTMLOUT.= '<tr>
<td class="heading" valign="top" align="right">'.$lang['details_add_karma1'].'</td>
<td valign="top" align="left"><b>'.$lang['details_add_karma2'].'' . (int)$torrents['points'] . ''.$lang['details_add_karma3'].'' . $my_points . ''.$lang['details_add_karma4'].'<br /><br />
<a href="coins.php?id=' . $id . '&amp;points=10"><img src="' . $INSTALLER09['pic_base_url'] . '10coin.png" alt="10" title="'.$lang['details_add_kar10'].'" /></a>&nbsp;&nbsp;
<a href="coins.php?id=' . $id . '&amp;points=20"><img src="' . $INSTALLER09['pic_base_url'] . '20coin.png" alt="20" title="'.$lang['details_add_kar20'].'" /></a>&nbsp;&nbsp;
<a href="coins.php?id=' . $id . '&amp;points=50"><img src="' . $INSTALLER09['pic_base_url'] . '50coin.png" alt="50" title="'.$lang['details_add_kar50'].'" /></a>&nbsp;&nbsp;
<a href="coins.php?id=' . $id . '&amp;points=100"><img src="' . $INSTALLER09['pic_base_url'] . '100coin.png" alt="100" title="'.$lang['details_add_kar100'].'" /></a>&nbsp;&nbsp;
<a href="coins.php?id=' . $id . '&amp;points=200"><img src="' . $INSTALLER09['pic_base_url'] . '200coin.png" alt="200" title="'.$lang['details_add_kar200'].'" /></a>&nbsp;&nbsp;
<a href="coins.php?id=' . $id . '&amp;points=500"><img src="' . $INSTALLER09['pic_base_url'] . '500coin.png" alt="500" title="'.$lang['details_add_kar500'].'" /></a>&nbsp;&nbsp;
<a href="coins.php?id=' . $id . '&amp;points=1000"><img src="' . $INSTALLER09['pic_base_url'] . '1000coin.png" alt="1000" title="'.$lang['details_add_kar1000'].'" /></a></b>&nbsp;&nbsp;
<br />'.$lang['details_add_karma'].'</td></tr>';
添加

//=== Torrent free-o-meter (.) (.) == set the target amount for free leech
//=== get total points
//$mc1->delete_value('free_for_day_counter_'.$id);
//$mc1->delete_value('torrent_free_points_' . $id);
if(($tor_free_counter = $mc1->get_value('free_for_day_counter_'.$id)) === false) {
$total = sql_query('SELECT f_points FROM torrents WHERE id=' . sqlesc($id));
$total_row = mysqli_fetch_assoc($total);
$percent = number_format($total_row['f_points'] / $INSTALLER09['torrent']['free_target'] * 100, 2);
$mc1->cache_value('free_for_day_counter_'.$id, $percent, $INSTALLER09['expires']['free_for_day_counter']);
} else
$percent = $tor_free_counter;

switch ($percent)
{
case $percent >= 100:
$image_to_use = '<img src="'.$INSTALLER09['pic_base_url'].'bar_12.png" alt="'.$percent.'% so far!" title="Torrent free-o-meter '.$percent.'% full!!!" align="middle" />';
break;
case $percent >= 80:
$image_to_use = '<img src="'.$INSTALLER09['pic_base_url'].'bar_10.png" alt="'.$percent.'% so far!" title="Torrent free-o-meter '.$percent.'% full!!!" align="middle" />';
break;
case $percent >= 70:
$image_to_use = '<img src="'.$INSTALLER09['pic_base_url'].'bar_8.png" alt="'.$percent.'% so far!" title="Torrent free-o-meter '.$percent.'% full!!!" align="middle" />';
break;
case $percent >= 50:
$image_to_use = '<img src="'.$INSTALLER09['pic_base_url'].'bar_6.png" alt="'.$percent.'% so far!" title="Torrent free-o-meter '.$percent.'% full!!!" align="middle" />';
break;
case $percent >= 40:
$image_to_use = '<img src="'.$INSTALLER09['pic_base_url'].'bar_5.png" alt="'.$percent.'% so far!" title="Torrent free-o-meter '.$percent.'% full!!!" align="middle" />';
break;
case $percent >= 30:
$image_to_use = '<img src="'.$INSTALLER09['pic_base_url'].'bar_4.png" alt="'.$percent.'% so far!" title="Torrent free-o-meter '.$percent.'% full!!!" align="middle" />';
break;
case $percent >= 20:
$image_to_use = '<img src="'.$INSTALLER09['pic_base_url'].'bar_3.png" alt="'.$percent.'% so far!" title="Torrent free-o-meter '.$percent.'% full!!!" align="middle" />';
break;
case $percent >= 10:
$image_to_use = '<img src="'.$INSTALLER09['pic_base_url'].'bar_2.png" alt="'.$percent.'% so far!" title="Torrent free-o-meter '.$percent.'% full!!!" align="middle" />';
break;
default:
$image_to_use = '<img src="'.$INSTALLER09['pic_base_url'].'bar_0.png" alt="'.$percent.'% so far!" title="Torrent free-o-meter '.$percent.'% full!!!" align="middle" />';
break;
}
$i_gave_points = 0;
if (($torrent['torrent_ffd_points_'] = $mc1->get_value('torrent_free_points_' . $id)) === false) {
$sql_ffd_points = sql_query('SELECT userid, tf_points FROM coins WHERE torrentid=' . sqlesc($id));
$torrent['torrent_ffd_points_'] = array();
if (mysqli_num_rows($sql_ffd_points) !== 0) {
while ($ffd_cache = mysqli_fetch_assoc($sql_ffd_points)) $torrent['torrent_ffd_points_'][$ffd_cache['userid']] = $ffd_cache['tf_points'];
}
$mc1->add_value('torrent_free_points_' . $id, $torrent['expires']['torrent_ffd_points_'], $INSTALLER09['torrent_free_points']);
}
$i_gave_points = (isset($torrent['torrent_ffd_points_'][$CURUSER['id']]) ? (int)$torrent['torrent_ffd_points_'][$CURUSER['id']] : 0);
$HTMLOUT.= '<tr>
<td class="heading" valign="top" align="right"><i><b><u>Free for one day</u></b></i></td><br /><br />
<td class="heading" valign="top" align="left"><b>'.$INSTALLER09['torrent']['free_target'].'</b> points required to make this torrent free for 24 hours !<br /><br />'.$image_to_use.'<br /><br />
<b>In total ' . (int)$torrents['f_points'] . ' Karma Points have been given to this torrent for 24 hours freeleech of which ' . $i_gave_points . ' from you.</b><br /><br />
<a href="tf_points.php?id=' . $id . '&amp;tf_points=10">10</a>&nbsp;&nbsp;
<a href="tf_points.php?id=' . $id . '&amp;tf_points=20">20</a>&nbsp;&nbsp;
<a href="tf_points.php?id=' . $id . '&amp;tf_points=50">50</a>&nbsp;&nbsp;
<a href="tf_points.php?id=' . $id . '&amp;tf_points=100">100</a>&nbsp;&nbsp;
<a href="tf_points.php?id=' . $id . '&amp;tf_points=200">200</a>&nbsp;&nbsp;
<a href="tf_points.php?id=' . $id . '&amp;tf_points=500">500</a>&nbsp;&nbsp;
<a href="tf_points.php?id=' . $id . '&amp;tf_points=1000">1000</a>&nbsp;&nbsp;
<a href="tf_points.php?id=' . $id . '&amp;tf_points=2500">2500</a>&nbsp;&nbsp;
<br /><br />By clicking on the amounts you can give Karma Points making this torrent free for one day.<br /><br /></td></tr>';

// end

create and upload tf_points.php

[password key=密码]<?php
/**
|--------------------------------------------------------------------------|
| https://github.com/Bigjoos/ |
|--------------------------------------------------------------------------|
| Licence Info: WTFPL |
|--------------------------------------------------------------------------|
| Copyright (C) 2010 U-232 V5 |
|--------------------------------------------------------------------------|
| A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon. |
|--------------------------------------------------------------------------|
| Project Leaders: Mindless, Autotron, whocares, Swizzles. |
|--------------------------------------------------------------------------|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e )
\_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
*/
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'bittorrent.php');
require_once(INCL_DIR . 'user_functions.php');
dbconn();
loggedinorreturn();
$lang = array_merge(load_language('global'), load_language('coins'));
//== Torrent free for one day == based on dokty points for uploader ==//
$id = intval($_GET["id"]);
$tf_points = intval($_GET["tf_points"]);
if (!is_valid_id($id) || !is_valid_id($tf_points))
die();
$pointstogive = array(
"10",
"20",
"50",
"100",
"200",
"500",
"1000",
"2500"
);

if (!in_array($tf_points, $pointstogive))
stderr($lang['gl_error'], $lang['coins_you_cant_give_that_amount_of_points']);
$res = sql_query("SELECT 1 FROM coins WHERE torrentid=" . sqlesc($id) . " AND tf_points > 0 AND userid =" . sqlesc($CURUSER["id"])) or sqlerr(__FILE__, __LINE__);
$resd = mysqli_fetch_assoc($res);
if ($resd)
stderr($lang['gl_error'], $lang['coins_you_already_gave_points_to_this_torrent']);
$res1 = sql_query("SELECT owner, name, f_points FROM torrents WHERE id = " . sqlesc($id)) or sqlerr(__FILE__, __LINE__);
$row = mysqli_fetch_assoc($res1) or stderr($lang['gl_error'], $lang['coins_torrent_was_not_found']);
$userid = intval($row["owner"]);
if ($userid == $CURUSER["id"])
stderr($lang['gl_error'], $lang['coins_you_cant_give_your_self_points']);
if ($CURUSER["seedbonus"] < $tf_points)
stderr($lang['gl_error'], $lang['coins_you_dont_have_enough_points']);
$sql = sql_query('SELECT seedbonus ' . 'FROM users ' . 'WHERE id = ' . sqlesc($userid)) or sqlerr(__FILE__, __LINE__);
$User = mysqli_fetch_assoc($sql);
sql_query("INSERT INTO coins (userid, torrentid, tf_points) VALUES (" . sqlesc($CURUSER["id"]) . ", " . sqlesc($id) . ", " . sqlesc($tf_points) . ")") or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE users SET seedbonus=seedbonus-" . sqlesc($tf_points) . " WHERE id=" . sqlesc($CURUSER["id"])) or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE torrents SET f_points=f_points+" . sqlesc($tf_points) . " WHERE id=" . sqlesc($id)) or sqlerr(__FILE__, __LINE__);

//Enough points donated -> Extra query added for points total -> Revise this
$FreeTime = 0;
$resfree = sql_query("SELECT f_points FROM torrents WHERE id = " . sqlesc($id)) or sqlerr(__FILE__, __LINE__);
$rows = mysqli_fetch_assoc($resfree);
if($rows['f_points'] >= $INSTALLER09['torrent']['free_target']){
$FreeTime = (TIME_NOW + 86400);
$Which_Free = (XBT_TRACKER === true ? 'freetorrent' : 'free');
$What_Var = (XBT_TRACKER === true ? '1' : $FreeTime);
sql_query("UPDATE torrents SET $Which_Free=".sqlesc($What_Var).", f_points='0' WHERE id=".sqlesc($id)) or sqlerr(__FILE__, __LINE__);
}

$update['freepoints'] = ($row['f_points'] + $tf_points);
$update['seedbonus_donator'] = ($CURUSER['seedbonus'] - $tf_points);
//==The torrent
$mc1->begin_transaction('torrent_details_' . $id);
$mc1->update_row(false, array(
'f_points' => $update['freepoints'],
'free' => $FreeTime
));
$mc1->commit_transaction($INSTALLER09['expires']['torrent_details']);
//==The donator
$mc1->begin_transaction('userstats_' . $CURUSER["id"]);
$mc1->update_row(false, array(
'seedbonus' => $update['seedbonus_donator']
));
$mc1->commit_transaction($INSTALLER09['expires']['u_stats']);
$mc1->begin_transaction('user_stats_' . $CURUSER["id"]);
$mc1->update_row(false, array(
'seedbonus' => $update['seedbonus_donator']
));
$mc1->commit_transaction($INSTALLER09['expires']['user_stats']);
//== delete the points cache
$mc1->delete_value('free_for_day_counter_'.$id);
$mc1->delete_value('torrent_free_points_' . $id);
header("Refresh: 3; url=details.php?id=$id");
stderr($lang['coins_done'], $lang['coins_successfully_gave_points_to_this_torrent']);

?>

[/password]

参与评论