aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--craftmine.php10
-rw-r--r--index.xhtml2
-rw-r--r--js/craftmine.js8
3 files changed, 17 insertions, 3 deletions
diff --git a/craftmine.php b/craftmine.php
index 78c5e37..dd2aa9e 100644
--- a/craftmine.php
+++ b/craftmine.php
@@ -7,6 +7,8 @@ require_once("inc/craftmine.inc");
session_start(); // Must be placed *BEFORE* $_SESSION is actually used and *AFTER* all classes are imported
+$op = "";
+
/**
* Indique au client une message requete.
*/
@@ -27,14 +29,16 @@ function reportBadRequest() {
exit();
}
if (!isset($_POST["op"])) {
- reportBadRequest();
-}
+ if(!isset($_GET["op"]))
+ reportBadRequest();
+ else
+ $op = $_GET["op"];
+} else $op = $_POST["op"];
/**
* On récupère l'opération à exécuter et on le fait.
*/
-$op = $_POST["op"];
switch($op) {
case "withdrawMine": withdrawMine(); break;
case "createGuild": createGuild(); break;
diff --git a/index.xhtml b/index.xhtml
index aa29615..d12585f 100644
--- a/index.xhtml
+++ b/index.xhtml
@@ -32,6 +32,8 @@
<form class="form-horizontal" method="post" action="craftmine.php">
<button class="btn btn-default" type="button" name="withdraw" onclick="withdrawMine()">Withdraw</button>
<button class="btn btn-default" type="button" name="HireMiner" onclick="hireMiner()">Hire one miner</button>
+ <button class="btn btn-default" type="button" onclick="saveGame()">Save game</button>
+ <button class="btn btn-default" type="button" onclick="downGame()">Download game</button>
</form>
</div>
</div>
diff --git a/js/craftmine.js b/js/craftmine.js
index 92fa45a..13dd0a2 100644
--- a/js/craftmine.js
+++ b/js/craftmine.js
@@ -60,6 +60,14 @@ function updateMine() {
updateData("mine");
}
+function saveGame() {
+ sendRequest("craftmine.php", "op=saveGame");
+}
+
+function downGame() {
+ window.open("craftmine.php?op=downGame", "_blank");
+}
+
function init() {
initCraftMine();
changeTab();