Jump to content
PHPStudent

Donator Pack Creation Module

Recommended Posts

I found this mod on my pc, it was originally made by Cronus and I believe it was a free release or eventually became one, and considering there aren't many, if any, free donator pack creation mods,  I'm posting the codes for anyone whom may want them. Personally, I will probably be buying Dave's script instead as it has more capabilities.

But I've chosen to post this in modification support rather than free modifications because it doesn't completely work. Donator Packs don't get auto credited and donatorstats.php does not update with any donator/donation data. 🤔

donator.php

<?php

//------------------------------------------------
// Mod created by Cronus.
// You can find more of his mods for sale
// and join his MCCode developers community here:
// http://www.cronwerks.com/forum
//------------------------------------------------

include "globals.php";
$currency="USD";

$paypal="your paypal email here";
$topstatement="This is the top statement, you can say anything here about your donator packs, maybe<br>
some specials you are/will be running. This is also a good place to put what your donator<br>
days do so new donator pack buyers will know what they are getting.<br><br>
You are able to put html in this area, however, you cannot put bbcode.<br>You can change this inside near the top of the file.";
print "<br><br><center>";

?>
<Script language="JavaScript">
<!-- Script courtesy of http://www.web-source.net - Your Guide to Professional Web Site Design and Development
function goto(form) { var index=form.select.selectedIndex
if (form.select.options[index].value != "0") {
location=form.select.options[index].value;}}
//-->
</SCRIPT>
<?php

if($_GET['deactivate'] && $userid == 1)
{
$db->query("UPDATE dpacks SET active=0 WHERE id={$_GET['deactivate']}");
}
if($_GET['activate'] && $userid == 1)
{
$db->query("UPDATE dpacks SET active=1 WHERE id={$_GET['activate']}");
}
if($_GET['hide'] && $userid == 1)
{
$db->query("UPDATE dpacks SET hidden=1 WHERE id={$_GET['hide']}");
}

if($userid == 1)
{
print"<a href=donator.php?add=site>[Add New Donator Pack]</a>
<br>
<a href=donatorstats.php>[Stats]</a><br><br>";
}
if($_GET['changebogo'] && $userid == 1)
{
$db->query("UPDATE dpacks SET bogo={$_GET['num']} WHERE id={$_GET['changebogo']}");
if($_GET['num'] == 0)
{
print"You have ended the bogo special.<br><br>";
}
else
{
print"The bogo special has been changed to Buy {$_GET['num']} Get 1 Free!<br><br>";
}
}
$width=70;
$second="";
$span=4;
if($userid == 1)
{
$width=90;
$second="<th width=10%>---</th><th width=10%>---</th>";
$span=6;
}
print"<table width=$width% class=table border=1><tr><th colspan=$span><center>Donator Packs</center></tr><tr><td colspan=$span><center>$topstatement</center></td></tr>
<tr><th>Name</th><th>Included</th><th width=10%>Price</th><th width=10%>---</th>$second</tr>";
if($userid == 1)
{
$hk=$db->query("SELECT * FROM dpacks WHERE hidden=0");
}
else
{
$hk=$db->query("SELECT * FROM dpacks WHERE active=1");
}
while($r=$db->fetch_row($hk))
{
if($userid == 1)
{
$sekond="<td><center><a href=donator.php?edit={$r['id']}><font color=blue>Edit</font></a></center></td><td><center><a href=donator.php?del={$r['id']}><font color=red>Del</font></a></center></td>";
}
print"<tr><td><center>";
if($userid == 1 && $r['active'] == 0 && $r['hidden'] == 0)
{
print"<font size=1 color=green>(<a href=donator.php?activate={$r['id']}><font color=green size=1>Activate For Sale</font></a>)</font><br>";
}
print"{$r['name']}";
if($r['bogo'] > 0)
{
print"<br><font color=red size=1>Buy {$r['bogo']} Get One Free!</font>";
}
if($userid == 1)
{
print"<br><font size=1><A href=donator.php?changebogo={$r['id']}&num=0>End Sale</a> - <A href=donator.php?changebogo={$r['id']}&num=1>1</a> - <A href=donator.php?changebogo={$r['id']}&num=2>2</a> - <A href=donator.php?changebogo={$r['id']}&num=3>3</a> - <A href=donator.php?changebogo={$r['id']}&num=4>4</a> - <A href=donator.php?changebogo={$r['id']}&num=5>5</a> - <A href=donator.php?changebogo={$r['id']}&num=10>10</a></font>";
}
if($userid == 1 && $r['active'] == 1)
{
print"<br><font size=1 color=red>(<a href=donator.php?deactivate={$r['id']}><font color=red size=1>Deactivate</font></a>)</font>";
}
if($userid == 1 && $r['active'] == 0 && $r['hidden'] == 0)
{
print"<br><font size=1 color=red>(<a href=donator.php?hide={$r['id']}><font color=red size=1>Hide Forever</font></a>)</font>";
}
print"</center></td><td><ul>";

if($r['days'] > 0)
{
print"<li>{$r['days']} Donator Days</li>";
}
if($r['money'] > 0)
{
$muneh=money_formatter($r['money']);
print"<li>$muneh Game Money</li>";
}
if($r['crystals'] > 0)
{
print"<li>{$r['crystals']} Crystals</li>";
}
if($r['items'] > 0)
{
$lao=$db->query("SELECT * FROM dpitems WHERE dpid={$r['id']}");
while($dpitem=$db->fetch_row($lao))
{
$juk=$db->query("SELECT * FROM items WHERE itmid={$dpitem['itemid']}");
$item=$db->fetch_row($juk);
$s="";
if($dpitem['quantity'] > 1)
{
$s="s";
}
print"<li>{$dpitem['quantity']} {$item['itmname']}$s</li>";
}
}
print"</ul></td><td><center>\${$r['price']}</center></td><td><center><a href=donator.php?buy={$r['id']}>Buy</a></center></td>$sekond</tr>";
}
print"</table></center>";

