implement gifting to ppemu

This commit is contained in:
Bluzume 2021-08-09 19:03:05 +12:00
parent be9b0ba8e0
commit ddbf1fd67b
8 changed files with 321 additions and 166 deletions

View file

@ -71,7 +71,7 @@ if(!is_logged_in())
// Get account data
$newUser = getUserExistInExt($dbname, $_SESSION['PLAYER_ID']);
$newUser = !getUserExistInExt($dbname, $_SESSION['PLAYER_ID']);
if(!$newUser){
@ -243,8 +243,8 @@ h+=60;//h += 96;
<input type="hidden" name="business" value="paypal@horseisle.com">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="item_name" value="One Month Horse Isle Membership-on <?php echo($_SERVER["HTTP_HOST"]); ?>">
<input type="hidden" name="item_number" value="588112">
<input type="hidden" name="custom" value="588112">
<input type="hidden" name="item_number" value="<?php echo(htmlspecialchars($_SESSION['PLAYER_ID'])); ?>">
<input type="hidden" name="custom" value="<?php echo(htmlspecialchars($_SESSION['PLAYER_ID'])); ?>">
<input type="hidden" name="amount" value="5.00">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://<?php echo($_SERVER["HTTP_HOST"]); ?>/web/paypalpayment.php">
@ -269,8 +269,8 @@ h+=60;//h += 96;
<input type="hidden" name="business" value="paypal@horseisle.com">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="item_name" value="Full Year Horse Isle Membership-on <?php echo($_SERVER["HTTP_HOST"]); ?>">
<input type="hidden" name="item_number" value="588112">
<input type="hidden" name="custom" value="588112">
<input type="hidden" name="item_number" value="<?php echo(htmlspecialchars($_SESSION['PLAYER_ID'])); ?>">
<input type="hidden" name="custom" value="<?php echo(htmlspecialchars($_SESSION['PLAYER_ID'])); ?>">
<input type="hidden" name="amount" value="40.00">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://<?php echo($_SERVER["HTTP_HOST"]); ?>/web/paypalpayment.php">
@ -296,8 +296,8 @@ h+=60;//h += 96;
<input type="hidden" name="business" value="paypal@horseisle.com">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="item_name" value="100k Horse Isle Money-on pinto.horseisle.com">
<input type="hidden" name="item_number" value="588112">
<input type="hidden" name="custom" value="588112">
<input type="hidden" name="item_number" value="<?php echo(htmlspecialchars($_SESSION['PLAYER_ID'])); ?>">
<input type="hidden" name="custom" value="<?php echo(htmlspecialchars($_SESSION['PLAYER_ID'])); ?>">
<input type="hidden" name="amount" value="1.00">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://pinto.horseisle.com/web/paypalpayment.php">
@ -337,8 +337,8 @@ Select: <SELECT NAME=quantity>
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="paypal@horseisle.com">
<input type="hidden" name="item_name" value="100k Horse Isle Money-on <?php echo($_SERVER["HTTP_HOST"]); ?>">
<input type="hidden" name="item_number" value="588112">
<input type="hidden" name="custom" value="588112">
<input type="hidden" name="item_number" value="<?php echo(htmlspecialchars($_SESSION['PLAYER_ID'])); ?>">
<input type="hidden" name="custom" value="<?php echo(htmlspecialchars($_SESSION['PLAYER_ID'])); ?>">
<input type="hidden" name="amount" value="1.00">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://<?php echo($_SERVER["HTTP_HOST"]); ?>/web/paypalpayment.php">
@ -362,8 +362,8 @@ Select: <SELECT NAME=quantity>
<input type="hidden" name="business" value="paypal@horseisle.com">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="item_name" value="Pawneer Order-on <?php echo($_SERVER["HTTP_HOST"]); ?>">
<input type="hidden" name="item_number" value="588112">
<input type="hidden" name="custom" value="588112">
<input type="hidden" name="item_number" value="<?php echo(htmlspecialchars($_SESSION['PLAYER_ID'])); ?>">
<input type="hidden" name="custom" value="<?php echo(htmlspecialchars($_SESSION['PLAYER_ID'])); ?>">
<input type="hidden" name="amount" value="8.00">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://<?php echo($_SERVER["HTTP_HOST"]); ?>/web/paypalpayment.php">
@ -387,8 +387,8 @@ Select: <SELECT NAME=quantity>
<input type="hidden" name="business" value="paypal@horseisle.com">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="item_name" value="Five Pawneer Order-on <?php echo($_SERVER["HTTP_HOST"]); ?>">
<input type="hidden" name="item_number" value="588112">
<input type="hidden" name="custom" value="588112">
<input type="hidden" name="item_number" value="<?php echo(htmlspecialchars($_SESSION['PLAYER_ID'])); ?>">
<input type="hidden" name="custom" value="<?php echo(htmlspecialchars($_SESSION['PLAYER_ID'])); ?>">
<input type="hidden" name="amount" value="30.00">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://<?php echo($_SERVER["HTTP_HOST"]); ?>/web/paypalpayment.php">

View file

@ -12,6 +12,7 @@ function GenHmacMessage(string $data, string $channel)
return $hmac;
}
function getPlayerList($database)
{
include('config.php');
@ -163,7 +164,7 @@ function getUserExistInExt($database, $id)
$stmt->execute();
$result = $stmt->get_result();
return intval($result->fetch_row()[0]) <= 0;
return intval($result->fetch_row()[0]) >= 1;
}
@ -251,7 +252,7 @@ function isUserOnline($database, $id)
return $count>0;
}
function getNoModPlayersOnlineInServer($database)
function getNoModPlayersOnlineInServer($database)
{
include('config.php');
$dbname = $database;
@ -317,6 +318,19 @@ function getNoPlayersOnlineGlobal()
return $playersOn;
}
function userExistAny($playerId)
{
include('servers.php');
for($i = 0; $i < count($server_list); $i++)
{
if(userid_exists($server_list[$i]['database'], $playerId)){
return true;
}
}
return false;
}
function getNoSubbedPlayersOnlineGlobal()
{
include('servers.php');

View file

@ -1,4 +1,6 @@
<?php include("header.php"); ?>
<?php
include("header.php");
?>
<BR>
<CENTER><TABLE CELLPADDING=5><TR><TD></CENTER>
<FONT FACE=arial>
@ -14,4 +16,6 @@ Click back to your <A HREF="/account.php">ACCOUNT</A> page to see any credited s
<B>PARENTS:</B> please email support@horseisle.com from the paypal email or signup email to
block chat, or limit time online for this account if you want to.<BR>
</TD></TR></TABLE>
<?php include("footer.php"); ?>
<?php
include("footer.php");
?>

View file

@ -13,26 +13,30 @@ if(!is_logged_in()){
}
$money = getUserMoney($dbname, $_SESSION['PLAYER_ID']);
$subbed = getUserSubbed($dbname, $_SESSION['PLAYER_ID']);
$subbedUntil = getUserSubTimeRemaining($dbname, $_SESSION['PLAYER_ID']);
if(!$subbed)
$subbedUntil = time();
if(isset($_GET["go"], $_GET["qnt"], $_GET["itm"], $_GET["ret"]))
if(isset($_GET["go"], $_GET["qnt"], $_GET["itm"], $_GET['to'], $_GET["ret"]))
{
$targetUser = $_GET['to'];
$subbed = getUserSubbed($dbname, $targetUser);
$subbedUntil = getUserSubTimeRemaining($dbname, $targetUser);
$moneyTarget = getUserMoney($dbname, $targetUser);
if(!$subbed)
$subbedUntil = time();
if($_GET["go"] == 1)
{
$itm = $_GET["itm"];
$itm = $_GET["itm"];
if(strpos($itm, "One Month Horse Isle Membership") === 0){
$amount = 5; // NO CHEATING!
$cost = $amount*$EXHANGE_RATE;
if($money >= $cost)
{
setUserMoney($dbname, $_SESSION['PLAYER_ID'], $money-$cost);
setUserSubbed($dbname, $_SESSION['PLAYER_ID'], true);
setUserSubbedUntil($dbname, $_SESSION['PLAYER_ID'], $subbedUntil + 2678400);
setUserSubbed($dbname,$targetUser, true);
setUserSubbedUntil($dbname, $targetUser, $subbedUntil + 2678400);
header("Location: ".$_GET["ret"]);
}
@ -51,8 +55,8 @@ if(isset($_GET["go"], $_GET["qnt"], $_GET["itm"], $_GET["ret"]))
if($money >= $cost)
{
setUserMoney($dbname, $_SESSION['PLAYER_ID'], $money-$cost);
setUserSubbed($dbname, $_SESSION['PLAYER_ID'], true);
setUserSubbedUntil($dbname, $_SESSION['PLAYER_ID'], $subbedUntil + 31622400);
setUserSubbed($dbname, $targetUser, true);
setUserSubbedUntil($dbname, $targetUser, $subbedUntil + 31622400);
header("Location: ".$_GET["ret"]);
@ -91,7 +95,7 @@ if(isset($_GET["go"], $_GET["qnt"], $_GET["itm"], $_GET["ret"]))
setUserMoney($dbname, $_SESSION['PLAYER_ID'], $money-$cost);
$money-=$cost;
setUserMoney($dbname, $_SESSION['PLAYER_ID'], $money+=$amountGained);
setUserMoney($dbname, $targetUser, $moneyTarget+=$amountGained);
header("Location: ".$_GET["ret"]);
}
@ -111,7 +115,7 @@ if(isset($_GET["go"], $_GET["qnt"], $_GET["itm"], $_GET["ret"]))
if($money >= $cost)
{
setUserMoney($dbname, $_SESSION['PLAYER_ID'], $money-$cost);
addItemToPuchaseQueue($dbname, $_SESSION['PLAYER_ID'], 559, 1);
addItemToPuchaseQueue($dbname, $targetUser, 559, 1);
header("Location: ".$_GET["ret"]);
@ -132,7 +136,7 @@ if(isset($_GET["go"], $_GET["qnt"], $_GET["itm"], $_GET["ret"]))
if($money >= $cost)
{
setUserMoney($dbname, $_SESSION['PLAYER_ID'], $money-$cost);
addItemToPuchaseQueue($dbname, $_SESSION['PLAYER_ID'], 559, 5);
addItemToPuchaseQueue($dbname, $targetUser, 559, 5);
header("Location: ".$_GET["ret"]);
@ -153,7 +157,7 @@ if(isset($_GET["go"], $_GET["qnt"], $_GET["itm"], $_GET["ret"]))
}
$quantity = 1;
if(!isset($_POST['item_name'], $_POST['amount'], $_POST['item_number'], $_POST['return']))
if(!isset($_POST['item_name'], $_POST['amount'], $_POST['item_number'], $_POST['custom'], $_POST['return']))
{
include("header.php");
@ -161,6 +165,7 @@ if(!isset($_POST['item_name'], $_POST['amount'], $_POST['item_number'], $_POST[
include("footer.php");
exit();
}
if(isset($_POST['quantity']))
$quantity = intval($_POST['quantity']);
@ -170,6 +175,18 @@ $hasIntl = function_exists('numfmt_create');
if($hasIntl)
$fmt = numfmt_create( 'en_US', NumberFormatter::DECIMAL );
$toUser = $_POST['custom'];
$toUsername = "";
if(!getUserExistInExt($dbname, $toUser))
{
include("header.php");
echo("Cannot buy for a user who does not exist on this server.");
include("footer.php");
exit();
}
else{
$toUsername = get_username($toUser);
}
include("header.php");
?>
@ -207,7 +224,7 @@ include("header.php");
?></td>
</tr>
</table>
<h3><b>NOTE: $1USD = $<?php echo($EXHANGE_RATE)?> HorseIsle Money! (you have $<?php echo($money) ?>)</b></h3><br>Do you want to purchase?</br><br><a href="?go=1&itm=<?php echo(urlencode(htmlspecialchars($_POST['item_name']))); ?>&qnt=<?php echo(urlencode(htmlspecialchars($quantity)));?>&ret=<?php echo(urlencode(htmlspecialchars($_POST['return']))); ?>">Yes</a> | <a href="/account.php">No</a>
<h3><b>NOTE: $1USD = $<?php echo($EXHANGE_RATE)?> HorseIsle Money! (you have $<?php echo($money) ?>)</b></h3><br><b>This purchase is for User: <?php echo(htmlspecialchars($toUser)." (".$toUsername.")"); ?></b></br>Do you want to purchase?</br><br><a href="?go=1&itm=<?php echo(urlencode(htmlspecialchars($_POST['item_name']))); ?>&qnt=<?php echo(urlencode(htmlspecialchars($quantity)));?>&to=<?php echo(urlencode(htmlspecialchars($_POST['custom']))); ?>&ret=<?php echo(urlencode(htmlspecialchars($_POST['return']))); ?>">Yes</a> | <a href="/account.php">No</a>
<?php
include("footer.php");
?>