Home » Discussion Forums » M0dZ & HaCkZ » Last Donors block
| |
| Re: Last Donors block [message #2259 is a reply to message #2258] |
Thu, 08 January 2009 02:48   |
DrAgon  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..
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
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!
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
[Updated on: Thu, 08 January 2009 07:20] Report message to a moderator
|
|
| |
| Re: Last Donors block [message #2261 is a reply to message #2260] |
Sat, 10 January 2009 02:13   |
DrAgon  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 #4676 is a reply to message #4670] |
Thu, 05 August 2010 23:43   |
|
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();


For cheap, fast, reliable webhosting, please click here on my affiliate link!
[Updated on: Sat, 07 August 2010 17:06] Report message to a moderator
|
|
| | | | | | |
| Re: Last Donors block [message #4709 is a reply to message #4703] |
Mon, 09 August 2010 22:26   |
watermolecule  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 #4727 is a reply to message #2257] |
Sat, 14 August 2010 20:51   |
|
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.


For cheap, fast, reliable webhosting, please click here on my affiliate link!
[Updated on: Sat, 14 August 2010 20:54] Report message to a moderator
|
|
| |
Goto Forum:
Current Time: Wed Feb 08 05:23:55 GMT 2012
Total time taken to generate the page: 0.02263 seconds
|