if($_GET['buy'])
{
$buy = abs((int) $_GET['buy']);
$look=$db->query("SELECT * FROM dpacks WHERE id=$buy");
if($db->num_rows($look) == 0)
{
print"<center>This donator pack does not exist or is not for sale.<br>> <a href=donator.php>Back</a>";
die("");
}
else
{
$dp=$db->fetch_row($look);
if($dp['active'] == 0)
{
print"<center>This donator pack does not exist or is not for sale.<br>> <a href=donator.php>Back</a>";
die("");
}
}
if($_GET['nbr'])
{
$number=$_GET['nbr'];
}
else
{
$number=1;
}
$domain=$_SERVER['HTTP_HOST'];
$cost=$number*$dp['price'];
$final=money_formatter($number*$dp['price']);
print"<br><hr width=50%><br>
<table class=table width=70% border=1>
<tr>
<th colspan=2>
<font size=4>You are purchasing the {$dp['name']}.</font>
</th>
</tr>
<tr>
<td width=50%>
<center>You are currently purchasing $number pack(s).<br><br>
If you would like more please select the<br> number you would like below.<br><br><FORM NAME='form1'><SELECT NAME='select' ONCHANGE='goto(this.form)' SIZE='1'>";
$total=1;
while($total < 51)
{
print "<option value='donator.php?buy=$buy&nbr=$total'>$total";
$total=$total+1;
}
print"</SELECT></FORM></center>
</th>
<td>
<center>Your total payment will be $final.<br>You will receive credit instantly after payment.<br><br>

<form action='https://www.paypal.com/cgi-bin/webscr' method='post'>
<input type=hidden name=cmd value=_xclick>
<input type='hidden' name='business' value='$paypal'>
<input type='hidden' name='item_name' value='{$domain}|{$dp['id']}|{$number}|{$userid}'>
<input type='hidden' name='item_number' value='21'>
<input type='hidden' name='amount' value='$cost'>
<input type='hidden' name='no_shipping' value='1'>
<input type='hidden' name='notify_url' value='http://{$domain}/ipn_donator.php'>
<input type='hidden' name='return' value='http://{$domain}'>
<input type='hidden' name='cancel_return' value='http://{$domain}'>
<input type='hidden' name='cn' value='Your Player ID'>
<input type='hidden' name='currency_code' value='$currency'>
<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!'>
<img alt='' border='0' src='https://www.paypal.com/en_US/i/btn/x-click-but21.gif' width='1' height='1'>
</form>

</td>
</tr>
</table>
";
}

