Mody & Porady

Tutaj znajduje się zbiór dostępnych dla TBDEV.NET modów oraz porad jak właściwie zmodyfikować skrypt naszego trackera.

AutoBackup

Chciałem dodać tutaj bardzo interesujący mod, i przy okazji bardzo praktyczny. Tyle się słyszy o włamaniach na konkurencyjne stronki torrentowe różnych Hackerów. By spać bezpiecznie warto robić Backupy ale są one nieco uciążliwe.





Oto mod który będzie nam automatycznie robił Backupy i wysyłał na dowolny adres e-mail.





tb



tb


mysql.backup.rar
Pobierz Plik ściągnięto 0 raz(y) 2,31 KB

FreeLeech

Instrukcja:



1. My najpierw musimy utworzyć nową kolumnę w phpmyadmin ( w bazie MySQL ) w tabeli "torrents"


Kod:
ALTER TABLE `torrents` ADD `freeleech` VARCHAR( 3 ) DEFAULT 'no' NOT NULL;





2. Nastepnie edytujemy plik announce.php



Znajdź poniższą linijkę ( powinna być 170)


Kod:
  if ($upthis > 0 || $downthis > 0)

        mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error 3");





Zamień ja na:


Kod:
  if ($upthis > 0 || $downthis > 0)

    {

        $freelech = mysql_query("SELECT * FROM torrents WHERE id='$torrentid' AND freeleech='yes'");

        if (mysql_num_rows($freelech) == 1)

        {

                    mysql_query("UPDATE users SET uploaded = uploaded + $upthis WHERE id=$userid") or err("Tracker error 3");

        }

        else

        {

                    mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error 3");

        }

    }





3. Teraz utwórz nowy plik freeleech.php w głównym katalogu i wklej poniższy kod do niego:


Kod:
echo "<table width=\"500\" border=\"0\">

  <tr>

    <td class=rowhead><center>Id</center></td>

    <td class=rowhead><center>Ime</center></td>

    <td class=rowhead><center>FreeLeech</center></td>

    </tr>"; // Ime = Name



   



while ($vrstica = mysql_fetch_array($rezultat))

{

    echo "

  <tr>

    <td><center>$vrstica[id]</center></td>

    <td><center><a href=\"http://www.slo-scene.net/details.php?id=$vrstica[id]\" target=\"_blank\">".format_comment($vrstica[name])."</a></center></td>

        <td><center><a href=\"freeleech.php?akcija=odstrani&odstraniid=$vrstica[id]\">Odstrani</a></center></td>

    </tr>"; // Odstrani = Remove

}

echo "</table><br /><br />Copyrights &#169; for free leech by Kami</div>";



if ($akcija == "odstrani")

{

    $rezultat = mysql_query("SELECT * from torrents WHERE id='$odstraniid'");

    mysql_query("UPDATE torrents SET freeleech='no' WHERE id='$odstraniid'");

   

    while ($vrstica = mysql_fetch_array($rezultat))

    {

        $ime = str_replace(" [FreeLeech]", " ", $vrstica[name]);

        mysql_query("UPDATE torrents SET name='$ime' WHERE id='$odstraniid'");

    }

   

    header("Location: freeleech.php?napaka=3");

}

stdfoot();

die();

?>





To wygląda mniej więcej tak:



freeleech



4. Teraz musimy edytować plik bittorrent.php



Znajdź to:


Kod:
$dispname = htmlspecialchars($row["name"]);





Zamień na to:


Kod:
$dispname = format_comment(htmlspecialchars($row["name"]));





5. Teraz zedytujemy plik userdetails.php



Znajdź to:


Kod:
  while ($a = mysql_fetch_assoc($r))

  {

        $r2 = mysql_query("SELECT name, image FROM categories WHERE id=$a[category]") or sqlerr(__FILE__, __LINE__);

        $a2 = mysql_fetch_assoc($r2);

        $cat = "<img src=\"/pic/$a2[image]\" alt=\"$a2[name]\">";

      $torrents .= "<tr><td style='padding: 0px'>$cat</td><td><a href=details.php?id=" . $a["id"] . "&hit=1><b>" . htmlspecialchars($a["name"]) . "</b></a></td>" .

        "<td align=right>$a[seeders]</td><td align=right>$a[leechers]</td></tr>\n";

  }





