diff --git a/.htaccess b/.htaccess
index 2eeba47..f8ea557 100644
--- a/.htaccess
+++ b/.htaccess
@@ -1,2 +1 @@
-## Default .htaccess file
php_value suhosin.srand.ignore 0
\ No newline at end of file
diff --git a/attackplace.php b/attackplace.php
index 50abcaa..583577f 100644
--- a/attackplace.php
+++ b/attackplace.php
@@ -6,7 +6,7 @@ require 'onlyloggedin.php';
use AnthonyMartin\GeoLocation\GeoLocation as GeoLocation;
if (is_empty($VARS['locationid'])) {
- sendError("No target!", true);
+ sendError(PLACE_ID_NOT_SENT, true);
}
$place = $database->select('locations', ['locationid', 'teamid', 'owneruuid', 'currentlife', 'maxlife', 'osmid'], ['locationid' => $VARS['locationid']])[0];
@@ -14,7 +14,7 @@ $user = $database->select('players', ['level', 'teamid', 'energy', 'maxenergy',
// This (probably) shouldn't happen in normal play
if ($place['teamid'] == $user['teamid']) {
- sendError("Cannot attack!", true);
+ sendError(PLACE_OWNED_BY_SAME_TEAM, true);
}
// The damage formulas
@@ -83,7 +83,7 @@ $damage = pow(floor($user['level']), 0.5) * 4 * $type_mod * $terrain_mod * $weat
//$damage = 2 * $userdrain * $TYPE_GRID[$user['teamid']][$place['teamid']];
// Check if action possible
if ($user['energy'] < $userdrain) {
- sendError("No life left!", true);
+ sendError(PLAYER_NO_LIFE_LEFT, true);
}
// Calculate resulting user HP
@@ -118,4 +118,4 @@ if ($placehp == 0) {
$database->update('locations', ['currentlife' => $placehp], ['locationid' => $VARS['locationid']]);
}
-sendOK(($dolevelup ? "Level up!" : "Success!"));
+sendOK(($dolevelup ? PLAYER_LEVEL_UP : PLACE_SUCCESS));
diff --git a/buyitem.php b/buyitem.php
index 25dd396..fc9759d 100644
--- a/buyitem.php
+++ b/buyitem.php
@@ -4,18 +4,18 @@ require 'required.php';
require 'onlyloggedin.php';
if (!$database->has('shopitems', ['merchid' => $VARS['merchid']])) {
- sendError("That item is not available at this time.", true);
+ sendError(ITEM_UNAVAILABLE, true);
}
$shopitem = $database->select('shopitems', ['merchid', 'itemid', 'quantity', 'cost'], ['merchid' => $VARS['merchid']])[0];
if (!is_empty($VARS['cost']) && !($shopitem['cost'] == $VARS['cost'])) {
- sendError("That item is no longer available at that price.", true);
+ sendError(ITEM_INCORRECT_PRICE, true);
}
$credits = $database->select('players', ['credits'], ['uuid' => $_SESSION['uuid']])[0]['credits'];
if ($credits < $shopitem['cost']) {
- sendError("You don't have enough money!", true);
+ sendError(PLAYER_NOT_ENOUGH_CREDITS, true);
}
for ($i = 0; $i < $shopitem['quantity']; $i++) {
@@ -24,4 +24,4 @@ for ($i = 0; $i < $shopitem['quantity']; $i++) {
$database->update('players', ['credits' => ($credits - $shopitem['cost'])], ['uuid' => $_SESSION['uuid']]);
-sendOK("Thanks for your purchase!");
\ No newline at end of file
+sendOK(ITEM_PURCHASED);
\ No newline at end of file
diff --git a/claimplace.php b/claimplace.php
index 134e39d..f4760fa 100644
--- a/claimplace.php
+++ b/claimplace.php
@@ -4,7 +4,7 @@ require 'required.php';
require 'onlyloggedin.php';
if (is_empty($VARS['locationid'])) {
- sendError("No target!", true);
+ sendError(PLACE_ID_NOT_SENT, true);
}
$place = $database->select('locations', ['locationid', 'teamid', 'owneruuid', 'currentlife', 'maxlife'], ['locationid' => $VARS['locationid']])[0];
@@ -12,11 +12,11 @@ $user = $database->select('players', ['level', 'teamid', 'energy', 'maxenergy',
// This (probably) shouldn't happen in normal play
if ($place['teamid'] == $user['teamid']) {
- sendError("Don't attack your own kind!", true);
+ sendError(PLACE_OWNED_BY_PLAYER_TEAM, true);
}
if ($place['currentlife'] > 0) {
- sendError("Cannot claim!", true);
+ sendError(PLACE_NO_LIFE_CLAIM, true);
}
$userdrain = 5 * floor($user['level']);
@@ -25,7 +25,7 @@ $userdrain = 5 * floor($user['level']);
$userhp = $user['energy'] - $userdrain;
// Check if action possible
if ($userhp < 0) {
- sendError("No life left!", true);
+ sendError(PLAYER_NO_LIFE_LEFT, true);
}
// Update the user's health and level
@@ -44,4 +44,4 @@ if (floor($userlevel) > floor($user['level'])) {
// Update the place
$database->update('locations', ['currentlife' => 100, 'maxlife' => 100, 'owneruuid' => $_SESSION['uuid'], 'teamid' => $user['teamid']], ['locationid' => $VARS['locationid']]);
-sendOK(($dolevelup ? "Level up!" : "Success!"));
+sendOK(($dolevelup ? PLAYER_LEVEL_UP : PLACE_SUCCESS));
diff --git a/code2item.php b/code2item.php
index 9bc2699..39d4f22 100644
--- a/code2item.php
+++ b/code2item.php
@@ -39,7 +39,7 @@ $returndata = [
];
if (is_empty($origcode)) {
- sendError("Bad code!", true);
+ sendError(BARCODE_INVALID, true);
}
try {
@@ -51,7 +51,7 @@ try {
}
if ($database->has('claimedcodes', ["AND" => ['code' => $origcode, 'playeruuid' => $_SESSION['uuid']]])) {
- $returndata['messages'][] = ["title" => "Huh?", "text" => "You've already found this code!"];
+ $returndata['messages'][] = ["title" => BARCODE_ALREADY_FOUND_TITLE, "text" => BARCODE_ALREADY_FOUND_MSG];
} else {
if ($origcode == "http://terranquest.net/#9001") {
// Secret awesome codez
@@ -74,7 +74,7 @@ if ($database->has('claimedcodes', ["AND" => ['code' => $origcode, 'playeruuid'
$database->insert('claimedcodes', ['code' => $origcode, 'playeruuid' => $_SESSION['uuid']]);
$itemname = $database->select('items', ['itemname'], ['itemid' => $itemcode])[0]['itemname'];
}
- $returndata["messages"][] = ["title" => "Found an item!", "text" => "Found one $itemname"];
+ $returndata["messages"][] = ["title" => BARCODE_ITEM_FOUND_TITLE, "text" => str_replace("%1", $itemname, BARCODE_ITEM_FOUND_MSG)];
}
die(json_encode($returndata));
diff --git a/giveitem.php b/giveitem.php
index 9ede7f9..fba8161 100644
--- a/giveitem.php
+++ b/giveitem.php
@@ -7,11 +7,11 @@ $itemuuid = $VARS['itemuuid'];
$player = $VARS['giveto'];
if (is_empty($itemuuid) || !is_numeric($itemuuid) || !$database->has('inventory', ["AND" => ['itemuuid' => $itemuuid, 'playeruuid' => $_SESSION['uuid']]])) {
- sendError("Invalid itemuuid.", true);
+ sendError(INVALID_ITEMID, true);
}
if (is_empty($player) || !$database->has('players', ['nickname' => $player])) {
- sendError("Invalid nickname.", true);
+ sendError(INVALID_NICKNAME, true);
}
$playeruuid = $database->select('players', ['uuid'], ['nickname' => $player])[0]['uuid'];
diff --git a/lang/en_us.php b/lang/en_us.php
new file mode 100644
index 0000000..6a33125
--- /dev/null
+++ b/lang/en_us.php
@@ -0,0 +1,71 @@
+Back to game");
+define("MUNZEE_FAILED_HTML", "Munzee is having problems right now. Try again later.
Back to game");
+
+/*
+ * onlyloggedin.php, ping.php
+ */
+define("SESSION_EXPIRED", "Your session has expired. Please log in again.");
+
+/*
+ * processiap.php
+ */
+define("INVALID_IAP", "Purchase not valid!");
+
+/*
+ * setteam.php
+ */
+define("INVALID_TEAM_ID", "Invalid team ID.");
+define("TEAM_ALREADY_CHOSEN", "You have already chosen a team. Contact support for problems.");
\ No newline at end of file
diff --git a/login.php b/login.php
index 1419615..337c84e 100644
--- a/login.php
+++ b/login.php
@@ -3,11 +3,11 @@
require 'required.php';
if (is_empty($VARS['user'])) {
- sendError("Missing username.", true);
+ sendError(USERNAME_MISSING, true);
}
if (is_empty($VARS['pass'])) {
- sendError("Missing password.", true);
+ sendError(PASSWORD_MISSING, true);
}
$VARS['user'] = strtolower(str_replace(" ", "", $VARS['user']));
@@ -27,7 +27,7 @@ $guid = file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . urle
/* ------------------------------- */
if (is_empty($guid)) {
- sendError("Account does not exist.", true);
+ sendError(ACCOUNT_MISSING, true);
}
if (!$database->has('players', ['uuid' => $guid])) {
diff --git a/munzee.php b/munzee.php
index 5b22edf..fc7b928 100644
--- a/munzee.php
+++ b/munzee.php
@@ -55,10 +55,10 @@ if (!is_empty($_GET['code'])) {
} else {
$database->insert('munzee', ['bearertoken' => $data['token']['access_token'], 'refreshtoken' => $data['token']['refresh_token'], 'expires' => $data['token']['expires'], 'player_uuid' => $_SESSION['uuid']]);
}
- echo "Your Munzee account has been linked to TerranQuest!
Back to game";
+ echo MUNZEE_LINKED_HTML;
die();
} else {
- echo "Munzee is having problems right now. Try again later.
Back to game";
+ echo MUNZEE_FAILED_HTML;
die();
}
}
\ No newline at end of file
diff --git a/onlyloggedin.php b/onlyloggedin.php
index 11f32f8..a5b334e 100644
--- a/onlyloggedin.php
+++ b/onlyloggedin.php
@@ -5,5 +5,5 @@
*/
if ($_SESSION['loggedin'] != true) {
- sendError('SESSION EXPIRED: Please reauthenticate.', true);
+ sendError(SESSION_EXPIRED, true);
}
\ No newline at end of file
diff --git a/ping.php b/ping.php
index 8766e2d..7eb8004 100644
--- a/ping.php
+++ b/ping.php
@@ -3,7 +3,7 @@
require 'required.php';
if ($_SESSION['loggedin'] != true) {
- sendError('Your session has expired. Please log in again.', true);
+ sendError(SESSION_EXPIRED, true);
} else {
}
diff --git a/processiap.php b/processiap.php
index d407523..17af936 100644
--- a/processiap.php
+++ b/processiap.php
@@ -84,5 +84,5 @@ if ($purchase_valid) {
$database->update('players', ['credits[+]' => $creditstoadd], ['uuid' => $_SESSION['uuid']]);
sendOK();
} else {
- sendError("Purchase not valid!", true);
+ sendError(INVALID_IAP, true);
}
\ No newline at end of file
diff --git a/refillplace.php b/refillplace.php
index 762a48d..6b9bfe1 100644
--- a/refillplace.php
+++ b/refillplace.php
@@ -4,7 +4,7 @@ require 'required.php';
require 'onlyloggedin.php';
if (is_empty($VARS['locationid'])) {
- sendError("No target!", true);
+ sendError(PLACE_ID_NOT_SENT, true);
}
$place = $database->select('locations', ['locationid', 'teamid', 'owneruuid', 'currentlife', 'maxlife'], ['locationid' => $VARS['locationid']])[0];
@@ -12,11 +12,11 @@ $user = $database->select('players', ['level', 'teamid', 'energy', 'maxenergy',
// This (probably) shouldn't happen in normal play
if ($place['teamid'] != $user['teamid']) {
- sendError("Wrong team!", true);
+ sendError(PLACE_OWNED_BY_WRONG_TEAM, true);
}
if ($place['currentlife'] == 100) {
- sendError("Full!", true);
+ sendError(PLACE_HEALTH_IS_FULL, true);
}
$userdrain = 2 * floor($user['level']);
@@ -25,7 +25,7 @@ $userdrain = 2 * floor($user['level']);
$userhp = $user['energy'] - $userdrain;
// Check if action possible
if ($userhp < 0) {
- sendError("No life left!", true);
+ sendError(PLAYER_NO_LIFE_LEFT, true);
}
// Update the user's health and level
@@ -49,4 +49,4 @@ if ($placelife > 100) {
// Update the place
$database->update('locations', ['currentlife' => $placelife, 'maxlife' => 100, 'owneruuid' => $_SESSION['uuid'], 'teamid' => $user['teamid']], ['locationid' => $VARS['locationid']]);
-sendOK(($dolevelup ? "Level up!" : "Refilled!"));
+sendOK(($dolevelup ? PLAYER_LEVEL_UP : PLACE_HEALTH_REFILLED));
diff --git a/required.php b/required.php
index ac9262b..f39c10c 100644
--- a/required.php
+++ b/required.php
@@ -67,3 +67,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
function is_empty($str) {
return (is_null($str) || !isset($str) || $str == '');
}
+
+if (is_empty($VARS['lang'])) {
+ require "lang/en_us.php";
+} else {
+ switch ($VARS['lang']) {
+ case "en":
+ require "lang/en_us.php";
+ case "en_us":
+ require "lang/en_us.php";
+ default:
+ require "lang/en_us.php";
+ }
+}
\ No newline at end of file
diff --git a/setteam.php b/setteam.php
index 69df887..305f3b7 100644
--- a/setteam.php
+++ b/setteam.php
@@ -4,11 +4,11 @@ require 'required.php';
require 'onlyloggedin.php';
if ($VARS['teamid'] < 1 || $VARS['teamid'] > 6) {
- sendError("Invalid team ID.", true);
+ sendError(INVALID_TEAM_ID, true);
}
$currentteam = $database->select('players', 'teamid', ['uuid' => $_SESSION['uuid']])[0];
if ($currentteam > 0 && $currentteam < 7) {
- sendError("You have already chosen a team. Contact support for problems.", true);
+ sendError(TEAM_ALREADY_CHOSEN, true);
}
$database->update('players', ['teamid' => $VARS['teamid']], ['uuid' => $_SESSION['uuid']]);
sendOK();
\ No newline at end of file
diff --git a/useitem.php b/useitem.php
index 8db6740..d8d8993 100644
--- a/useitem.php
+++ b/useitem.php
@@ -6,7 +6,7 @@ require 'onlyloggedin.php';
$itemuuid = $VARS['itemuuid'];
if (is_empty($itemuuid) || !is_numeric($itemuuid) || !$database->has('inventory', ["AND" => ['itemuuid' => $itemuuid, 'playeruuid' => $_SESSION['uuid']]])) {
- sendError("Invalid itemuuid.", true);
+ sendError(INVALID_ITEMID, true);
}
$item = $database->select(