diff --git a/casino.php b/casino.php deleted file mode 100644 index bb9c189..0000000 --- a/casino.php +++ /dev/null @@ -1,80 +0,0 @@ -Règles -
- -
-
- Banque : 1000 -
- tirette - -
-
-
0
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
-
-
-
-
0
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
-
-
-
-
0
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
-
- - -
- Vous : -
- - - HTML; -?> \ No newline at end of file diff --git a/index.php b/index.php deleted file mode 100644 index 0469f1e..0000000 --- a/index.php +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - Bellagio - - -

CASINO BELLAGIO

- "admin", "user"=>"yahou") - //euh ça marche pas ici à régler après - $user_scores = array("admin"=>100, "user"=>200) - if(isset($_POST["username"]) and isset($_POST["password"])){ - if(in_array($_POST["username"], $users) and $_POST["password"] == $users[$_POST["username"]]){ - $_GET['score'] = $user_scores[$_POST["username"]]; - $return_path = "casino.php"; - } - else{ - $_GET['error'] = 1; - $return_path = "login.php"; - } - } - else{ - $return_path = "login.php"; - } - include($return_path); - ?> - - diff --git a/app.js b/jeu/app.js old mode 100644 new mode 100755 similarity index 94% rename from app.js rename to jeu/app.js index 772d689..712b8b7 --- a/app.js +++ b/jeu/app.js @@ -1,17 +1,17 @@ + +const bacDom = document.getElementById("banque_score") +const joueurDom = document.getElementById("joueur_score") +const input = document.getElementById("mise_input"); + let game = { bac: 1000, - joueur: 100, + joueur: parseInt(joueurDom.innerText), inGame: false, mise: 0 } - -const bacDom = document.getElementById("banque_score") -const joueurDom = document.getElementById("joueur_score") -const input = document.getElementById("mise_input"); input.value = game.mise bacDom.innerText = game.bac -joueurDom.innerText = game.joueur function nbAlea(){ return Math.floor(Math.random()*10); @@ -76,6 +76,7 @@ async function jeu(){ } tirette() game.joueur -= game.mise + game.bac += game.mise let tirageNumbers = await tirage() //[2,1,2] @@ -83,13 +84,17 @@ async function jeu(){ document.getElementById("tirage").innerText = tirageNumbers let gain_retour = gain(tirageNumbers) - console.log(gain_retour) game.bac -= gain_retour bacDom.innerText = game.bac game.joueur += gain_retour joueurDom.innerText = game.joueur - console.log(game.mise) + let xhr = new XMLHttpRequest(); + let data = new FormData(); + data.append('compte', JSON.stringify(game.joueur)); + xhr.open("POST", "change_compte.php", true); + xhr.send(data); + input if(game.bac < 500) console.log("fin de partie") if(game.joueur > 0) game.inGame = false diff --git a/jeu/change_compte.php b/jeu/change_compte.php new file mode 100644 index 0000000..44eb03b --- /dev/null +++ b/jeu/change_compte.php @@ -0,0 +1,13 @@ +prepare("UPDATE users SET compte='".$_POST['compte']."' where username = '".$_SESSION['username']."'"); + + $append->execute(); +} + + ?> diff --git a/index.html b/jeu/index.php old mode 100644 new mode 100755 similarity index 93% rename from index.html rename to jeu/index.php index d6c5c48..d092f24 --- a/index.html +++ b/jeu/index.php @@ -1,3 +1,9 @@ +'; + exit; +} + ?> @@ -62,7 +68,7 @@ - Vous : + Vous : diff --git a/jackpot.png b/jeu/jackpot.png old mode 100644 new mode 100755 similarity index 100% rename from jackpot.png rename to jeu/jackpot.png diff --git a/machine.png b/jeu/machine.png old mode 100644 new mode 100755 similarity index 100% rename from machine.png rename to jeu/machine.png diff --git a/master.css b/jeu/master.css old mode 100644 new mode 100755 similarity index 100% rename from master.css rename to jeu/master.css diff --git a/tirette.png b/jeu/tirette.png old mode 100644 new mode 100755 similarity index 100% rename from tirette.png rename to jeu/tirette.png diff --git a/login.php b/login.php deleted file mode 100644 index 3afd061..0000000 --- a/login.php +++ /dev/null @@ -1,20 +0,0 @@ -Erreur: Votre mot de passe n'est pas correct

- HTML;; - } - echo << -
- - -
-
- - -
- - - HTML; -?> diff --git a/login/cible_login.php b/login/cible_login.php new file mode 100755 index 0000000..6235114 --- /dev/null +++ b/login/cible_login.php @@ -0,0 +1,22 @@ +query("SELECT * FROM users where username='".$_POST['username']."'"); + while($line = $request->fetchArray()) { + if ($line["password"] == sha1($_POST["password"])) { + session_start(); + $_SESSION['username'] = $line['username']; + $_SESSION['password'] = $line['password']; + $_SESSION['compte'] = $line['compte']; + echo ''; + exit; + } + else { + echo ''; + exit; + } + } + echo ''; + +} + ?> diff --git a/login/cible_sign-up.php b/login/cible_sign-up.php new file mode 100755 index 0000000..87036fa --- /dev/null +++ b/login/cible_sign-up.php @@ -0,0 +1,25 @@ +query('SELECT * from users'); + + while($line = $request->fetchArray()) { + if ($line['username'] == $_POST["username"]) { + echo ''; + exit; + } + } + $append = $bdd->prepare("INSERT INTO users(username, password, compte) VALUES(:username, :password, :compte)"); + + $append->bindValue(':username', $_POST['username']); + $append->bindValue(':password', sha1($_POST['password'])); + $append->bindValue(':compte', 100); + + $append->execute(); + session_start(); + $_SESSION['username'] = $line['username']; + $_SESSION['password'] = $line['password']; + $_SESSION['compte'] = $line['compte']; + echo ''; +} + ?> diff --git a/login.css b/login/login.css old mode 100644 new mode 100755 similarity index 100% rename from login.css rename to login/login.css diff --git a/login/login.php b/login/login.php new file mode 100755 index 0000000..4e683c9 --- /dev/null +++ b/login/login.php @@ -0,0 +1,35 @@ +

Content de vous revoir !

+
+
+ + + Nom d'utilisateur incorrecte + HTML; } ?> +
+
+ + + Mot de passe incorrecte + HTML; } ?> +
+ +
+
+
+

Toujours pas de compte chez deuzagio ?

+
+
+ + + Nom d'utilisateur déjà pris + HTML; } ?> +
+
+ + +
+ +
diff --git a/login/users.db b/login/users.db new file mode 100644 index 0000000..e69de29 diff --git a/users.db b/users.db new file mode 100755 index 0000000..952002c Binary files /dev/null and b/users.db differ