Zamień na to:


Kod:
  while ($a = mysql_fetch_assoc($r))

  {

  $r2 = mysql_query("SELECT name, image FROM categories WHERE id=$a[category]") or sqlerr(__FILE__, __LINE__);

  $a2 = mysql_fetch_assoc($r2);

  $cat = "<img src=\"/pic/$a2[image]\" alt=\"$a2[name]\">";

   $torrents .= "<tr><td style='padding: 0px'>$cat</td><td><a href=details.php?id=" . $a["id"] . "&hit=1><b>" .



format_comment(htmlspecialchars($a["name"])) . "</b></a></td>" .

  "<td align=right>$a[seeders]</td><td align=right>$a[leechers]</td></tr>\n";

  }





A następnie znajdź to:


Kod:
  $ret .= "<tr><td style='padding: 0px'><img src=\"pic/$catimage\" alt=\"$catname\" width=42 height=42></td>\n" .

        "<td><a href=details.php?id=$arr[torrent]&amp;hit=1><b>" . htmlspecialchars($arr["torrentname"]) .

        "</b></a></td><td align=center>$ttl</td><td align=center>$size</td><td align=right>$seeders</td><td align=right>$leechers</td><td align=center>$uploaded</td>\n" .

        "<td align=center>$downloaded</td><td align=center>$ratio</td></tr>\n";





i analogicznie zamień na to:


Kod:
$ret .= "<tr><td style='padding: 0px'><img src=\"pic/$catimage\" alt=\"$catname\" width=42 height=42></td>\n" .

        "<td><a href=details.php?id=$arr[torrent]&amp;hit=1><b>" . format_comment(htmlspecialchars($arr["torrentname"])) .

        "</b></a></td><td align=center>$ttl</td><td align=center>$size</td><td align=right>$seeders</td><td align=right>$leechers</td><td align=center>$uploaded</td>\n" .

        "<td align=center>$downloaded</td><td align=center>$ratio</td></tr>\n";





Z tym modem ty możesz robić na swojej stronce freeleech, Free Leech oznacza zliczanie tylko uploadu na wybranych torrentach

Kontrola Anonimowości

Utwórz nowyplik anonymous.php

<?php

require "include/bittorrent.php";

dbconn(true);

loggedinorreturn();

if (get_user_class() >= UC_MODERATOR) {

stdhead("");

begin_main_frame();

// ===================================

$unco = number_format(get_row_count("users", "WHERE class<'4' AND anonymous='yes'"));

begin_frame("Anonimowcy poniżej Lulka ($unco)", true);

begin_table();

?>

<form method="post" action="/takeanonymous.php">

<tr><td class="colhead">ID</td><td class="colhead" align="left">Username</td><td class="colhead">Wylacz Anonimowosc</td></tr>

<?

$res=mysql_query("SELECT id,username, class FROM users WHERE class < '4' AND anonymous='yes' ORDER BY id") or print(mysql_error());

// ------------------

while ($arr = @mysql_fetch_assoc($res)) {

echo "<tr><td>" . $arr[id] . "</td><td align=\"left\"><b><a href=userdetails.php?id=" . $arr[id] . " > " . $arr[username] . "</a></b></td><td><input type=\"checkbox\" name=\"delusr[]\" value=\"" . $arr[id] . "\" /></td></tr>";

}

?>

<tr><td colspan="5" align="right"><input type="submit" value="Dalej!" /></td></tr>

</form>

<?

// ------------------

end_table();

end_frame();

$unco2 = number_format(get_row_count("users", "WHERE anonymous='yes'"));

begin_frame("Anonimowcy ($unco2)", true);

begin_table();

?>

<form method="post" action="/takeanonymous.php">

<tr><td class="colhead">ID</td><td class="colhead" align="left">Username</td><td class="colhead">Wylacz Anonimowosc</td></tr>

<?

$res=mysql_query("SELECT id,username, class FROM users WHERE class < '11' AND anonymous='yes' ORDER BY id") or print(mysql_error());

// ------------------

while ($arr = @mysql_fetch_assoc($res)) {

echo "<tr><td>" . $arr[id] . "</td><td align=\"left\"><b><a href=userdetails.php?id=" . $arr[id] . " > " . $arr[username] . "</a></b></td><td><input type=\"checkbox\" name=\"delusr[]\" value=\"" . $arr[id] . "\" /></td></tr>";

}

?>

<tr><td colspan="5" align="right"><input type="submit" value="Dalej!" /></td></tr>

</form>

<?

// ------------------

end_table();

end_frame();

// ===================================

end_main_frame();

stdfoot();

}

