vampireduff Posted January 8, 2010 Posted January 8, 2010 I have edited a few files and added table to mysql but I can't get this to auto credit users, can some look at these codes for me and tell me where I have went wrong. thanks buyhonors.php <?php include "globals.php"; print <<<EOF <h2><font color=purple>Honors</font></h2> Buy Honors today! <font color=red>[i]If the honors do not go to your account after purchase, please mail Admin and he will credit you the honors as soon as he checks the payment thank you.[/i]</font> [b]<font color=gold>Buy One (1):[/b] (\$1)</font> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="{$set['paypal']}"> <input type="hidden" name="item_name" value="{$domain}|HP|1|{$userid}"> <input type="hidden" name="amount" value="1.00"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="return" value="http://{$domain}/honordone.php?action=done&quantity=one"> <input type="hidden" name="cancel_return" value="http://{$domain}/honordone.php?action=cancel"> <input type="hidden" name="notify_url" value="http://{$domain}/ipn_hp.php"> <input type="hidden" name="cn" value="Your Player ID"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="tax" value="0"> <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> [b]<font color=gold>Buy Ten (10):[/b] (\$10.00)</font> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="{$set['paypal']}"> <input type="hidden" name="item_name" value="{$domain}|HP|10|{$userid}"> <input type="hidden" name="amount" value="10.00"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="return" value="http://{$domain}/honordone.php?action=done&quantity=ten"> <input type="hidden" name="cancel_return" value="http://{$domain}/honordone.php?action=cancel"> <input type="hidden" name="notify_url" value="http://{$domain}/ipn_hp.php"> <input type="hidden" name="cn" value="Your Player ID"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="tax" value="0"> <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> [b]<font color=gold>Buy Thirty (30):[/b] (\$25.00)</font> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="{$set['paypal']}"> <input type="hidden" name="item_name" value="{$domain}|HP|30|{$userid}"> <input type="hidden" name="amount" value="25.00"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="return" value="http://{$domain}/honordone.php?action=done&quantity=thirty"> <input type="hidden" name="cancel_return" value="http://{$domain}/honordone.php?action=cancel"> <input type="hidden" name="notify_url" value="http://{$domain}/ipn_hp.php"> <input type="hidden" name="cn" value="Your Player ID"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="tax" value="0"> <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> [b]<font color=gold>Buy Fifty (50):[/b] (\$45.00)</font> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="{$set['paypal']}"> <input type="hidden" name="item_name" value="{$domain}|HP|50|{$userid}"> <input type="hidden" name="amount" value="45.00"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="return" value="http://{$domain}/honordone.php?action=done&quantity=fifty"> <input type="hidden" name="cancel_return" value="http://{$domain}/honordone.php?action=cancel"> <input type="hidden" name="notify_url" value="http://{$domain}/ipn_hp.php"> <input type="hidden" name="cn" value="Your Player ID"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="tax" value="0"> <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> EOF; $h->endpage(); ?> ipn_hp.php <? include "config.php"; global $_CONFIG; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; require 'global_func.php'; $set=array(); $settq=$db->query("SELECT * FROM settings"); while($r=$db->fetch_row($settq)) { $set[$r['conf_name']]=$r['conf_value']; } // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } // post back to PayPal system to validate $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30); // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { // check the payment_status is Completed if($payment_status != "Completed") { fclose ($fp);die(""); } if(mysql_num_rows($db->query("SELECT * FROM dps_accepted WHERE dpTXN='{$txn_id}'", $c)) > 0) { fclose ($fp);die(""); } if(mysql_num_rows($db->query("SELECT * FROM willps_accepted WHERE dpTXN='{$txn_id}'", $c)) > 0) { fclose ($fp);die(""); } if(mysql_num_rows($db->query("SELECT * FROM honors_accepted WHERE dpTXN='{$txn_id}'", $c)) > 0) { fclose ($fp);die(""); } // check that txn_id has not been previously processed // check that receiver_email is your Primary PayPal email if($receiver_email != $set['paypal']) { fclose ($fp);die(""); } // check that payment_amount/payment_currency are correct if($payment_currency != "USD") { fclose ($fp);die(""); } // parse for pack $packr=explode('|',$item_name); if(str_replace("www.","",$packr[0]) != str_replace("www.","",$_SERVER['HTTP_HOST'])) { fclose($fp); die(""); } if($packr[1] != "HP") { fclose($fp);die(""); } $pack=$packr[4]; if( $pack != 1 and $pack != 10 and $pack != 30 and $pack != 50) { fclose($fp);die(""); } if(($pack == 1) && $payment_amount != "1.00") { fclose ($fp);die(""); } if($pack == 10 && $payment_amount != "10.00") { fclose ($fp);die(""); } if($pack == 30 && $payment_amount != "25.00") { fclose ($fp);die(""); } if($pack == 50 && $payment_amount != "45.00") { fclose ($fp);die(""); } // grab IDs $buyer=$packr[3]; $for=$buyer; // all seems to be in order, credit it. if($pack==1) { $db->query("INSERT INTO honorawards values ($userid,'$rlist')"); $db->query("UPDATE users SET honors=honors+1 WHERE userid=$userid"); print "<font color=green>Award Credited!</font> "; } else if($pack==10) { $db->query("INSERT INTO honorawards values ($userid,'$rlist')"); $db->query("UPDATE users SET honors=honors+10 WHERE userid=$userid"); print "<font color=green>Award Credited!</font> "; } else if($pack==30) { $db->query("INSERT INTO honorawards values ($userid,'$rlist')"); $db->query("UPDATE users SET honors=honors+30 WHERE userid=$userid"); print "<font color=green>Award Credited!</font> "; } else if($pack==50) { $db->query("INSERT INTO honorawards values ($userid,'$rlist')"); $db->query("UPDATE users SET honors=honors+50 WHERE userid=$userid"); print "<font color=green>Award Credited!</font> "; } // process payment event_add($for, "Your \${$payment_amount} worth of Honors ($pack) has been successfully credited.", $c); $db->query("INSERT INTO honors_accepted VALUES('', {$buyer}, {$for}, '$pack', unix_timestamp(), '$txn_id')", $c); } else if (strcmp ($res, "INVALID") == 0) { fwrite($f,"Invalid?"); } } fclose ($fp); } ?> I don't get errors and the users buying get everything there would normally get, messages from paypal and all that stuff, they just don't get the honors, until staff credit them I would like it so it would auto credit, like the donator packs do and the will potions :) thanks for any help from you guys Quote
AlabamaHit Posted January 11, 2010 Posted January 11, 2010 where is $rlist defined? If I missed it my bad I just had a quick look but don't see it defined Quote
vampireduff Posted January 14, 2010 Author Posted January 14, 2010 where is $rlist defined? If I missed it my bad I just had a quick look but don't see it defined second php page, line 81, 88, 95 and 102 not sure what is does but there are there at the end Quote
seanybob Posted January 14, 2010 Posted January 14, 2010 where is $rlist defined? If I missed it my bad I just had a quick look but don't see it defined second php page, line 81, 88, 95 and 102 not sure what is does but there are there at the end That is where $rlist is USED, not where $rlist is DEFINED. I imagine there's many problems in this script - one of which (as Alabama pointed out) $rlist isn't defined. I don't have time to actually go through it, but perhaps someone else will... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.