Nicholas Posted October 7, 2009 Share Posted October 7, 2009 hi sorry about all the questions, i would do it myself but well there isnt only tutorials on how to do this one lol and its abit confusing for me... im wondering how to make it so when players donate they get there items automaticly credited. <? 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($db->num_rows($db->query("SELECT * FROM dps_accepted WHERE dpTXN='{$txn_id}'")) > 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] != "DP") { fclose($fp);die(""); } $pack=$packr[2]; if( $pack != 1 and $pack != 2 and $pack != 3 and $pack != 4 and $pack != 5) { fclose($fp);die(""); } if(($pack == 1 || $pack == 2 || $pack == 3) && $payment_amount != "3.00") { fclose ($fp);die(""); } if($pack == 4 && $payment_amount != "5.00") { fclose ($fp);die(""); } if($pack == 5 && $payment_amount != "10.00") {fclose ($fp);die(""); } // grab IDs $buyer=$packr[3]; $for=$buyer; // all seems to be in order, credit it. if($pack==1) { $db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET u.money=u.money+5000,u.crystals=u.crystals+50, us.IQ=us.IQ+50,u.donatordays=u.donatordays+30 WHERE u.userid={$for}"); $d=30; $t="standard"; } else if($pack==2) { $db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET u.crystals=u.crystals+100,u.donatordays=u.donatordays+30 WHERE u.userid={$for}"); $d=30; $t="crystals"; } else if($pack==3) { $db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET us.IQ=us.IQ+120,u.donatordays=u.donatordays+30 WHERE u.userid={$for}"); $d=30; $t="iq"; } else if($pack==4) { $db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET u.money=u.money+15000,u.crystals=u.crystals+75, us.IQ=us.IQ+80,u.donatordays=u.donatordays+55 WHERE u.userid={$for}"); $d=55; $t="fivedollars"; } else if($pack==5) { $db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET u.money=u.money+35000,u.crystals=u.crystals+160, us.IQ=us.IQ+180,u.donatordays=u.donatordays+115 WHERE u.userid={$for}"); $d=115; $t="tendollars"; } // process payment event_add($for, "Your \${$payment_amount} Pack {$pack} Donator Pack has been successfully credited to you.", $c); $db->query("INSERT INTO dps_accepted VALUES('', {$buyer}, {$for}, '$t', unix_timestamp(), '$txn_id')"); } else if (strcmp ($res, "INVALID") == 0) { } } fclose ($fp); } ?> thats the ipn_donator.php file that makes it automaticly credits the users the pack when they have brought it... but my donator system is abit different and the mccodes v2 verison... so im wondering can anyone help me convert that file into giving out these items? if its possible, it would be great help :) Donator Pack 1 = item ID 1 = costs £2.00 Donator Pack 2 = item ID 2 = costs £3.00 Donator Pack 3 = item ID 3 = costs £7.50 Donator Pack 4 = item ID 4 = costs £10.00 Donator Pack 5 = item ID 5 = costs £17.50 Donator Pack 6 = item ID 6 = costs £25.00 Donator Pack 7 = item ID 7 = costs £30.00 Donator Pack 8 = item ID 8 = costs £40.00 Donator Pack 9 = item ID 9 = costs £50.00 Donator Pack 10 = item ID 10 = costs £60.00 Donator Pack 11 = item ID 88 = costs £75.00 1000 Crystals = item ID 18 = costs £3.00 2000 Crystals = item ID 19 = costs £4.00 3000 Crystals = item ID 20 = costs £6.00 4000 Crystals = item ID 21 = costs £7.50 5000 Crystals= item ID 22 = costs £10.00 10000 Crystals = item ID 99 = costs £15.00 25000 Crystals = item ID 122 = costs £25.00 1 Honors = item ID 80 = costs £1.00 5 Honors = item ID 81 = costs £4.00 10 Honors = item ID 82 = costs £7.50 25 Honors = item ID 83 = costs £15.00 50 Honors = item ID 83 = costs £20.00 Game Money = 1,000,000 = costs £1.00 5 Full Restores = item ID 12 = costs £2.00 10 Full Restores = item ID 12 = costs £3.50 25 Full Restores = item ID 12 = costs £5.00 5 Will Potions = item ID 13 = costs £1.50 10 Will Potions = item ID 13 = costs £2.50 25 Will Potions = item ID 13 = costs £4.50 1 Stat Pill = item ID 11 = costs £1.50 3 Stat Pill = item ID 11 = costs £4.00 5 Stat Pill = item ID 11 = costs £6.00 10 Stat Pill = item ID 11= costs £10.00 Quote Link to comment Share on other sites More sharing options...
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.