Members   Search      Help    Register    Login    Home
Home » Discussion Forums » M0dZ & HaCkZ » Last Donors block
Last Donors block [message #2257] Wed, 07 January 2009 03:59 Go to next message
DrAgon  United States
Messages: 192
Registered: August 2007
Super-Seeder
Bug hunter
This hack might be like a continution to donation hack Joe wrote few year ago at http://www.phpmybittorrent.com/forum/index.php/t/94/153/

I applied this donor hack to pmbt 1.2.2, but it will most likely work with full-mod and 2.x, if not.. If you find your way around php/mysql then it is a piece of cake to make it work in other releases of pmbt.

Anyways, the story is this:

so paypal.php was updating reseaved_donation field everytime donation was coming as gross_mc from paypal via IPN record in the torrent_paypal table...on my pmbt tracker for a while...

but then I have another tracker that was using same web notification url from incoming donation and it was updating my pmbt torrent_papal table..... and it just started to get too old and pissing me off, since I had to clean up the torrent_paypal table every time a donation was made on other tracker. Laughing

So Finally, I cleaned up paypal accounts and donation buttons and seperated each of the notification url returns unique for each tracker in paypal accounts. Cool

Then I said..hm..now that's a bit cleaner....and I can easily capture more info from IPN record coming back and list the donor's name and how much donated from paypal.php instantly in a block for recognition of people who donate to the site. Smile

so I create a new table called torrent_donors and added a sql insert in paypal.php to update the donors table as IPN comes in from paypal.

Then I created lastdonors.php which is small php/sql that will list the last few names from donors table and how much was donated.

if you are interested, reply with a note on this thread Razz and
I'll post the following:

-the sql I used to create donors table
-paypal.php
-lastdonors.php

I had few html tabling column and sql issues and questions that Joe helped me with and I cleaned it up.

meanwhile I perhaps can clean up the hack with any enhancement I can think of and make sure all sql are using same database class that pmbt basecode uses per Joe's suggestion.

btw..pmbt 2.0.3 is starting to look very good Smile ..if you have been in touch with Joe and helping him out..and etc....

Cheers

[Updated on: Wed, 07 January 2009 04:02]

Report message to a moderator

Re: Last Donors block [message #2258 is a reply to message #2257] Wed, 07 January 2009 05:13 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
small reply Laughing

http://a.imageshack.us/img831/5562/mybikes.png
Re: Last Donors block [message #2259 is a reply to message #2258] Thu, 08 January 2009 02:48 Go to previous messageGo to next message
DrAgon  United States
Messages: 192
Registered: August 2007
Super-Seeder
Bug hunter
okay, one reply came

so now I have to post.

Feel free to clean them up, to make have it fit pmbt as it should be.....I will clean them up..when I get a chance..


-the sql I used to create donors table

CREATE TABLE `donors` (
`id` int(6) NOT NULL auto_increment,
`first_name` varchar(255) NOT NULL default '',
`last_name` varchar(255) NOT NULL default '',
`payers_email` varchar(255) NOT NULL default '',
`mc_gross` varchar(255) NOT NULL default '',
`date` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY  (`id`),
UNIQUE KEY `id` (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;


in the above you should include prefix_ for pmbt and perhaps remove primary key.. Razz

You can add extra fields as you wish

-here is my working paypal.php
1) you have to ignore or remove all ^M (end of line)
2) create testFile.txt for your troubleshooting txt file as paypal hits your server so you can use it to troubleshoot paypal.php

<?^M
/*^M
*-------------- A premium or business paypal account is required, this will NOT work with a pers
onal account------------------*^M
*-------------------------------------- You can upgrade via the paypal site---------------------
------------------------------*^M
*-----------------------------------------------------------------------------------------------
------------------------------*^M
*-------------------------Remember to change this: admin@progressivetorrents.com to your paypal
address---------------------------*^M
*---------------------------------- Remember to change yoursite.com to your tracker URL---------
------------------------------*^M
*--------------------------------------Hacked By Joeroberts for phpMyBitTorrent-----------------
------------------------------*^M
*/^M
^M
include("include/config_lite.php");^M
^M


$myFile = "testFile.txt";
$fh = fopen($myFile, 'a');
fwrite($fh,"test");

$query="SELECT * FROM torrent_paypal WHERE donation_block='true'";
fwrite($fh,"test3");
$result=mysql_query($query);

#$row=mysql_fetch_array($res);
fwrite($fh,"test4");

#$donatein=mysql_result($result,1,"reseaved_donations");
$paypal_email==mysql_result($result,1,"paypal_email");
fwrite($fh,$paypal_email);

fwrite($fh,"test5");

// read the post from PayPal system and add 'cmd'^M
$req = 'cmd=_notify-validate';^M
^M
foreach ($_POST as $key => $value) {^M
$value = urlencode(stripslashes($value));^M
$req .= "&$key=$value";^M
}^M
^M
// post back to PayPal system to validate^M
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";^M
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";^M
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";^M
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);^M
^M
// assign posted variables to local variables^M
$item_name = $_POST['item_name'];^M
$item_number = $_POST['item_number'];^M
$payment_status = $_POST['payment_status'];^M
$payment_amount = $_POST['mc_gross'];^M
$payment_currency = $_POST['mc_currency'];^M
$txn_id = $_POST['txn_id'];^M

$receiver_email = $_POST['receiver_email'];^M

$payer_email = $_POST['payer_email'];^M
$first_name = $_POST['first_name'];^M
$last_name = $_POST['last_name'];^M




^M
if (!$fp) {^M
// HTTP ERROR^M
} else {^M
fputs ($fp, $header . $req);^M
#fwrite($fh, $fp);
#fclose($fh);


while (!feof($fp)) {^M
$res = fgets ($fp, 1024);^M

#fwrite($fh, $res);
fwrite($fh,$paypal_email);
fwrite($fh,$receiver_email);
fwrite($fh,$payment_amount);
fwrite($fh,$payer_email);

fwrite($fh,"---");
fwrite($fh,"\n");


#if (strcmp ($res, "OK") == 0) {^M
#if ($receiver_email == $paypal_email){
#fwrite($fh,$paypal_email);
#fwrite($fh,$receiver_email);


fclose($fh);


}
^M
^M
#header("Location: ".$siteurl."");^M
#}^M
#else if (strcmp ($res, "INVALID") == 0) {^M
#}^M
}^M
fclose ($fp);^M
^M
if ($receiver_email == $paypal_email){
  mysql_query ("UPDATE torrent_paypal SET reseaved_donations = $donatein + '$payment_amount' ");
^M
#  $result = mysql_query($query);^M
$query = "INSERT INTO donors (id, first_name, last_name, payers_email, mc_gross, date)VALUES (''
, '$first_name', '$last_name', '$payer_email', '$payment_amount', UNIX_TIMESTAMP())";

$result = mysql_query($query) or die ("Could not execute query : $query." . mysql_error());
}

header("Location: ".$siteurl."");^M

?>




in above code.. you better change sql INSERT line into donors to a pmbt format (database class oreiented) of $db->sql_query("INSERT INTO ... for security reason to make it more pmbt format friendly ...

you can write extra info to the donors tables if you like to modify paypal.php and create donors table with more fields.

date in the donors table.. I am not using and was not necessary for my purpose , but it is there and harmless.


I will clean up above with correct database class for insert into donors later..... if no one else does...

below is the lastdonors.php for display donors in a block with amount donated..

<?php^M
/*^M
*-------------------------------phpMyBitTorrent--------------------------------*^M
*--- The Ultimate BitTorrent Tracker and BMS (Bittorrent Management System) ---*^M
*--------------   Created By Antonio Anzivino (aka DJ Echelon)   --------------*^M
*-------------               http://www.p2pmania.it               -------------*^M
*------------ Based on the Bit Torrent Protocol made by Bram Cohen ------------*^M
*-------------              http://www.bittorrent.com             -------------*^M
*------------------------------------------------------------------------------*^M
*------------------------------------------------------------------------------*^M
*--   This program is free software; you can redistribute it and/or modify   --*^M
*--   it under the terms of the GNU General Public License as published by   --*^M
*--   the Free Software Foundation; either version 2 of the License, or      --*^M
*--   (at your option) any later version.                                    --*^M
*--                                                                          --*^M
*--   This program is distributed in the hope that it will be useful,        --*^M
*--   but WITHOUT ANY WARRANTY; without even the implied warranty of         --*^M
*--   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          --*^M
*--   GNU General Public License for more details.                           --*^M
*--                                                                          --*^M
*--   You should have received a copy of the GNU General Public License      --*^M
*--   along with this program; if not, write to the Free Software            --*^M
*-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA --*^M
*--                                                                          --*^M
*------------------------------------------------------------------------------*^M
*------              \xa92005 phpMyBitTorrent Development Team              ------*^M
*-----------               http://phpmybittorrent.com               -----------*^M
*------------------------------------------------------------------------------*^M
*------                    Hacked For phpMyBitTorrent                   -------*^M
*----------------                 By joeroberts                   -------------*^M
*------------------------------------------------------------------------------*^M
*/^M
^M
#if (eregi("donations_block.php",$_SERVER["PHP_SELF"])) die("You cannot access this file directl
y.");^M

#echo $_SERVER['HTTP_USER_AGENT'];


if ($donations){^M
OpenTable(_lastdonors);^M
#echo ".$browser.";
#if ($b == "ff") $fs="3";
#if ($b == "ie") $fs="1";
#echo "<br><br><center><font size='1' color=\"white\">";
#echo "<center>";
#include ("ptcdonate1.htm");
#include ("blocks/sofar_block.php");
#echo "<br>";
#echo "<center><br>Last Donors";
#echo "<br>----------------";
$sql="SELECT * FROM donors ORDER BY `id` DESC";
$res = $db->sql_query($sql) or btsqlerror($sql);
#$donor = $db->sql_fetchrow($res);
#$db->sql_freeresult($res);

#$result=mysql_query($query);
#$num = mysql_num_rows ($result);
#if ($num > 0 ) {
$num=$db->sql_numrows($res);
if ($db->sql_numrows($res) > 0) {

$i=0;
$num2=7;
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";

#echo "<table>";
#if ($num<7) $num2=$num;
#echo $num2;
while ($i < $num2) {

$donor = $db->sql_fetchrow($res);
#$db->sql_freeresult($res);
#$first_name = mysql_result($result,$i,"first_name");
$first_name = $donor["first_name"];
#$last_name = mysql_result($result,$i,"last_name");
$last_name = $donor["last_name"];
#$payers_email = mysql_result($result,$i,"payers_email");
#$mc_gross = mysql_result($result,$i,"mc_gross");
$mc_gross = $donor["mc_gross"];
#$date = mysql_result($result,$i,"date");
#$id = mysql_result($result,$i,"id");

$f=substr($first_name,0,10);
$l=substr($last_name,0,1);
echo "<tr><td>".$f." ".$l.".</td>";
#echo "<tr><td>$f$l </td>";
echo "<td align=right>$$mc_gross</td></tr>";


++$i; } } else { echo "<br>The database is empty"; }
echo "</table>";





CloseTable (_lastdonors);^M
}^M
?>^M




above has extra lines for non-conforming sql that I had before using pmbt database class .....so ..in reality ..I am just using firstname, lastname and mc_gross to display last 7 donors in a block from code above..

ignore ^M, or remove them and put your EOL (end of line)

put above lastdonors.php in blocks directory

then you can include this block in your index.php or header.php
as you like with

include ("blocks/lastdonors.php");

set your _lastdonors variable in english language to whatever you like your last donor block header to say

okay..that is it for now

I know, all of above is totally messy Very Happy
and there are tons of # lines, that are comments ..line can be deleted or ignored...

the hack works just fine as posted above for me.

here is the clean up task as reminder to myself:
hopefully I can clean it all up and repost! Shocked

1) database class usage for all sql query/update/insert
2) remove all comments
3) prefix for tables added into the code
4) few more security lines for loading of the php, maybe!
5) dos2unix to remove ^M (EOL)

