Jump to content
MakeWebGames

Recommended Posts

Posted

Here is the code for donator I found on forum and edited some so would work for me. But please tell em if this will work or what I need to fix. Thank you :).

IPN_DONATOR.php

<?php
session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm);
$h->menuarea();
global $_CONFIG;
define("MONO_ON", 1);
$set=array();
$settq=mysql_query("SELECT * FROM settings");
while($r=mysql_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) {

} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if($payment_status != "Completed") { fclose ($fp);die(""); }
if(mysql_num_rows(mysql_query("SELECT * FROM dps_accepted WHERE dpTXN='{$txn_id}'")) > 0) { fclose ($fp);;die(""); }
if($receiver_email != $set['paypal']) { fclose ($fp);die(""); }
if($payment_currency != "USD") { fclose ($fp);die(""); }
$packr=explode('|',$item_name);
if(str_replace("www.","",$packr[0]) != str_replace("www.","",$_SERVER['HTTP_HOST'])) { fclose($fp);mysql_query("INSERT INTO test VALUES('', 'DOMAIN FUCK UP!')"); die(""); }
if($packr[1] != "DP") { fclose($fp);die(""); }
$pack=$packr[2];
$packinfo = mysql_fetch_row(mysql_query("SELECT * FROM packages WHERE id='$pack' AND deleted='0' LIMIT 1"));
if(!$packinfo) { fclose($fp);die(""); }
if($packinfo[cost] != $payment_amount) { fclose ($fp);
die(""); }

$buyer=$packr[3];
$for=$buyer;
mysql_query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET 
      	u.money=u.money+'$packinfo[money]',
      	u.crystals=u.crystals+'$packinfo[crystals]'
       	WHERE 
      	u.userid='$for'");
$d = $packinfo[ddays];
$t = $packinfo[id];


mysql_query("INSERT INTO dps_accepted VALUES('', {$buyer}, {$for}, '$t', unix_timestamp(), '$txn_id')");
########}
########else if (strcmp ($res, "INVALID") == 0) {
########	mysql_query("INSERT INTO test VALUES('', 'INVALID')");

########}
}

fclose ($fp);
}
?>

 

 

DONATOR.php

<?php
session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$cm=money_formatter($ir['crystals'],'');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();
print <<<EOF
<h3>Donations</h3>
If you become a donator to Stick Mafia, you will receive (each time you donate):

EOF;

if(mysql_num_rows(mysql_query("SELECT id FROM packages")) < 1):
echo "Sorry, but there are currently no packages in the game yet.";
else:
$q=mysql_query("SELECT * FROM packages WHERE deleted!='1' ORDER BY cost ASC");
while($r=mysql_fetch_array($q)):
   	echo "<fieldset><legend>$r[name] (\$$r[cost],--)</legend><ul>";
   	if($r[money] > 0) echo "[*]\$".number_format($r[money])." game money.";
   	if($r[crystals] > 0) echo "[*]$r[crystals] crystals.";
   	if($r[iq] > 0) echo "[*]$r[iq] IQ, the hardest stat in the game to get.";
   	if($r[ddays] > 0) echo "[*]$r[ddays] days Donator Status: Red name + cross next to your name.";


   	echo "[*]17% Energy every 5 minutes instead of 8%. (For aslong as you have Donator Status)[*]Access to Friends and Black lists[/list]";

   	echo '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">';
   	echo '<input type=hidden name=cmd value=_xclick>';
   	echo '<input type="hidden" name="business" value="[email protected]">';
   	echo '<input type="hidden" name="item_name" value="Stick Mafia|Donator Pack|'.$r[id].'|'.$userid.'">';
   	echo '<input type="hidden" name="amount" value="'.$r[cost].'.00">';
   	echo '<input type="hidden" name="no_shipping" value="1">';
   	echo '<input type="hidden" name="return" value="http://stickmafia.unlimitedtree.com">';
   	echo '<input type="hidden" name="cancel_return" value="http://stickmafia.unlimitedtree.com">';
   	echo '<input type="hidden" name="notify_url" value="http://stickmafia.unlimitedtree.com/ipn_donator.php">';
   	echo '<input type="hidden" name="cn" value="Your Player ID">';
   	echo '<input type="hidden" name="currency_code" value="USD">';
   	echo '<input type="hidden" name="tax" value="0">';
   	echo '<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!">';
   	echo '</form>';

   	echo "</fieldset>";
endwhile;
endif;
$h->endpage();
Posted

Why do you have the header info in an ipn file?

session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm);
$h->menuarea();

A user should NEVER see the ipn therefore the menu is a waste as is the user function you should pass everything you need by the paypal button.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...