if($userid == 1 && $_GET['add'])
{
print"<br><hr width=75%><br>";
if($_POST['name'] && $_POST['desc'] && $_POST['price'] && $_POST['itemone'] && $_POST['itemtwo'] && $_POST['itemthree'] && $_POST['itemfour'] && $_POST['itemfive'])
{
$money = abs((int) $_POST['money']);
$crystals = abs((int) $_POST['crystals']);
$days = abs((int) $_POST['days']);
$itemone = abs((int) $_POST['itemone']);
$itemoneqty = abs((int) $_POST['itemoneqty']);
$itemtwo = abs((int) $_POST['itemtwo']);
$itemtwoqty = abs((int) $_POST['itemtwoqty']);
$itemthree = abs((int) $_POST['itemthree']);
$itemthreeqty = abs((int) $_POST['itemthreeqty']);
$itemfour = abs((int) $_POST['itemfour']);
$itemfourqty = abs((int) $_POST['itemfourqty']);
$itemfive = abs((int) $_POST['itemfive']);
$itemfiveqty = abs((int) $_POST['itemfiveqty']);
if($itemone == 1000100)
{
$itemone=0;
$itemoneqty=0;
}
if($itemtwo == 1000100)
{
$itemtwo=0;
$itemtwoqty=0;
}
if($itemthree == 1000100)
{
$itemthree=0;
$itemthreeqty=0;
}
if($itemfour == 1000100)
{
$itemfour=0;
$itemfourqty=0;
}
if($itemfive == 1000100)
{
$itemfive=0;
$itemfiveqty=0;
}
$info=str_replace(array("'","\n"),array("'","<br />"),strip_tags($_POST['name']));
$name = $db->escape($info);
$info=str_replace(array("'","\n"),array("'","<br />"),strip_tags($_POST['desc']));
$desc = $db->escape($info);
$info=str_replace(array("'","\n"),array("'","<br />"),strip_tags($_POST['price']));
$price = $db->escape($info);

$howmany=0;
if($itemone > 0)
{
if($itemone == $itemtwo || $itemone == $itemthree || $itemone == $itemfour || $itemone == $itemfive)
{
print"<center>You shouldn't have the same item in multiple places in a Donator Pack<br>> <a href=donator.php>Back</a>";
die("");
}
$juk=$db->query("SELECT * FROM items WHERE itmid=$itemone");
if($db->num_rows($juk) == 0)
{
print"<center>One of the items you have selected does not exist.<br>> <a href=donator.php>Back</a>";
die("");
}
$howmany=1;
}
if($itemtwo > 0)
{
if($itemone == $itemtwo || $itemtwo == $itemthree || $itemtwo == $itemfour || $itemtwo == $itemfive)
{
print"<center>You shouldn't have the same item in multiple places in a Donator Pack<br>> <a href=donator.php>Back</a>";
die("");
}
$juk=$db->query("SELECT * FROM items WHERE itmid=$itemtwo");
if($db->num_rows($juk) == 0)
{
print"<center>One of the items you have selected does not exist.<br>> <a href=donator.php>Back</a>";
die("");
}
$howmany=2;
}
if($itemthree > 0)
{
if($itemthree == $itemtwo || $itemone == $itemthree || $itemthree == $itemfour || $itemthree == $itemfive)
{
print"<center>You shouldn't have the same item in multiple places in a Donator Pack<br>> <a href=donator.php>Back</a>";
die("");
}
$juk=$db->query("SELECT * FROM items WHERE itmid=$itemthree");
if($db->num_rows($juk) == 0)
{
print"<center>One of the items you have selected does not exist.<br>> <a href=donator.php>Back</a>";
die("");
}
$howmany=3;
}
if($itemfour > 0)
{
if($itemfour == $itemtwo || $itemfour == $itemthree || $itemone == $itemfour || $itemfour == $itemfive)
{
print"<center>You shouldn't have the same item in multiple places in a Donator Pack<br>> <a href=donator.php>Back</a>";
die("");
}
$juk=$db->query("SELECT * FROM items WHERE itmid=$itemfour");
if($db->num_rows($juk) == 0)
{
print"<center>One of the items you have selected does not exist.<br>> <a href=donator.php>Back</a>";
die("");
}
$howmany=4;
}
if($itemfive > 0)
{
if($itemfive == $itemtwo || $itemfive == $itemthree || $itemfive == $itemfour || $itemone == $itemfive)
{
print"<center>You shouldn't have the same item in multiple places in a Donator Pack<br>> <a href=donator.php>Back</a>";
die("");
}
$juk=$db->query("SELECT * FROM items WHERE itmid=$itemfive");
if($db->num_rows($juk) == 0)
{
print"<center>One of the items you have selected does not exist.<br>> <a href=donator.php>Back</a>";
die("");
}
$howmany=5;
}

if($itemone == 0 && $howmany > 0 || $itemtwo == 0 && $howmany > 1 || $itemthree == 0 && $howmany > 2 || $itemfour == 0 && $howmany > 3 || $itemfive == 0 && $howmany > 4)
{
print"<center>Make sure you fill in the First Item first, Second Item second... etc.<br>Please do not leave one lower item blank while a higher item is not.<br>> <a href=donator.php>Back</a>";
die("");
}

$huji=$db->query("SELECT * FROM itemtypes WHERE itmtypeid=999");
if($db->num_rows($huji) == 0)
{
$typename="Donation Items";
$db->query("INSERT INTO itemtypes VALUES('999','$typename')");
}
$db->query("INSERT INTO items VALUES('','999','$name','$desc','0','0','0', '0', '0', '0', '0', '1', '0', '0', '0')");
$i=$db->insert_id();
$db->query("INSERT INTO dpacks VALUES ('$i','$name','$crystals','$money','$days','$price','$desc','$howmany','1','0','1');");
$which=1;
while($howmany > 0)
{
if($which == 5)
{
$db->query("INSERT INTO dpitems VALUES ('$i','$itemfive','$itemfiveqty');");
$which=21;
}
if($which == 4)
{
$db->query("INSERT INTO dpitems VALUES ('$i','$itemfour','$itemfourqty');");
$which=5;
}
if($which == 3)
{
$db->query("INSERT INTO dpitems VALUES ('$i','$itemthree','$itemthreeqty');");
$which=4;
}
if($which == 2)
{
$db->query("INSERT INTO dpitems VALUES ('$i','$itemtwo','$itemtwoqty');");
$which=3;
}
if($which == 1)
{
$db->query("INSERT INTO dpitems VALUES ('$i','$itemone','$itemoneqty');");
$which=2;
}
$howmany=$howmany-1;
}

print"<center>You have successfully added the $name.<br>> <a href=donator.php>Back</a>";
}
else
{
print"<form action='donator.php?add=site' method='post'>
<table width=40% border=1>
<tr>
<th colspan=3>Add A New Donator Pack</th>
</tr>
<tr>
<th>Name:</th>
<td><center><input type='text' name='name' value='{$_POST['name']}' /></center></td><td><center>-</center></td>
</tr>
<tr>
<th>Item Description:</th>
<td><center><input type='text' name='desc' value='{$_POST['desc']}' /></center></td><td><center>-</center></td>
</tr>
<tr>
<th>Price In USD:</th>
<td><center><input type='text' name='price' value='{$_POST['price']}' /></center></td><td><center>-</center></td>
</tr>
<tr>
<th>Donator Days:</th>
<td><center><input type='text' name='days' value='{$_POST['days']}' /></center></td><td><center>-</center></td>
</tr>
<tr>
<th>Crystals:</th>
<td><center><input type='text' name='crystals' value='{$_POST['crystals']}' /></center></td><td><center>-</center></td>
</tr>
<tr>
<th>Money:</th>
<td><center><input type='text' name='money' value='{$_POST['money']}' /></center></td><td><center>-</center></td>
</tr>
<tr>
<th><br>Item ID:<br><br>Item Quantity:<br><br></th>
<td><center><input type='text' name='itemone' value='0' /><br><font color=red size=1>Check box if none.</font><br><input type='text' name='itemoneqty' value='0' /></center></td><td><center><input type='checkbox' name='itemone' value='1000100'></center></td>
</tr>
<tr>
<th><br>Item ID:<br><br>Item Quantity:<br><br></th>
<td><center><input type='text' name='itemtwo' value='0' /><br><font color=red size=1>Check box if none.</font><br><input type='text' name='itemtwoqty' value='0' /></center></td><td><center><input type='checkbox' name='itemtwo' value='1000100'></center></td>
</tr>
<tr>
<th><br>Item ID:<br><br>Item Quantity:<br><br></th>
<td><center><input type='text' name='itemthree' value='0' /><br><font color=red size=1>Check box if none.</font><br><input type='text' name='itemthreeqty' value='0' /></center></td><td><center><input type='checkbox' name='itemthree' value='1000100'></center></td>
</tr>
<tr>
<th><br>Item ID:<br><br>Item Quantity:<br><br></th>
<td><center><input type='text' name='itemfour' value='0' /><br><font color=red size=1>Check box if none.</font><br><input type='text' name='itemfourqty' value='0' /></center></td><td><center><input type='checkbox' name='itemfour' value='1000100'></center></td>
</tr>
<tr>
<th><br>Item ID:<br><br>Item Quantity:<br><br></th>
<td><center><input type='text' name='itemfive' value='0' /><br><font color=red size=1>Check box if none.</font><br><input type='text' name='itemfiveqty' value='0' /></center></td><td><center><input type='checkbox' name='itemfive' value='1000100'></center></td>
</tr>
<tr>
<th colspan=3><input type='submit' value='Add New Donator Pack' /></form></th>
</tr>
</table>";
}
}