Joe, any other clean up task!?


cheers Razz

[Updated on: Thu, 08 January 2009 07:20]

Report message to a moderator

Re: Last Donors block [message #2260 is a reply to message #2259] Fri, 09 January 2009 06:31 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
at quick look Y all the
fwrite(

and why the need for test.txt??
there is one to many = in
$paypal_email==mysql_result($result,1,"paypal_email");

wich you realy shouldnt have to query for in the first place as it is already done in config_lite.php
you may need to use global function for the results if they did not show up for you.


http://a.imageshack.us/img831/5562/mybikes.png
Re: Last Donors block [message #2261 is a reply to message #2260] Sat, 10 January 2009 02:13 Go to previous messageGo to next message
DrAgon  United States
Messages: 192
Registered: August 2007
Super-Seeder
Bug hunter
fwrites to the test file was for capturing few of the variables without updaing database..now that I recall correctly..
when I used ipn simulator many times at

https://developer.paypal.com/us/cgi-bin/devscr?cmd=_ipn-link -session

all fwrites to testfile could be removed

yea, as I said...all the mysql_result can be removed as they are not within the pmbt convention of database class usage

and all other sql queries should be based on the pmbt convention (framework) too

yes, config_lite has paypal_email and few more variables set around the donation logic...which is a good thing.

thnx for feedback

[Updated on: Sat, 10 January 2009 05:30]

Report message to a moderator

Re: Last Donors block [message #2271 is a reply to message #2261] Sun, 25 January 2009 02:07 Go to previous messageGo to next message
DrAgon  United States
Messages: 192
Registered: August 2007
Super-Seeder
Bug hunter
I added new country/flag/code tables to pmbt
it is integrated with paypal
so last donor block include each donor's flag in front of firstname
--------------
I also imported country2ip table into pmbt mysql
and it'll use the country/flag table to

display country location field in memember profile screen

and now working on

adding flag to whoisonline from the IP of member when they logon to the site.

that should be enough for all the freaking colorful flags and countries for now.
Re: Last Donors block [message #4557 is a reply to message #2271] Thu, 29 July 2010 01:07 Go to previous messageGo to next message
watermolecule is currently offline watermolecule  United States
Messages: 109
Registered: July 2010
Super-Seeder
No Message Body
Re: Last Donors block [message #4571 is a reply to message #4557] Fri, 30 July 2010 21:07 Go to previous messageGo to next message
the-reactor is currently offline the-reactor  United States
Messages: 28
Registered: July 2010
Leecher
I'm having trouble implementing the last 5 donors on my site. Any help?
Re: Last Donors block [message #4578 is a reply to message #4571] Sat, 31 July 2010 05:42 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
Its not My code I well attempt to desifer it this weekend

http://a.imageshack.us/img831/5562/mybikes.png
Re: Last Donors block [message #4586 is a reply to message #4578] Sat, 31 July 2010 17:53 Go to previous messageGo to next message
watermolecule is currently offline watermolecule  United States
Messages: 109
Registered: July 2010
Super-Seeder
Thanks!!
Re: Last Donors block [message #4635 is a reply to message #4571] Tue, 03 August 2010 20:36 Go to previous messageGo to next message
the-reactor is currently offline the-reactor  United States
Messages: 28
Registered: July 2010
Leecher
Any word?
Re: Last Donors block [message #4670 is a reply to message #4635] Thu, 05 August 2010 18:37 Go to previous messageGo to next message
watermolecule is currently offline watermolecule  United States
Messages: 109
Registered: July 2010
Super-Seeder
Any help would be appreciated. We are so close to finishing the site! Smile

Basically, we just want to implement the last 5 donors and add it to our donate.php page and give donors the option of donating anonymously.

thanks
Re: Last Donors block [message #4676 is a reply to message #4670] Thu, 05 August 2010 23:43 Go to previous messageGo to next message
Daffy is currently offline Daffy  United Kingdom
Messages: 359
Registered: October 2009
Location: uk
Releaser

something like this but needs to be adjusted. not looked at it yet.

OpenTable("Site Donors");

echo "<div align=left>";
echo "<center><strong><br>Thank You</strong></center><br>";
echo "<br/>";
$sql = "SELECT id, username, donated FROM ".$db_prefix."_users WHERE donated != '' ORDER BY donated DESC ";
$mysql_result=mysql_query($sql) or die (mysql_error());; 
while ($row=mysql_fetch_array($mysql_result))
{
$id = $row['id'];
$username = $row['username'];
$donated = $row['donated'];
echo "<center><strong><img src=/images/star.gif></img><a href=account-details.php?id=$id><font color=orange>".$username."</font></a><img src=/images/star.gif></img></strong></center>";
}
echo "</marquee><br>";
echo "<center><strong><br>For Your Support</strong></center><br>";
echo"<br/>";

CloseTable();


[Updated on: Sat, 07 August 2010 17:06]

Report message to a moderator

Re: Last Donors block [message #4684 is a reply to message #4676] Sat, 07 August 2010 03:35 Go to previous messageGo to next message
watermolecule is currently offline watermolecule  United States
Messages: 109
Registered: July 2010
Super-Seeder
I added that to my donate.php file and i get this message on my page:

Table 'pmbt.users' doesn't exist

you can take a look at currentperspectives.org/torrents/donate.php

So I have 3 questions:
1. 7What does that message mean?
2. How can I add an option for anonymous contributions?
3. How can I test if this all works without getting contributions coming in?
Re: Last Donors block [message #4685 is a reply to message #4684] Sat, 07 August 2010 06:05 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
change
$sql = "SELECT id, username, donated FROM users WHERE donated != '' ORDER BY donated DESC ";

to
$sql = "SELECT id, username, donated FROM ".$db_prefix."_users WHERE donated != '' ORDER BY donated DESC ";


http://a.imageshack.us/img831/5562/mybikes.png
Re: Last Donors block [message #4689 is a reply to message #4685] Sat, 07 August 2010 17:06 Go to previous messageGo to next message
Daffy is currently offline Daffy  United Kingdom
Messages: 359
Registered: October 2009
Location: uk
Releaser

updated.

Re: Last Donors block [message #4691 is a reply to message #4670] Sat, 07 August 2010 20:46 Go to previous messageGo to next message
watermolecule is currently offline watermolecule  United States
Messages: 109
Registered: July 2010
Super-Seeder
So:

How can I add an option for anonymous contributions?
How can I test if this all works without getting contributions coming in?
Re: Last Donors block [message #4700 is a reply to message #4691] Mon, 09 August 2010 01:44 Go to previous messageGo to next message
watermolecule is currently offline watermolecule  United States
Messages: 109
Registered: July 2010
Super-Seeder
Hello?
Re: Last Donors block [message #4703 is a reply to message #4700] Mon, 09 August 2010 08:43 Go to previous messageGo to next message
Daffy is currently offline Daffy  United Kingdom
Messages: 359
Registered: October 2009
Location: uk
Releaser

try it. we ae busy also doing daily life routines dude. learn some php man.

Re: Last Donors block [message #4709 is a reply to message #4703] Mon, 09 August 2010 22:26 Go to previous messageGo to next message
watermolecule is currently offline watermolecule  United States
Messages: 109
Registered: July 2010
Super-Seeder
"Try it"? So, you're telling me I have to donate to myself to debug / see if the code works?

Hey, I have been learning a lot doing this, but it isn't easy as PMBT is sort of like an invisible web - the style sheet and some php files control some things over here, other php files control things over there... things are constantly misspelled... Sometimes one function is controlled by numerous files scattered all over the place, and those files are not named logically or placed in logically named folders. Then, to top it off, there is no documentation.

Realistically, I don't expect you to be helping me on every issue, as I figured other people frequent the forums and could possibly help out - kind of like how I try to answer peoples questions when I know the answer.

Re: Last Donors block [message #4711 is a reply to message #4709] Tue, 10 August 2010 00:30 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
Sorry PMBT is so hard to figure out.
PMBT has had only one coder for the last 2+ years and I have been doing the best I can.
I never ones said I could spell for shit Laughing
Maybe on day I well have enough users that can help me But as for now what you see is what you get I spend soo much time helping every one and fixing broken codes I don't really have time to clean things up.

as for checking the code go in to the data base and set you donation info.
donator
donated
dondate
donator_tell


http://a.imageshack.us/img831/5562/mybikes.png
Re: Last Donors block [message #4727 is a reply to message #2257] Sat, 14 August 2010 20:51 Go to previous messageGo to next message
Daffy is currently offline Daffy  United Kingdom
Messages: 359
Registered: October 2009
Location: uk
Releaser

replace
$sql = "SELECT id, username, donated FROM ".$db_prefix."_users WHERE donated != '' ORDER BY donated DESC ";


with
$sql = "SELECT id, username, can_do, donated FROM ".$db_prefix."_users WHERE donated != '' ORDER BY donated DESC ";

replace

echo "<center><strong><img src=/images/star.gif></img><a href=account-details.php?id=$id><font color=orange>".$username."</font></a><img src=/images/star.gif></img></strong></center>";


with below

echo "<center><strong><img src=/images/star.gif></img><a href=user.php?op=profile&id=$id><font color=\"".getusercolor($row["can_do"])."\">".$username."</font></a><img src=/images/star.gif></img></strong></center>";


above is so usercolor is shown also links to profile. forgot about that part sorry.
just edit user table manually to enter don amount. for them to appear. this is not setup yet in users profile. once iv added to mine i will post.


[Updated on: Sat, 14 August 2010 20:54]

Report message to a moderator

Re: Last Donors block [message #5777 is a reply to message #4711] Fri, 28 October 2011 06:26 Go to previous message
stevo66669 is currently offline stevo66669  Canada
Messages: 19
Registered: October 2011
Location: Canada
Leecher
joeroberts wrote on Mon, 09 August 2010 19:30
Sorry PMBT is so hard to figure out.
PMBT has had only one coder for the last 2+ years and I have been doing the best I can.
I never ones said I could spell for shit Laughing
Maybe on day I well have enough users that can help me But as for now what you see is what you get I spend soo much time helping every one and fixing broken codes I don't really have time to clean things up.

as for checking the code go in to the data base and set you donation info.
donator
donated
dondate
donator_tell



I'll agree with you on this that you can't spell worth shit lol... but hey it works on the coding, i just fix up my spelling mistakes but it works. Keep up the good work buddy


There will ALWAYS be ONLY 1 Stevo, and thats me Smile
Previous Topic:staff links block
Next Topic:new statistics table
Goto Forum:
  


Current Time: Thu Feb 09 05:08:39 GMT 2012

Total time taken to generate the page: 0.02553 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software