else {

stderr("Sorry", "Access denied!");

}

?>

Utwórz następnie plik takeanonymous.php

<?

require_once("include/bittorrent.php");

function bark($msg) {

stdhead();

stdmsg("Job failed...", $msg);

stdfoot();

exit;

}

dbconn();

loggedinorreturn();

if (get_user_class() > UC_MODERATOR) {

if (empty($_POST["delusr"]))

bark("Don't leave any fields blank.");

$do="UPDATE users SET anonymous='no' WHERE id IN (" . implode(", ", $_POST[delusr]) . ")";

$res=mysql_query($do);

}

header("Refresh: 0; url=/anonymous.php");

?>

 

Masowe Rozdawanie Zaproszeń

Mod, który pozwala dać wszystkim użytkownikom po 1 lub innej, zdefiniowanej przez nas liczbie zaproszeń.

http://img136.imageshack.us/img136/8521/invite4zs.jpg

Utworz plik massinvite.php i daj do niego kod:

<?

require_once('include/bittorrent.php');

dbconn();

loggedinorreturn();

if (get_user_class() < UC_ADMINISTRATOR)

stderr('Error', 'Access denied.');

if ($_POST['doit'] == 'yes') {

mysql_query("UPDATE users SET invites = invites + 1");

header("Location: /staff.php");

}

stdhead('Masowe rozdawanie zaproszeń');

?>

<h2>Po jednym zaproszeniu dla wszystkich użytkowników?</h2>

<font size=1>Czy jestes pewny, że chcesz dać wszystkim jedno dotkowe zaproszenie? </font><br /><br />

<form action="massinvite.php" method="post">

<table border=1 cellspacing=0 cellpadding=5><tr><td class="rowhead">

<input type = "hidden" name = "doit" value = "yes" />

<input type="submit" value="Tak!" />

</td></tr></table>

</form>

<? stdfoot(); ?>




Releasy z nForce.nl

Mod ten pokazuje, jaki są ostatnio wydane release na stronie nforce.nl. Korzysta on z plików xml



1.Utwórz plik nforce.php i dodaj do niego kod:

Kod:
<?php



ob_start("ob_gzhandler");



require_once("include/bittorrent.php");



dbconn(true);

stdhead();



include './lastRSS.php';



// create lastRSS object

$rss = new lastRSS; 



// setup transparent cache

$rss->cache_dir = './newsCache'; 

$rss->cache_time = 3600; // one hour

?>



<h2>Ostatnie release na nforce.nl</h2>

<table width=100% border="1" cellspacing="0" cellpadding="10" class="stats" background=images/mainbox_bg.jpg><tr><td align=center>

<table cellspacing="0" cellpadding="5" border="0" class=main border=1>

<tr>

<td width="50%" valign="top">

<table cellspacing="0" cellpadding="0" border="0" width="100%">

<tr>

<td class="upper"><strong>Ostatnie release DVD</strong></td>

</tr>

</table>

<font size="1">

<?

if ($rs = $rss->get('http://www.nforce.nl/rss/rss_18.xml')) {

foreach($rs['items'] as $item) {

echo "<a href=\"$item[link]\">".$item['title']."</a><br>\n";

}

}

else {

print ('Error: NForce not reachable...');

}

?>

</td>

<td width="50%" valign="top">

<table cellspacing="0" cellpadding="0" border="0" width="100%">

<tr>

<td class="upper"><strong>Ostatnie release SVCD</strong></td>

</tr>

</table>

<font size="1">

<?

if ($rs = $rss->get('http://www.nforce.nl/rss/rss_15.xml')) {

foreach($rs['items'] as $item) {

echo "<a href=\"$item[link]\">".$item['title']."</a><br>\n";

}

}