if($userid == 1 && $_GET['edit'])
{
$_GET['edit'] = abs((int) $_GET['edit']);
$blak=$db->query("SELECT * FROM dpacks WHERE id={$_GET['edit']}");
if($db->num_rows($blak) == 0)
{
print"<center>This donator pack does not exist!<br>> <a href=donator.php>Back</a></center>";
die("");
}
else
{
$r=$db->fetch_row($blak);
}
print"<br><hr width=75%><br>";
if($_POST['name'] && $_POST['desc'] && $_POST['price'] && $_POST['itemone'] && $_POST['itemtwo'] && $_POST['itemthree'] && $_POST['itemfour'] && $_POST['itemfive'])
{
$money = abs((int) $_POST['money']);
$crystals = abs((int) $_POST['crystals']);
$days = abs((int) $_POST['days']);
$itemone = abs((int) $_POST['itemone']);
$itemoneqty = abs((int) $_POST['itemoneqty']);
$itemtwo = abs((int) $_POST['itemtwo']);
$itemtwoqty = abs((int) $_POST['itemtwoqty']);
$itemthree = abs((int) $_POST['itemthree']);
$itemthreeqty = abs((int) $_POST['itemthreeqty']);
$itemfour = abs((int) $_POST['itemfour']);
$itemfourqty = abs((int) $_POST['itemfourqty']);
$itemfive = abs((int) $_POST['itemfive']);
$itemfiveqty = abs((int) $_POST['itemfiveqty']);
if($itemone == 1000100)
{
$itemone=0;
$itemoneqty=0;
}
if($itemtwo == 1000100)
{
$itemtwo=0;
$itemtwoqty=0;
}
if($itemthree == 1000100)
{
$itemthree=0;
$itemthreeqty=0;
}
if($itemfour == 1000100)
{
$itemfour=0;
$itemfourqty=0;
}
if($itemfive == 1000100)
{
$itemfive=0;
$itemfiveqty=0;
}
$info=str_replace(array("'","\n"),array("'","<br />"),strip_tags($_POST['name']));
$name = $db->escape($info);
$info=str_replace(array("'","\n"),array("'","<br />"),strip_tags($_POST['desc']));
$desc = $db->escape($info);
$info=str_replace(array("'","\n"),array("'","<br />"),strip_tags($_POST['price']));
$price = $db->escape($info);

$howmany=0;
if($itemone > 0)
{
if($itemone == $itemtwo || $itemone == $itemthree || $itemone == $itemfour || $itemone == $itemfive)
{
print"<center>You shouldn't have the same item in multiple places in a Donator Pack<br>> <a href=donator.php>Back</a>";
die("");
}
$juk=$db->query("SELECT * FROM items WHERE itmid=$itemone");
if($db->num_rows($juk) == 0)
{
print"<center>One of the items you have selected does not exist.<br>> <a href=donator.php>Back</a>";
die("");
}
$howmany=1;
}
if($itemtwo > 0)
{
if($itemone == $itemtwo || $itemtwo == $itemthree || $itemtwo == $itemfour || $itemtwo == $itemfive)
{
print"<center>You shouldn't have the same item in multiple places in a Donator Pack<br>> <a href=donator.php>Back</a>";
die("");
}
$juk=$db->query("SELECT * FROM items WHERE itmid=$itemtwo");
if($db->num_rows($juk) == 0)
{
print"<center>One of the items you have selected does not exist.<br>> <a href=donator.php>Back</a>";
die("");
}
$howmany=2;
}
if($itemthree > 0)
{
if($itemthree == $itemtwo || $itemone == $itemthree || $itemthree == $itemfour || $itemthree == $itemfive)
{
print"<center>You shouldn't have the same item in multiple places in a Donator Pack<br>> <a href=donator.php>Back</a>";
die("");
}
$juk=$db->query("SELECT * FROM items WHERE itmid=$itemthree");
if($db->num_rows($juk) == 0)
{
print"<center>One of the items you have selected does not exist.<br>> <a href=donator.php>Back</a>";
die("");
}
$howmany=3;
}
if($itemfour > 0)
{
if($itemfour == $itemtwo || $itemfour == $itemthree || $itemone == $itemfour || $itemfour == $itemfive)
{
print"<center>You shouldn't have the same item in multiple places in a Donator Pack<br>> <a href=donator.php>Back</a>";
die("");
}
$juk=$db->query("SELECT * FROM items WHERE itmid=$itemfour");
if($db->num_rows($juk) == 0)
{
print"<center>One of the items you have selected does not exist.<br>> <a href=donator.php>Back</a>";
die("");
}
$howmany=4;
}
if($itemfive > 0)
{
if($itemfive == $itemtwo || $itemfive == $itemthree || $itemfive == $itemfour || $itemone == $itemfive)
{
print"<center>You shouldn't have the same item in multiple places in a Donator Pack<br>> <a href=donator.php>Back</a>";
die("");
}
$juk=$db->query("SELECT * FROM items WHERE itmid=$itemfive");
if($db->num_rows($juk) == 0)
{
print"<center>One of the items you have selected does not exist.<br>> <a href=donator.php>Back</a>";
die("");
}
$howmany=5;
}

if($itemone == 0 && $howmany > 0 || $itemtwo == 0 && $howmany > 1 || $itemthree == 0 && $howmany > 2 || $itemfour == 0 && $howmany > 3 || $itemfive == 0 && $howmany > 4)
{
print"<center>Make sure you fill in the First Item first, Second Item second... etc.<br>Please do not leave one lower item blank while a higher item is not.<br>> <a href=donator.php>Back</a>";
die("");
}

$db->query("UPDATE dpacks SET crystals=$crystals WHERE id={$r['id']}");
$db->query("UPDATE dpacks SET money=$money WHERE id={$r['id']}");
$db->query("UPDATE dpacks SET days=$days WHERE id={$r['id']}");
$db->query("UPDATE dpacks SET price=$price WHERE id={$r['id']}");
$db->query("UPDATE dpacks SET name='$name' WHERE id={$r['id']}");
$db->query("UPDATE dpacks SET items=$howmany WHERE id={$r['id']}");
$db->query("UPDATE dpacks SET description='$desc' WHERE id={$r['id']}");
$db->query("UPDATE items SET itmdesc='$desc' WHERE itmid={$r['id']}");
$db->query("UPDATE items SET itmname='$name' WHERE itmid={$r['id']}");

$db->query("DELETE FROM dpitems WHERE dpid={$r['id']}");
$which=1;
while($howmany > 0)
{
if($which == 5)
{
$db->query("INSERT INTO dpitems VALUES ('{$r['id']}','$itemfive','$itemfiveqty');");
$which=21;
}
if($which == 4)
{
$db->query("INSERT INTO dpitems VALUES ('{$r['id']}','$itemfour','$itemfourqty');");
$which=5;
}
if($which == 3)
{
$db->query("INSERT INTO dpitems VALUES ('{$r['id']}','$itemthree','$itemthreeqty');");
$which=4;
}
if($which == 2)
{
$db->query("INSERT INTO dpitems VALUES ('{$r['id']}','$itemtwo','$itemtwoqty');");
$which=3;
}
if($which == 1)
{
$db->query("INSERT INTO dpitems VALUES ('{$r['id']}','$itemone','$itemoneqty');");
$which=2;
}
$howmany=$howmany-1;
}

print"<center>You have successfully edited the $name.<br>> <a href=donator.php>Back</a>";
}
else
{
print"<form action='donator.php?edit={$_GET['edit']}' method='post'>
<table width=40% border=1>
<tr>
<th colspan=3>Edit The {$r['name']}</th>
</tr>
<tr>
<th>Name:</th>
<td><center><input type='text' name='name' value='{$r['name']}' /></center></td><td><center>-</center></td>
</tr>
<tr>
<th>Item Description:</th>
<td><center><input type='text' name='desc' value='{$r['description']}' /></center></td><td><center>-</center></td>
</tr>
<tr>
<th>Price In USD:</th>
<td><center><input type='text' name='price' value='{$r['price']}' /></center></td><td><center>-</center></td>
</tr>
<tr>
<th>Donator Days:</th>
<td><center><input type='text' name='days' value='{$r['days']}' /></center></td><td><center>-</center></td>
</tr>
<tr>
<th>Crystals:</th>
<td><center><input type='text' name='crystals' value='{$r['crystals']}' /></center></td><td><center>-</center></td>
</tr>
<tr>
<th>Money:</th>
<td><center><input type='text' name='money' value='{$r['money']}' /></center></td><td><center>-</center></td>
</tr>";

if($r['items'] > 0)
{
$test="one";
$tezt="oneqty";
$jihu=$db->query("SELECT * FROM dpitems WHERE dpid={$r['id']}");
while($wun=$db->fetch_row($jihu))
{
print"<tr>
<th><br>Item ID:<br><br>Item Quantity:<br><br></th>
<td><center><input type='text' name='item$test' value='{$wun['itemid']}' /><br><font color=red size=1>Check box if none.</font><br><input type='text' name='item$tezt' value='{$wun['quantity']}' /></center></td><td><center><input type='checkbox' name='item$test' value='1000100'></center></td>
</tr>";
if($test == "four")
{
$test="five";
$tezt="fiveqty";
}
if($test == "three")
{
$test="four";
$tezt="fourqty";
}
if($test == "two")
{
$test="three";
$tezt="threeqty";
}
if($test == "one")
{
$test="two";
$tezt="twoqty";
}
}
}
$left=5-$r['items'];
while($left > 0)
{
if($left == 5)
{
$test="one";
$tezt="oneqty";
}
if($left == 4)
{
$test="two";
$tezt="twoqty";
}
if($left == 3)
{
$test="three";
$tezt="threeqty";
}
if($left == 2)
{
$test="four";
$tezt="fourqty";
}
if($left == 1)
{
$test="five";
$tezt="fiveqty";
}
print"<tr>
<th><br>Item ID:<br><br>Item Quantity:<br><br></th>
<td><center><input type='text' name='item$test' value='0' /><br><font color=red size=1>Check box if none.</font><br><input type='text' name='item$tezt' value='0' /></center></td><td><center><input type='checkbox' name='item$test' value='1000100' CHECKED></center></td>
</tr>";
$left=$left-1;
}
print"<tr>
<th colspan=3><input type='submit' value='Edit Donator Pack' /></form></th>
</tr>
</table>";
}
}

