TorrentFlux.com Hey, OppTupacShakur, you have 11 messages, 0 are new.
05-07-2007, 12:33:11
Home Help Search Profile Logout donate chat
News:


+  TorrentFlux Forums
|-+  Code Hacks and Tools
| |-+  TorrentFlux 2.1 Hacks
| | |-+  xfer bandwidth/transfer statistics hack 2.3.0
« previous next »
Pages: 1 ... 3 4 [5] 6 7 8 Go Down Reply Notify of replies Send this topic Print
Author Topic: xfer bandwidth/transfer statistics hack 2.3.0  (Read 14712 times)
blackwidow
Newbie
*
Offline Offline

Posts: 44



View Profile Personal Message (Offline)
« Reply #60 on: 05-24-2006, 15:24:09 » Reply with quote

carlo1234 pointed out some (4) of the (insert)-statements fail on sqlite due to being not 100% sql-conform.

he provided new statements which of course also work on mysql so replacing them in your codebase would be a nice thing.
i dont have any line-numbers at hand because my version is very different as i splitted the functions into different files. grep or a capable text-editor should do ~

thanks b4rt and carlo1234 ! I will log this and put it in the next version soon. I always wondered why my database professor told me to use "(field,field,field) values (value,value,value)".
Report to moderator   Logged
Beowulf
Newbie
*
Offline Offline

Posts: 28



View Profile Email Personal Message (Offline)
« Reply #61 on: 05-24-2006, 19:34:20 » Reply with quote

carlo1234 pointed out some (4) of the (insert)-statements fail on sqlite due to being not 100% sql-conform.

he provided new statements which of course also work on mysql so replacing them in your codebase would be a nice thing.
i dont have any line-numbers at hand because my version is very different as i splitted the functions into different files. grep or a capable text-editor should do ~

old code :
Code:
$sql = 'INSERT INTO tf_xfer SET user = "'.$user.'", date = '.$db->DBDate(time()).', download = '.($down+0).', upload = '.($up+0);
conform code:
Code:
$sql = 'INSERT INTO tf_xfer (user,date,download,upload) values ("'.$user.'",'.$db->DBDate(time()).','.($down+0).','.($up+0).')';

old code :
Code:
$sql = 'INSERT INTO tf_xfer SET user = "'.$torrentowner.'", date = "'.$lastDate.'", download = '.($af->downtotal+0).', upload = '.($af->uptotal+0);
conform code:
Code:
$sql = 'INSERT INTO tf_xfer (user,date,download,upload) values ("'.$torrentowner.'","'.$lastDate.'",'.($af->downtotal+0).','.($af->uptotal+0).')';

old code :
Code:
$sql = 'INSERT INTO tf_xfer SET user = "'.$torrentowner.'", date = '.$db->DBDate(time()).', download = -'.($af->downtotal+0).', upload = -'.($af->uptotal+0);
conform code:
Code:
$sql = 'INSERT INTO tf_xfer (user,date,download,upload) values ("'.$torrentowner.'",'.$db->DBDate(time()).',-'.($af->downtotal+0).',-'.($af->uptotal+0).')';

old code :
Code:
$sql = 'INSERT INTO tf_xfer SET user = "", date = '.$db->DBDate(time());
conform code:
Code:
$sql = 'INSERT INTO tf_xfer (user,date) values ( "",'.$db->DBDate(time()).')';



regards,
b4rt

These codes can be found in functions.php

old code in line 105:
Code:
$sql = 'INSERT INTO tf_xfer SET user = "'.$user.'", date = '.$db->DBDate(time()).', download = '.($down+0).', upload = '.($up+0);
conform code:
Code:
$sql = 'INSERT INTO tf_xfer (user,date,download,upload) values ("'.$user.'",'.$db->DBDate(time()).','.($down+0).','.($up+0).')';

old code in line 2513:
Code:
$sql = 'INSERT INTO tf_xfer SET user = "'.$torrentowner.'", date = "'.$lastDate.'", download = '.($af->downtotal+0).', upload = '.($af->uptotal+0);
conform code:
Code:
$sql = 'INSERT INTO tf_xfer (user,date,download,upload) values ("'.$torrentowner.'","'.$lastDate.'",'.($af->downtotal+0).','.($af->uptotal+0).')';

old code in line 2524:
Code:
$sql = 'INSERT INTO tf_xfer SET user = "'.$torrentowner.'", date = '.$db->DBDate(time()).', download = -'.($af->downtotal+0).', upload = -'.($af->uptotal+0);
conform code:
Code:
$sql = 'INSERT INTO tf_xfer (user,date,download,upload) values ("'.$torrentowner.'",'.$db->DBDate(time()).',-'.($af->downtotal+0).',-'.($af->uptotal+0).')';

old code in line 2816:
Code:
$sql = 'INSERT INTO tf_xfer SET user = "", date = '.$db->DBDate(time());
conform code:
Code:
$sql = 'INSERT INTO tf_xfer (user,date) values ( "",'.$db->DBDate(time()).')';