else {

print ('Error: NForce not reachable...');

}

?>



</td>

</tr>

<tr>

<td width="50%" valign="top">

<table cellspacing="0" cellpadding="0" border="0" width="100%">

<tr>

<td class="upper"><strong>Ostatnie release w kategorii Tv-Rip</strong></td>

</tr>

</table>

<font size="1">

<?

if ($rs = $rss->get('http://www.nforce.nl/rss/rss_19.xml')) {

foreach($rs['items'] as $item) {

echo "<a href=\"$item[link]\">".$item['title']."</a><br>\n";

}

}

else {

print ('Error: NForce not reachable...');

}

?>



</td>

<td width="50%" valign="top">

<table cellspacing="0" cellpadding="0" border="0" width="100%">

<tr>

<td class="upper"><strong>Ostatnie release XXX</strong></td>

</tr>

</table>

<font size="1">

<?

$max = 0;

if ($rs = $rss->get('http://www.nforce.nl/rss/rss_17.xml')) {

foreach($rs['items'] as $item) {

if ($max >= 10) { break; }

echo "<a href=\"$item[link]\">".$item['title']."</a><br>\n";

$max++;

}

}

else {

print ('Error: NForce not reachable...');

}

?>

</td>

</tr>

  <tr>

<td width="50%" valign="top">

<table cellspacing="0" cellpadding="0" border="0" width="100%">

<tr>

<td class="upper"><strong> PS2</strong></td>

</tr>

</table>

<font size="1">

<?

if ($rs = $rss->get('http://www.nforce.nl/rss/rss_9.xml')) {

foreach($rs['items'] as $item) {

echo "<a href=\"$item[link]\">".$item['title']."</a><br>\n";

}

}

else {

print ('Error: NForce not reachable...');

}

?>

</td>

<td width="50%" valign="top">

<table cellspacing="0" cellpadding="0" border="0" width="100%">

<tr>

<td class="upper"><strong>Ostatnie release na konsolę xBox</strong></td>

</tr>

</table>

<font size="1">

<?

if ($rs = $rss->get('http://www.nforce.nl/rss/rss_11.xml')) {

foreach($rs['items'] as $item) {

echo "<a href=\"$item[link]\">".$item['title']."</a><br>\n";

}

}

else {

print ('Error: NForce not reachable...');

}

?>



</td>

</tr>

<tr>

<td width="50%" valign="top">

<table cellspacing="0" cellpadding="0" border="0" width="100%">

<tr>

<td class="upper"><strong>Ostatnie release w kategori PC/ISo</strong></td>

</tr>

</table>

<font size="1">

<?

if ($rs = $rss->get('http://www.nforce.nl/rss/rss_2.xml')) {

foreach($rs['items'] as $item) {

echo "<a href=\"$item[link]\">".$item['title']."</a><br>\n";

}

}

else {

print ('Error: NForce not reachable...');

}

?>



</td>

<td width="50%" valign="top">

<table cellspacing="0" cellpadding="0" border="0" width="100%">

<tr>

<td class="upper"><strong>Ostatnie release w kategori Programy/PC ISO</strong></td>

</tr>

</table>

<font size="1">

<?

$max = 0;

if ($rs = $rss->get('http://www.nforce.nl/rss/rss_6.xml')) {

foreach($rs['items'] as $item) {

if ($max >= 10) { break; }

echo "<a href=\"$item[link]\">".$item['title']."</a><br>\n";

$max++;

}

}

else {

print ('Error: NForce not reachable...');

}

?>

</td>

</tr>

</table>

</td></tr></table>



<?

stdfoot();



?>

2.Utwórz plik lastRSS.php i dodaj do niego kod:

Kod:

<?php