if($userid == 1 && $_GET['del'])
{
$_GET['del'] = abs((int) $_GET['del']);
$blak=$db->query("SELECT * FROM dpacks WHERE id={$_GET['del']}");
if($db->num_rows($blak) == 0)
{
print"<center>This donator pack does not exist!<br>> <a href=donator.php>Back</a></center>";
die("");
}
else
{
$r=$db->fetch_row($blak);
}
print"<br><hr width=75%><br>";
if($_GET['confirm'])
{
$db->query("UPDATE dpacks SET active=0 WHERE id='{$_GET['del']}'");
print"<center>You have successfully deleted the {$r['name']}.<br>> <a href=donator.php>Back</a>";
}
else
{
print"<form action='donator.php?del={$_GET['del']}&confirm=delete' method='post'>
<table width=55% border=1>
<tr>
<th colspan=2>Are you sure you would like to delete the {$r['name']}?<br><font color=red size=1>This will only remove the item from the donate page, it will still exist in the items.</font></th>
</tr>
<tr>
<th colspan=2><input type='submit' value='Delete Donator Pack' /></form></th>
</tr>
</table>";
}
}
$h->endpage();
?>

donatorstats.php

<?php

//------------------------------------------------
//Mod created by Cronus.
//You can find more of his mods for sale
//and join his MCCode developers community here:
//http://www.cronwerks.com/forum
//------------------------------------------------