I hope this will help me. Thanks for the work.

EDIT:

Poorly this was no resolution for my Problem. Now I only get another message of failure.  :'(
« Last Edit: 05-25-2006, 20:48:30 by Beowulf » Report to moderator   Logged
b4rt
Hero Member
*****
Offline Offline

TF Base: Linux 2.x
Posts: 542



View Profile WWW Email Personal Message (Offline)
« Reply #62 on: 05-26-2006, 06:26:51 » Reply with quote

I get an error every new day. This is the message:

Code:
Debug SQL is on.

SQL: INSERT INTO tf_xfer SET user = "beowulf", date = '2006-05-19', download = 0, upload = 7445429808


Database error: Duplicate entry 'beowulf' for key 1

Always check your database variables in the config.php file.

I don't know what I've done wrong and its nerve-racking to empty the table every day.
Can anyone help me please?


looks like this conditional returns false on your system :
Code:
            $sql = 'SELECT 1 FROM tf_xfer WHERE user = "'.$torrentowner.'" AND date = '.$db->DBDate(time());
            if ($db->GetOne($sql)) {

so everyday xfer uses the insert-state and not the update-state.
you should check why this statement gives false (it shouldnt) then you (may) know why your error occurs.


regards,
b4rt
Report to moderator   Logged

torrentflux-b4rt svn-trunk
Linux 2.4.34.1, Apache 2.0.59, PHP 4.4.5, Perl 5.8.8, Python 2.5, MySQL 4.1.22
b4rt
Hero Member
*****
Offline Offline

TF Base: Linux 2.x
Posts: 542



View Profile WWW Email Personal Message (Offline)
« Reply #63 on: 05-26-2006, 06:35:08 » Reply with quote


hi blackwidow,

just a little thing:
the rgb-calc-code of the bars doesnt handle 0 and 100 in a "proper" way. (it results in black on black)
in my 81 i handled these as "exceptions" and set color to white... its not nice but you can read the strings Smiley

regards,
b4rt

Report to moderator   Logged

torrentflux-b4rt svn-trunk
Linux 2.4.34.1, Apache 2.0.59, PHP 4.4.5, Perl 5.8.8, Python 2.5, MySQL 4.1.22
blackwidow
Newbie
*
Offline Offline

Posts: 44



View Profile Personal Message (Offline)
« Reply #64 on: 05-26-2006, 12:51:12 » Reply with quote

just a little thing:
the rgb-calc-code of the bars doesnt handle 0 and 100 in a "proper" way. (it results in black on black)
in my 81 i handled these as "exceptions" and set color to white... its not nice but you can read the strings Smiley

here is the RGP calc code for displayDriveSpaceBar:
Code:
  $bgcolor = '#';
  $bgcolor .= str_pad(dechex(256-256*($percent/150)),2,0,STR_PAD_LEFT);
  $bgcolor .= str_pad(dechex(256*($percent/150)),2,0,STR_PAD_LEFT);
  $bgcolor .='00';

The 256s should be 255s. Then at 0%, the bar would be all black with bright red text, and at 100% the bar would be bright green with black text. I might put in a max(0,$drivespace) so we never deal with negative percentages.
Report to moderator   Logged
Beowulf
Newbie
*
Offline Offline

Posts: 28



View Profile Email Personal Message (Offline)
« Reply #65 on: 05-30-2006, 20:43:30 » Reply with quote

I found this in line 135 of functions.php:

Code:
//XFER:****************************************************
//XFER: saveXfer(user, download, upload)
//XFER: Inserts or updates SQL upload/download for user
function saveXfer($user, $down, $up)
{
  global $db;
  $sql = 'SELECT 1 FROM tf_xfer WHERE user = "'.$user.'" AND date = '.$db->DBDate(time());
  if ($db->GetRow($sql)) {
    $sql = 'UPDATE tf_xfer SET download = download+'.($down+0).', upload = upload+'.($up+0).' WHERE user = "'.$user.'" AND date = '.$db->DBDate(time());
    $db->Execute($sql);
    showError($db,$sql);
  } else {
    showError($db,$sql);
    $sql = 'INSERT INTO tf_xfer (user,date,download,upload) values ("'.$user.'",'.$db->DBDate(time()).','.($down+0).','.($up+0).')';
    $db->Execute($sql);
    showError($db,$sql);
  }
}

Is that wrong and if it is wrong how do I have to change it?
Report to moderator   Logged
b4rt
Hero Member
*****
Offline Offline

TF Base: Linux 2.x
Posts: 542



View Profile WWW Email Personal Message (Offline)
« Reply #66 on: 05-30-2006, 21:39:45 » Reply with quote

I found this in line 135 of functions.php:

Code:
//XFER:****************************************************
//XFER: saveXfer(user, download, upload)
//XFER: Inserts or updates SQL upload/download for user
function saveXfer($user, $down, $up)
{
  global $db;
  $sql = 'SELECT 1 FROM tf_xfer WHERE user = "'.$user.'" AND date = '.$db->DBDate(time());
  if ($db->GetRow($sql)) {
    $sql = 'UPDATE tf_xfer SET download = download+'.($down+0).', upload = upload+'.($up+0).' WHERE user = "'.$user.'" AND date = '.$db->DBDate(time());
    $db->Execute($sql);
    showError($db,$sql);
  } else {
    showError($db,$sql);
    $sql = 'INSERT INTO tf_xfer (user,date,download,upload) values ("'.$user.'",'.$db->DBDate(time()).','.($down+0).','.($up+0).')';
    $db->Execute($sql);
    showError($db,$sql);
  }
}

Is that wrong and if it is wrong how do I have to change it?

there is nothing wrong with it.
but as i wrote above :

looks like this conditional returns false on your system :
Code:
            $sql = 'SELECT 1 FROM tf_xfer WHERE user = "'.$torrentowner.'" AND date = '.$db->DBDate(time());
            if ($db->GetOne($sql)) {

so everyday xfer uses the insert-state and not the update-state.
you should check why this statement gives false (it shouldnt) then you (may) know why your error occurs.

you should check the "why on my system" as the code itself is "working".
eg try to execute the statement and check ret-val. then check database-entries.

btw as i dont know anything about your setup / whats done this was just a guess.

regards,
b4rt

Report to moderator   Logged

torrentflux-b4rt svn-trunk
Linux 2.4.34.1, Apache 2.0.59, PHP 4.4.5, Perl 5.8.8, Python 2.5, MySQL 4.1.22
Beowulf
Newbie
*
Offline Offline

Posts: 28



View Profile Email Personal Message (Offline)
« Reply #67 on: 05-31-2006, 13:08:21 » Reply with quote

Thanks, bat as I am no professional with mysql I need an introduction how to check or what to do.  Undecided
Report to moderator   Logged
PlymWS
Jr. Member
**
Offline Offline

Posts: 53



View Profile Email Personal Message (Offline)
« Reply #68 on: 06-18-2006, 18:25:30 » Reply with quote

Does anyone have a mirror of the files, or the codes that are inserted.  The links are all down Sad
Report to moderator   Logged
Stardust
Newbie
*
Offline Offline

Posts: 8



View Profile Personal Message (Offline)
« Reply #69 on: 06-20-2006, 17:01:59 » Reply with quote

Hello,

can pls somebody give the files of the 2.1.1 transfer hack?.
The links on first page are still down.
Report to moderator   Logged
WingZero
Newbie
*
Offline Offline

Posts: 3



View Profile Personal Message (Offline)
« Reply #70 on: 06-21-2006, 14:58:02 » Reply with quote

i also need link to the pre-patch links are down
Report to moderator   Logged
blackwidow
Newbie
*
Offline Offline

Posts: 44



View Profile Personal Message (Offline)
« Reply #71 on: 06-26-2006, 17:09:44 » Reply with quote

Does anyone have a mirror of the files, or the codes that are inserted.  The links are all down Sad
sorry about that! back up again.
Report to moderator   Logged
Stardust
Newbie
*
Offline Offline

Posts: 8



View Profile Personal Message (Offline)
« Reply #72 on: 06-29-2006, 09:16:29 » Reply with quote

thx  Grin
Report to moderator   Logged
Host-Away Web Hosting Company
Jr. Member
**
Offline Offline

TF Base: Linux 2.x
Posts: 89


Host-Away Web Hosting Company



View Profile WWW Email Personal Message (Offline)
« Reply #73 on: 08-04-2006, 17:54:18 » Reply with quote

hello i am trying to install this hack but i have modified some of the files and when i try to use the xfer.diff patch it all fails i am wondering if a step by step guide could be posted please

thank you

 TF Love

host-away
Report to moderator   Logged

Host-Away Web Hosting Company

====================
   = My TF SERVER INFO  =

Intel Centrino Duo 4GHZ
4GB DDR 2
HDD 1 = 250GB (Westeren Digital SATA)
HDD 2 = 250GB (Seagate SATA)
HDD 3 = 250GB (Westeren Digital)
HDD 4 = LaCie Big Disk Extreme with Triple Interface 1TB (Firewire 800)
100 MBPS Dedicated Line
99.9% Uptime
===
Beowulf
Newbie
*
Offline Offline

Posts: 28



View Profile Email Personal Message (Offline)
« Reply #74 on: 08-07-2006, 09:24:30 » Reply with quote

I still need help with this hack pleeeeeaaaaasssse  :'(
Report to moderator   Logged
Pages: 1 ... 3 4 [5] 6 7 8 Go Up Reply Notify of replies Send this topic Print 
« previous next »
Jump to:  


Powered by MySQL Powered by SMF 1.1.1 | SMF © 2006, Simple Machines LLC Powered by PHP