/*

 ======================================================================

 lastRSS 0.9.1

 

 Simple yet powerfull PHP class to parse RSS files.

 

 by Vojtech Semecky, webmaster @ webdot . cz

 

 Latest version, features, manual and examples:

 http://lastrss.webdot.cz/



 ----------------------------------------------------------------------

 LICENSE



 This program is free software; you can redistribute it and/or

 modify it under the terms of the GNU General Public License (GPL)

 as published by the Free Software Foundation; either version 2

 of the License, or (at your option) any later version.



 This program is distributed in the hope that it will be useful,

 but WITHOUT ANY WARRANTY; without even the implied warranty of

 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

 GNU General Public License for more details.



 To read the license please visit http://www.gnu.org/copyleft/gpl.html

 ======================================================================

*/



/**

* lastRSS

* Simple yet powerfull PHP class to parse RSS files.

*/

class lastRSS {

// -------------------------------------------------------------------

// Public properties

// -------------------------------------------------------------------

var $default_cp = 'UTF-8';

var $CDATA = 'nochange';

var $cp = '';

var $items_limit = 0;

var $stripHTML = False;

var $date_format = '';



// -------------------------------------------------------------------

// Private variables

// -------------------------------------------------------------------

var $channeltags = array ('title', 'link', 'description', 'language', 'copyright', 'managingEditor', 

'webMaster', 'lastBuildDate', 'rating', 'docs');

var $itemtags = array('title', 'link', 'description', 'author', 'category', 'comments', 

'enclosure', 'guid', 'pubDate', 'source');

var $imagetags = array('title', 'url', 'link', 'width', 'height');

var $textinputtags = array('title', 'description', 'name', 'link');



// -------------------------------------------------------------------

// Parse RSS file and returns associative array.

// -------------------------------------------------------------------

function Get ($rss_url) {

// If CACHE ENABLED

if ($this->cache_dir != '') {

$cache_file = $this->cache_dir . '/rsscache_' . md5($rss_url);

$timedif = @(time() - filemtime($cache_file));

if ($timedif < $this->cache_time) {

// cached file is fresh enough, return cached array

$result = unserialize(join('', file($cache_file)));

// set 'cached' to 1 only if cached file is correct

if ($result) $result['cached'] = 1;

} else {

// cached file is too old, create new

$result = $this->Parse($rss_url);

$serialized = serialize($result);

if ($f = @fopen($cache_file, 'w')) {

fwrite ($f, $serialized, strlen($serialized));

fclose($f);

}

if ($result) $result['cached'] = 0;

}

}

// If CACHE DISABLED >> load and parse the file directly

else {

$result = $this->Parse($rss_url);

if ($result) $result['cached'] = 0;

}

// return result

return $result;

}



// -------------------------------------------------------------------

// Modification of preg_match(); return trimed field with index 1

// from 'classic' preg_match() array output

// -------------------------------------------------------------------

function my_preg_match ($pattern, $subject) {

// start regullar expression

preg_match($pattern, $subject, $out);



// if there is some result... process it and return it

if(isset($out[1])) {

// Process CDATA (if present)

if ($this->CDATA == 'content') { // Get CDATA content (without CDATA tag)

$out[1] = strtr($out[1], array('<![CDATA['=>'', ']]>'=>''));

} elseif ($this->CDATA == 'strip') { // Strip CDATA

$out[1] = strtr($out[1], array('<![CDATA['=>'', ']]>'=>''));

}



// If code page is set convert character encoding to required

if ($this->cp != '')

//$out[1] = $this->MyConvertEncoding($this->rsscp, $this->cp, $out[1]);

$out[1] = iconv($this->rsscp, $this->cp.'//TRANSLIT', $out[1]);

// Return result

return trim($out[1]);

} else {

// if there is NO result, return empty string

return '';

}



}



// -------------------------------------------------------------------

// Replace HTML entities &something; by real characters

// -------------------------------------------------------------------

function unhtmlentities ($string) {

// Get HTML entities table

$trans_tbl = get_html_translation_table (HTML_ENTITIES, ENT_QUOTES);

// Flip keys<==>values

$trans_tbl = array_flip ($trans_tbl);

// Add support for &apos; entity (missing in HTML_ENTITIES)

$trans_tbl += array('&apos;' => "'");

// Replace entities by values

return strtr ($string, $trans_tbl);

}



// -------------------------------------------------------------------

// Parse() is private method used by Get() to load and parse RSS file.

// Don't use Parse() in your scripts - use Get($rss_file) instead.

// -------------------------------------------------------------------

function Parse ($rss_url) {

// Open and load RSS file

if ($f = @fopen($rss_url, 'r')) {

$rss_content = '';

while (!feof($f)) {

$rss_content .= fgets($f, 4096);

}

fclose($f);



// Parse document encoding

$result['encoding'] = $this->my_preg_match("'encoding=[\'\"](.*?)[\'\"]'si", $rss_content);

// if document codepage is specified, use it

if ($result['encoding'] != '')

{ $this->rsscp = $result['encoding']; } // This is used in my_preg_match()

// otherwise use the default codepage

else

{ $this->rsscp = $this->default_cp; } // This is used in my_preg_match()



// Parse CHANNEL info

preg_match("'<channel.*?>(.*?)</channel>'si", $rss_content, $out_channel);

foreach($this->channeltags as $channeltag)

{

$temp = $this->my_preg_match("'<$channeltag.*?>(.*?)</$channeltag>'si", $out_channel[1]);

if ($temp != '') $result[$channeltag] = $temp; // Set only if not empty

}

// If date_format is specified and lastBuildDate is valid

if ($this->date_format != '' && ($timestamp = strtotime($result['lastBuildDate'])) !==-1) {

// convert lastBuildDate to specified date format

$result['lastBuildDate'] = date($this->date_format, $timestamp);

}



// Parse TEXTINPUT info

preg_match("'<textinput(|[^>]*[^/])>(.*?)</textinput>'si", $rss_content, $out_textinfo);

// This a little strange regexp means:

// Look for tag <textinput> with or without any attributes, but skip truncated version <textinput />

(it's not beggining tag)

if (isset($out_textinfo[2])) {

foreach($this->textinputtags as $textinputtag) {

$temp = $this->my_preg_match("'<$textinputtag.*?>(.*?)</$textinputtag>'si", $out_textinfo[2]);

if ($temp != '') $result['textinput_'.$textinputtag] = $temp; // Set only if not empty

}

}

// Parse IMAGE info

preg_match("'<image.*?>(.*?)</image>'si", $rss_content, $out_imageinfo);

if (isset($out_imageinfo[1])) {

foreach($this->imagetags as $imagetag) {

$temp = $this->my_preg_match("'<$imagetag.*?>(.*?)</$imagetag>'si", $out_imageinfo[1]);

if ($temp != '') $result['image_'.$imagetag] = $temp; // Set only if not empty

}

}

// Parse ITEMS

preg_match_all("'<item(| .*?)>(.*?)</item>'si", $rss_content, $items);

$rss_items = $items[2];

$i = 0;

$result['items'] = array(); // create array even if there are no items

foreach($rss_items as $rss_item) {

// If number of items is lower then limit: Parse one item

if ($i < $this->items_limit || $this->items_limit == 0) {

foreach($this->itemtags as $itemtag) {

$temp = $this->my_preg_match("'<$itemtag.*?>(.*?)</$itemtag>'si", $rss_item);

if ($temp != '') $result['items'][$i][$itemtag] = $temp; // Set only if not empty

}

// Strip HTML tags and other bullshit from DESCRIPTION

if ($this->stripHTML && $result['items'][$i]['description'])

$result['items'][$i]['description'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['description'])));

// Strip HTML tags and other bullshit from TITLE

if ($this->stripHTML && $result['items'][$i]['title'])

$result['items'][$i]['title'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['title'])));

// If date_format is specified and pubDate is valid

if ($this->date_format != '' && ($timestamp = strtotime($result['items'][$i]['pubDate'])) !==-1) {

// convert pubDate to specified date format

$result['items'][$i]['pubDate'] = date($this->date_format, $timestamp);

}

// Item counter

$i++;

}

}