include "globals.php";
if($userid == 1)
{
print"<br><br><table class=table width=80% border=1>
<tr><th colspan=2>Your Games Donation Statistics</th></tr>
<tr><td width=50%><center><a href=donatorstats.php>Latest 25 Donations</a></center></td><td><center><a href=donatorstats.php?action=top>Top Donators</a></center></td></tr>
<tr><td width=50%><center><a href=donatorstats.php?action=year>Last Week/Month/Year</a></center></td><td><center><a href=donatorstats.php?action=search>Search For User</a></center></td></tr>
</table>";

function search()
{
global $db,$ir,$c,$userid,$h;
$id=0;
if($_GET['ID'])
{
$id=$_GET['ID'];

$n=$db->query("SELECT * FROM users WHERE userid=$id");
$user=$db->fetch_row($n);

print "<br>
<table width=75% border=1><tr><th colspan=3>Donations Made By {$user['username']}</th></tr>
<tr><th>Date/Time</th><th>DP Purchased xQTY</th><th>Donated</th></tr>";
$total=0;
$blah=$db->query("SELECT * FROM dplogs WHERE user=$id ORDER BY time DESC");
while($r=$db->fetch_row($blah))
{
$total=$total+$r['cost'];
$f=$db->query("SELECT * FROM items WHERE itmid={$r['pack']}");
$item=$db->fetch_row($f);
print "<tr><td>".date('F j Y, g:i:s a',$r['time']);
print"</td><td><a href=iteminfo.php?ID={$r['pack']}>{$item['itmname']}</a> <i>x{$r['quantity']}</i></td><td>\${$r['cost']}</td></tr>";
}

print"<tr><th colspan=2></th><th>$$total</th></tr></table>";
}

print"<br><table width=75% border=1><tr><th>Enter A User's ID</th></tr><tr><td><center><form action='donatorstats.php?action=search' method='get'>
<input type='text' name='ID' /><br>
<input type='hidden' name='action' value='search'/>
<input type='submit' value='Search For Donations' /></form></center></td></tr></table>";

}

function home()
{
global $db,$ir,$c,$userid,$h;
$amt=25;
if($_GET['amount'])
{
$amt=$_GET['amount'];
}
print "<br>
<table width=75% border=1><tr><th colspan=4>Viewing The Latest $amt Donations<br><font size=1> <a href=donatorstats.php?amount=10>10</a> - <a href=donatorstats.php?amount=25>25</a> - <a href=donatorstats.php?amount=50>50</a> - <a href=donatorstats.php?amount=100>100</a> - <a href=donatorstats.php?amount=250>250</a></font></th></tr>
<tr><th>Date/Time</th><th>User</th><th>DP Purchased xQTY</th><th>Donated</th></tr>";
$total=0;
$blah=$db->query("SELECT * FROM dplogs ORDER BY time DESC LIMIT $amt");
while($r=$db->fetch_row($blah))
{
$total=$total+$r['cost'];
$n=$db->query("SELECT * FROM users WHERE userid={$r['user']}");
$user=$db->fetch_row($n);
$f=$db->query("SELECT * FROM items WHERE itmid={$r['pack']}");
$item=$db->fetch_row($f);
print "<tr><td>".date('F j Y, g:i:s a',$r['time']);
print"</td><td><a href=viewuser.php?u={$r['user']}>{$user['username']}</a> [{$r['user']}]</td><td><a href=iteminfo.php?ID={$r['pack']}>{$item['itmname']}</a> <i>x{$r['quantity']}</i></td><td>\${$r['cost']}</td></tr>";
}

print"<tr><th colspan=3></th><th>$$total</th></tr></table>";
}

function year()
{
global $db,$ir,$c,$userid,$h;
if($_GET['amount'] == 0)
{
$amt="Week";
$time=time()-604800;
}
if($_GET['amount'] == 1)
{
$amt="Month";
$time=time()-2629743;
}
if($_GET['amount'] == 2)
{
$amt="Year";
$time=time()-31556926;
}
if($_GET['amount'] == 3)
{
$amt="Eternity";
$time=0;
}
print "<br>
<table width=75% border=1><tr><th colspan=4>Viewing All Transactions In The Last $amt<br><font size=1><a href=donatorstats.php?action=year&amount=0>Week</a> - <a href=donatorstats.php?action=year&amount=1>Month</a> - <a href=donatorstats.php?action=year&amount=2>Year</a> - <a href=donatorstats.php?action=year&amount=3>All</a></font></th></tr>
<tr><th>Date/Time</th><th>User</th><th>DP Purchased xQTY</th><th>Donated</th></tr>";
$total=0;
$blah=$db->query("SELECT * FROM dplogs WHERE time>$time ORDER BY time DESC");
while($r=$db->fetch_row($blah))
{
$total=$total+$r['cost'];
$n=$db->query("SELECT * FROM users WHERE userid={$r['user']}");
$user=$db->fetch_row($n);
$f=$db->query("SELECT * FROM items WHERE itmid={$r['pack']}");
$item=$db->fetch_row($f);
print "<tr><td>".date('F j Y, g:i:s a',$r['time']);
print"</td><td><a href=viewuser.php?u={$r['user']}>{$user['username']}</a> [{$r['user']}]</td><td><a href=iteminfo.php?ID={$r['pack']}>{$item['itmname']}</a> <i>x{$r['quantity']}</i></td><td>\${$r['cost']}</td></tr>";
}

print"<tr><th colspan=3></th><th>$$total</th></tr></table>";
}

function top()
{
global $db,$ir,$c,$userid,$h;
$amt=10;
if($_GET['amount'])
{
$amt=$_GET['amount'];
}
print "<br>
<table width=75% border=1><tr><th colspan=4>Viewing The Top $amt Donators<br><font size=1><a href=donatorstats.php?action=top&amount=10>10</a> - <a href=donatorstats.php?action=top&amount=25>25</a> - <a href=donatorstats.php?action=top&amount=50>50</a> - <a href=donatorstats.php?action=top&amount=100>100</a> - <a href=donatorstats.php?action=top&amount=250>250</a></font></th></tr>
<tr><th>User</th><th>Donated</th><th>---</tr>";
$total=0;
$blah=$db->query("SELECT * FROM users WHERE donated>0 AND userid!=1 ORDER BY donated DESC LIMIT $amt");
while($r=$db->fetch_row($blah))
{
print"<tr><td><a href=viewuser.php?u={$r['userid']}>{$r['username']}</a> [{$r['userid']}]</td><td>\${$r['donated']}</a></td><td><center><a href=donatorstats.php?action=search&ID={$r['userid']}>View</a></center></td></tr>";
}

print"</table>";
}

switch($_GET['action'])
{
case 'top':
top();
break;

case 'year':
year();
break;

case 'search':
search();
break;

default:
home();
break;
}

}
$h->endpage();
?>

