diff --git a/config.php b/config.php
index a7bc141..ba37179 100644
--- a/config.php
+++ b/config.php
@@ -890,6 +890,7 @@
// If useDB is set to true, player can shop in-game as well using Znote LUA shop system plugin.
$config['shop'] = array(
'enabled' => false,
+ 'loginToView' => false, // Do user need to login to see the shop offers?
'enableShopConfirmation' => true, // Verify that user wants to buy with popup
'useDB' => false, // Fetch offers from database, or the below config array
'showImage' => true,
diff --git a/shop.php b/shop.php
index 34cea90..2d1460a 100644
--- a/shop.php
+++ b/shop.php
@@ -1,6 +1,5 @@
alert("Seu pagamento está sendo processado pelo PagSeguro...");';
@@ -8,64 +7,69 @@ if (isset($_GET['callback']) && $_GET['callback'] === 'processing') {
// Import from config:
$shop = $config['shop'];
+if ($shop['loginToView'] === true) protect_page();
+$loggedin = user_logged_in();
+
$shop_list = $config['shop_offers'];
-if (!empty($_POST['buy']) && $_SESSION['shop_session'] == $_POST['session']) {
- $time = time();
- $player_points = (int)$user_znote_data['points'];
- $cid = (int)$user_data['id'];
- // Sanitizing post, setting default buy value
- $buy = false;
- $post = (int)$_POST['buy'];
-
- foreach ($shop_list as $key => $value) {
- if ($key === $post) {
- $buy = $value;
+if ($loggedin === true) {
+ if (!empty($_POST['buy']) && $_SESSION['shop_session'] == $_POST['session']) {
+ $time = time();
+ $player_points = (int)$user_znote_data['points'];
+ $cid = (int)$user_data['id'];
+ // Sanitizing post, setting default buy value
+ $buy = false;
+ $post = (int)$_POST['buy'];
+
+ foreach ($shop_list as $key => $value) {
+ if ($key === $post) {
+ $buy = $value;
+ }
}
+ if ($buy === false) die("Error: Shop offer ID mismatch.");
+
+ // Verify that user can afford this offer.
+ if ($player_points >= $buy['points']) {
+ $data = mysql_select_single("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';");
+ if (!$data) die("0: Account is not converted to work with Znote AAC");
+ $old_points = $data['points'];
+ if ((int)$old_points != (int)$player_points) die("1: Failed to equalize your points.");
+ // Remove points if they can afford
+ // Give points to user
+ $expense_points = $buy['points'];
+ $new_points = $old_points - $expense_points;
+ $update_account = mysql_update("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$cid'");
+
+ $data = mysql_select_single("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';");
+ $verify = $data['points'];
+ if ((int)$old_points == (int)$verify) die("2: Failed to equalize your points.". var_dump((int)$old_points, (int)$verify, $new_points, $expense_points));
+
+ // Do the magic (insert into db, or change sex etc)
+ // If type is 2 or 3
+ if ($buy['type'] == 2) {
+ // Add premium days to account
+ user_account_add_premdays($cid, $buy['count']);
+ echo 'You now have '.$buy['count'].' additional days of premium membership.';
+ } else if ($buy['type'] == 3) {
+ // Character Gender
+ mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
+ echo 'You now have access to change character gender on your characters. Visit My Account to select character and change the gender.';
+ } else if ($buy['type'] == 4) {
+ // Character Name
+ mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
+ echo 'You now have access to change character name on your characters. Visit My Account to select character and change the name.';
+ } else {
+ mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
+ echo 'Your order is ready to be delivered. Write this command in-game to get it: [!shop].
Make sure you are in depot and can carry it before executing the command!';
+ }
+
+ // No matter which type, we will always log it.
+ mysql_insert("INSERT INTO `znote_shop_logs` (`account_id`, `player_id`, `type`, `itemid`, `count`, `points`, `time`) VALUES ('$cid', '0', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '". $buy['points'] ."', '$time')");
+
+ } else echo 'You need more points, this offer cost '.$buy['points'].' points.';
+ //var_dump($buy);
+ //echo ''. $_POST['buy'] .'';
}
- if ($buy === false) die("Error: Shop offer ID mismatch.");
-
- // Verify that user can afford this offer.
- if ($player_points >= $buy['points']) {
- $data = mysql_select_single("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';");
- if (!$data) die("0: Account is not converted to work with Znote AAC");
- $old_points = $data['points'];
- if ((int)$old_points != (int)$player_points) die("1: Failed to equalize your points.");
- // Remove points if they can afford
- // Give points to user
- $expense_points = $buy['points'];
- $new_points = $old_points - $expense_points;
- $update_account = mysql_update("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$cid'");
-
- $data = mysql_select_single("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';");
- $verify = $data['points'];
- if ((int)$old_points == (int)$verify) die("2: Failed to equalize your points.". var_dump((int)$old_points, (int)$verify, $new_points, $expense_points));
-
- // Do the magic (insert into db, or change sex etc)
- // If type is 2 or 3
- if ($buy['type'] == 2) {
- // Add premium days to account
- user_account_add_premdays($cid, $buy['count']);
- echo 'You now have '.$buy['count'].' additional days of premium membership.';
- } else if ($buy['type'] == 3) {
- // Character Gender
- mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
- echo 'You now have access to change character gender on your characters. Visit My Account to select character and change the gender.';
- } else if ($buy['type'] == 4) {
- // Character Name
- mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
- echo 'You now have access to change character name on your characters. Visit My Account to select character and change the name.';
- } else {
- mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
- echo 'Your order is ready to be delivered. Write this command in-game to get it: [!shop].
Make sure you are in depot and can carry it before executing the command!';
- }
-
- // No matter which type, we will always log it.
- mysql_insert("INSERT INTO `znote_shop_logs` (`account_id`, `player_id`, `type`, `itemid`, `count`, `points`, `time`) VALUES ('$cid', '0', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '". $buy['points'] ."', '$time')");
-
- } else echo 'You need more points, this offer cost '.$buy['points'].' points.';
- //var_dump($buy);
- //echo ''. $_POST['buy'] .'';
}
if ($shop['enabled']) {
@@ -73,19 +77,23 @@ if ($shop['enabled']) {
Interested in buying characters? View the character auction page!
+Interested in buying characters? View the character auction page!
-You need to be logged in to use the shop.
$offer) {