$result['items_count'] = $i;

return $result;

}

else // Error in opening return False

{

return False;

}

}

}



?>

 

3.Screen:



a

Tłumaczenie: Kuba1530

Mod napisany przez Wilba

Statystyki na forum

Poniższa modyfikacja dodaje statystyki na forum TBDEV.NET

1. Znajdź w pliku forums.php

print("</table>\n");

print("<p align=center><a href=?action=search><b>Search</b></a> | <a href=?action=viewunread><b>View unread</b></a> | <a href=?catchup><b>Catch up</b></a></p>");

Dodaj po tym:

print("<tr><td class=colhead>Statystki forum</td></tr>\n");

$registered = number_format(get_row_count("users", "WHERE enabled = 'yes'"));

$a = @mysql_fetch_assoc(@mysql_query("SELECT id,username FROM users WHERE status='confirmed' ORDER BY id DESC LIMIT 1")) or die(mysql_error());

if ($CURUSER)

$latestuser = "<a href=userdetails.php?id=" . $a["id"] . ">" . $a["username"] . "</a>";

else

$latestuser = $a['username'];

$totalonline = number_format(get_row_count("users", "WHERE UNIX_TIMESTAMP(" . get_dt_num() . ") - UNIX_TIMESTAMP(last_access) < 1200"));