ipn_donator.php

<?

//------------------------------------------------
// Mod created by Cronus.
// You can find more of his mods for sale
// and join his MCCode developers community here:
// http://www.cronwerks.com/forum
//------------------------------------------------

$primarypaypal="your paypal email here";
$currency="USD";
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(""); }
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
if($receiver_email != $primarypaypal) { 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(""); }

$meki=$db->query("SELECT * FROM dpacks WHERE id={$packr[1]} AND active=1");
if($db->num_rows($meki) == 0)
{
fclose($fp);
die("");
}
else
{
$r=$db->fetch_row($meki);
}

$total=$r['price']*$packr[2];
if($total != $payment_amount)
{
fclose($fp);
die("");
}
// grab IDs
$buyer=$packr[3];
$number=$packr[2];
// all seems to be in order, credit it.
$time=time();
$db->query("INSERT INTO dplogs VALUES('','$buyer',{$r['id']},'$number','$time', '$payment_amount')") or die(mysql_error());
$db->query("UPDATE users SET donated=donated+$payment_amount WHERE userid={$r['id']}");
$db->query("UPDATE users SET donated=donated+$payment_amount WHERE userid=1");
if($r['bogo'] > 0)
{
$add=floor($number/$r['bogo']);
$number=$number+$add;
}

$db->query("INSERT INTO inventory VALUES('',{$r['id']},'$buyer','$number')",$c) or die(mysql_error());

// process payment
event_add($buyer, "Your donation has been successfully credited to you. Thank you for your support.", $c);
event_add(1, "ID $buyer has purchased $number {$r['name']}(s) for $$payment_amount.", $c);

}
else if (strcmp ($res, "INVALID") == 0) {
}
}

fclose ($fp);
}
?>

in itemuse.php just below require globals add:

$i=$db->query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i.itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid");
if(mysqli_num_rows($i) == 0)
{
print "Invalid item ID";
}
else
{
$r=$db->fetch_row($i);
if($r['itmtypeid'] == 999)
{
$look=$db->query("SELECT * FROM dpacks WHERE id={$r['itmid']}");
$dp=$db->fetch_row($look);
print"<br><br><center>You opened your {$r['itmname']} and look inside.<br>";
if($dp['days'] > 0)
{
$days=$dp['days'];
$db->query("UPDATE users SET donatordays=donatordays+$days WHERE userid=$userid");
print"You find $days Donator Days!<br>";
}
if($dp['crystals'] > 0)
{
$crystals=$dp['crystals'];
$db->query("UPDATE users SET crystals=crystals+$crystals WHERE userid=$userid");
print"You find $crystals Crystals!<br>";
}
if($dp['money'] > 0)
{
$money=$dp['money'];
$muneh=money_formatter($money);
$db->query("UPDATE users SET money=money+$money WHERE userid=$userid");
print"You find $muneh!<br>";
}
if($dp['items'] > 0)
{
$mok=$db->query("SELECT * FROM dpitems WHERE dpid={$dp['id']}");
while($item=$db->fetch_row($mok))
{
$db->query("INSERT INTO inventory (inv_itemid,inv_userid,inv_qty) values('{$item['itemid']}','$userid','{$item['quantity']}')",$c) or die(mysql_error());
$b=$db->query("SELECT * FROM items WHERE itmid={$item['itemid']}");
$something=$db->fetch_row($b);
print"You found {$item['quantity']} {$something['itmname']}(s)!<br>";
}
}
item_remove($userid, $r['inv_itemid'], 1);
die("");
}
}

 