$topiccount = mysql_query("select sum(topiccount) as topiccount from forums");

$row1 = mysql_fetch_array($topiccount);

$topiccount = $row1[topiccount];

$postcount = mysql_query("select sum(postcount) as postcount from forums");

$row2 = mysql_fetch_array($postcount);

$postcount = $row2[postcount];

print("<tr><td>

&raquo;&nbsp;Nasi użytkownicy napisali " . $postcount . " postów w " . $topiccount . " tematach,<BR>

&raquo;&nbsp;Mamy" . $registered . " zarejestrowanych użytkowników,<BR>

&raquo;&nbsp;Naszym ostatnim zarejestrowanym użytkownikiem jest " . $latestuser . ", <BR>

&raquo;&nbsp;" . $totalonline . " -Tylu użytkowników jest online.</td></tr>\n");

print("</table>");

Efekt:

tbdevnet

Wyłapywanie Cheaterów

Mod wypisuje na forum, nicki osób, które wyuploadowały xxx gb/min np:)

Pliki potrzebe do zmodyfikowania skryptu:

announce.php

forums.php

global.php

1.Otwórz plik global.php i znajdź

Znajdź:

function get_ratio_color($ratio)

{

if ($ratio < 0.1) return "#ff0000";

if ($ratio < 0.2) return "#ee0000";

if ($ratio < 0.3) return "#dd0000";

if ($ratio < 0.4) return "#cc0000";

if ($ratio < 0.5) return "#bb0000";

if ($ratio < 0.6) return "#aa0000";

if ($ratio < 0.7) return "#990000";

if ($ratio < 0.8) return "#880000";

if ($ratio < 0.9) return "#770000";

if ($ratio < 1) return "#660000";

return "#000000";

}

Dodaj przed tym:

function auto_post($subject = "Error - Subject Missing",$body = "Error - No Body") // Function to use the special system message forum

{

$forumid = 'XX'; // Remember to change this if the forum is recreated for some reason.

$res = mysql_query("SELECT id FROM topics WHERE forumid = ".$forumid" AND subject = ".$subject) or sqlerr(__FILE__, __LINE__);

if(mysql_num_rows($res)==1) { // Topic already exists in the system forum.

$arr = mysql_fetch_array($res);

$topicid = $arr['id'];

}

else { // Create new topic.

mysql_query( "INSERT INTO topics (userid, forumid, subject) VALUES(0, $forumid, $subject)") or sqlerr(__FILE__, __LINE__);

$topicid = @mysql_insert_id();

}

$added = "'" . get_date_time() . "'";

mysql_query( "INSERT INTO posts (topicid, userid, added, body) " .

"VALUES($topicid, 0, $added, $body)") or sqlerr(__FILE__, __LINE__);

$res = mysql_query("SELECT id FROM posts WHERE topicid=$topicid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);

$arr = mysql_fetch_row($res) or die("No post found");

$postid = $arr[0];

mysql_query("UPDATE topics SET lastpost=$postid WHERE id=$topicid") or sqlerr(__FILE__, __LINE__);

}

Oczywscie zamiast XX w linicje

$forumid = 'XX'

Wpisz swoj ID forum

2.Otwórz plik forums.php

a) Znajdź:

if ($postername == "")

{

$by = "unknown[$posterid]";

$avatar = "";

}

Zamień na:

if ($postername == "")

{

if( $posterid == 0 )

$by = "System";

else

$by = "unknown[$posterid]";

$avatar = "";

}

b) Znajdź:

if (mysql_num_rows($res) == 1)

{

$arr = mysql_fetch_assoc($res);

$lpusername = "$arr[username]";

}

else

$lpusername = "unknown[$topic_userid]";

Zamień na:

if (mysql_num_rows($res) == 1)

{

$arr = mysql_fetch_assoc($res);

$lpusername = "$arr[username]";

}

else if( $lpuserid == 0 )

$lpusername = "System";

else

$lpusername = "unknown[$lpuserid]";

c) Znajdź:

if (mysql_num_rows($res) == 1)

{

$arr = mysql_fetch_assoc($res);

$lpauthor = "$arr[username]";

}

else

$lpauthor = "unknown[$topic_userid]";

Zamień na:

if (mysql_num_rows($res) == 1)

{

$arr = mysql_fetch_assoc($res);

$lpauthor = "$arr[username]";

}

else if( $topic_userid == 0 )

$lpauthor = "System";

else

$lpauthor = "unknown[$topic_userid]";

Zamknij i zapisz plik forums.php

3. Otwórz plik announce.php i dokonaj modyfikacji:

Znajdź:

mysql_query("UPDATE peers SET uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = NOW(), seeder = '$seeder'"

. ($seeder == "yes" && $self["seeder"] != $seeder ? ", finishedat = " . time() : "") . " WHERE $selfwhere");

Zamień na:

mysql_query("UPDATE peers SET uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = NOW(), seeder = '$seeder'"

. ($seeder == "yes" && $self["seeder"] != $seeder ? ", finishedat = " . time() : "")

. ", ip = " . sqlesc($ip) . " WHERE $selfwhere")

Znajdź:

if (mysql_affected_rows() && $self["seeder"] != $seeder)

{

Dodaj PO TYM

// Initial sanity check xMB/s for 1 second

if( $upthis > 2097152 ){

// Work out time difference

$rrr = @mysql_query( "SELECT UNIX_TIMESTAMP(last_action) AS ts FROM peers WHERE $selfwhere" );

$aaa = @mysql_fetch_assoc( $rrr );

$starttime = $self['ts'];

$endtime = $aaa['ts'];

$diff = $endtime - $starttime;

// Normalise to prevent divide by zero.

$rate = $upthis / ( $diff + 1 );

// Currently 2MB/s. Increase to 5MB/s once finished testing.

if( $rate > 2097152 ){

$rrr = @mysql_query( "SELECT username,class FROM users WHERE id=$userid" );

$aaa = @mysql_fetch_assoc( $rrr );

$username = $aaa['username'];

$class = $aaa['class'];

if( $class < 6 ){

$rrr = @mysql_query( "SELECT name FROM torrents WHERE id=$torrentid" );

$aaa = @mysql_fetch_assoc( $rrr );

$torrentname = $aaa['name'];

$subject = sqlesc( "Upload - $username" );

$rate = mksize( $rate );

$client = $self['agent'];

$body = sqlesc(

"

"" target="_blank">".$username"
just uploaded at $rate/s. (".

mksize( $upthis )" in $diff seconds.)\n".

"On Torrent

$torrentid"" target="_blank">".$torrentname"
\n".

"Using $client from $ip\n\n".

"This members last actual recorded total uploaded was " . mksize( $last_up ) );

auto_post( $subject , $body );

}

}

}

Znajdź:

$upthis = max(0, $uploaded - $self["uploaded"]);

$downthis = max(0, $downloaded - $self["downloaded"]);

if ($upthis > 0 || $downthis > 0)

mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error 3");

}/

Zamien na:

$upthis = max(0, $uploaded - $self["uploaded"]);

$downthis = max(0, $downloaded - $self["downloaded"]);

if ($upthis > 0 || $downthis > 0)

mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error 3");

}

Znajdź:

$fields = "seeder, peer_id, ip, port, uploaded, downloaded, userid";

Zamień na:

$fields = "seeder, peer_id, agent, ip, port, uploaded, downloaded, userid, UNIX_TIMESTAMP(last_action) AS ts";

Zamknij plik announce.php