SQL:

-- 
-- Table structure for table `dpacks`
-- 

CREATE TABLE `dpacks` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `crystals` int(11) NOT NULL,
  `money` int(11) NOT NULL,
  `days` int(11) NOT NULL,
  `price` decimal(10,2) NOT NULL,
  `description` text NOT NULL,
  `items` int(11) NOT NULL,
  `active` int(11) NOT NULL DEFAULT '1',
  `hidden` int(11) NOT NULL DEFAULT '0',
  `bogo` int(11) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

-- 
-- Table structure for table `dplogs`
-- 

CREATE TABLE `dplogs` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`user` INT NOT NULL ,
`pack` INT NOT NULL ,
`quantity` INT NOT NULL ,
`time` INT NOT NULL ,
`cost` decimal(10,2) NOT NULL
) ENGINE = MYISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

-- 
-- Table structure for table `dpitems`
-- 

CREATE TABLE `dpitems` (
  `dpid` int(11) NOT NULL,
  `itemid` int(11) NOT NULL,
  `quantity` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

ALTER TABLE `users` ADD `donated` INT NOT NULL DEFAULT '0' AFTER `posts`;

 

Screenshots:

 

screenie1.png

screenie2.png

screenie3.png

screenie4.png

screenie5.png

Remember to make sure you change the paypal email address in the files to your own.

Edited by PHPStudent
  • Like 1

Share this post


Link to post
Share on other sites

I have Dave's Ajax donation mod and unless you know what your doing it won't work from default as its outdated.

  • Like 1

Share this post


Link to post
Share on other sites
15 minutes ago, peterisgb said:

I have Dave's Ajax donation mod and unless you know what your doing it won't work from default as its outdated.

It hasn't been updated yet ? @Dave

Share this post


Link to post
Share on other sites
1 hour ago, PHPStudent said:

It hasn't been updated yet ? @Dave

I wrote that thing 10 years ago, and considering it's $15 there's no real reason for me to update it.

It'll probably work fine on PHP 5 as that's what it was written for.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
19 minutes ago, Dave said:

I wrote that thing 10 years ago, and considering it's $15 there's no real reason for me to update it.

It'll probably work fine on PHP 5 as that's what it was written for.

I am currently updating the default version of this myself atm.
I have most of it working now, Just cant figure out how to get the ajax to work. Weak Point for me.

Share this post


Link to post
Share on other sites
4 hours ago, Dave said:

I wrote that thing 10 years ago, and considering it's $15 there's no real reason for me to update it.

It'll probably work fine on PHP 5 as that's what it was written for.

I understand. Just not good for people who don't know what they're doing if it doesn't work out of the box... 

older versions of PHP are not supported anymore either

Edited by PHPStudent

Share this post


Link to post
Share on other sites
16 minutes ago, PHPStudent said:

I understand. Just not good for people who don't know what they're doing if it doesn't work out of the box... 

Most browsers don't support older versions of PHP either

MCCodes v2 doesn't work out of the box on PHP 7, so the donation system does work out of the box if you run it on a version of PHP which MCCodes support.

As the potential income from the module is so low I'd need to drastically increase the price to make it at all reasonable for me to update the code, let alone specify a version of MCCodes v2 which doesn't exist today.

All browser support all versions of PHP, PHP is a server side language and has nothing to do with the browser.

Share this post


Link to post
Share on other sites

is there a Donator system that does work out of the box or at least one thats like the first one posted that a beginner can work on?

Share this post


Link to post
Share on other sites
11 hours ago, MajikalJoker said:

is there a Donator system that does work out of the box or at least one thats like the first one posted that a beginner can work on?

The one posted in this thread should work just fine, are you having issues with it?

Share this post


Link to post
Share on other sites

I think if you change your php version through cpanel to php 5, Dave's ajax one will work too. Atleast thats what I've been told.

Share this post


Link to post
Share on other sites
6 hours ago, PHPStudent said:

I think if you change your php version through cpanel to php 5, Dave's ajax one will work too. Atleast thats what I've been told.

I gave it a try yesterday on php 5.6 and failed 😞

  • Confused 1

Share this post


Link to post
Share on other sites

Lines 97 and 106 of ipn_donator.php, and line 39 of the addition to itemuse.php make calls to mysql_error().
In PHP7, mysql_*() functions don't exist.

In this instance, those calls can be safely removed

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)
19 minutes ago, Magictallguy said:

Lines 97 and 106 of ipn_donator.php, and line 39 of the addition to itemuse.php make calls to mysql_error().
In PHP7, mysql_*() functions don't exist.

In this instance, those calls can be safely removed

Will remove it, thank you. 

I tested this module on xampp and then donated to test if packs were auto credited and donator stats would update and neither did, is that because I was using xampp? 

Nevermind, it doesnt work either way. Just checked on a live server

Edited by PHPStudent

Share this post


Link to post
Share on other sites

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...