From 1b54a9c27cd7b38c46eb18d3f6bd83fad1b53df8 Mon Sep 17 00:00:00 2001 From: "barraux.a" Date: Sat, 16 Apr 2022 21:26:42 +0200 Subject: [PATCH] =?UTF-8?q?Vite=20fait=20fini=20dis=20moi=20ce=20que=20t'e?= =?UTF-8?q?n=20pense=20(ps:=20vas=20sur=20login/login.php=20et=20cr=C3=A9e?= =?UTF-8?q?r=20toi=20un=20compte=20dans=20le=20deuxi=C3=A8me=20champ)=20?= =?UTF-8?q?=20;)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- casino.php | 80 --------------------------------- index.php | 31 ------------- app.js => jeu/app.js | 21 +++++---- jeu/change_compte.php | 13 ++++++ index.html => jeu/index.php | 8 +++- jackpot.png => jeu/jackpot.png | Bin machine.png => jeu/machine.png | Bin master.css => jeu/master.css | 0 tirette.png => jeu/tirette.png | Bin login.php | 20 --------- login/cible_login.php | 22 +++++++++ login/cible_sign-up.php | 25 +++++++++++ login.css => login/login.css | 0 login/login.php | 35 +++++++++++++++ login/users.db | 0 users.db | Bin 0 -> 16384 bytes 16 files changed, 115 insertions(+), 140 deletions(-) delete mode 100644 casino.php delete mode 100644 index.php rename app.js => jeu/app.js (94%) mode change 100644 => 100755 create mode 100644 jeu/change_compte.php rename index.html => jeu/index.php (93%) mode change 100644 => 100755 rename jackpot.png => jeu/jackpot.png (100%) mode change 100644 => 100755 rename machine.png => jeu/machine.png (100%) mode change 100644 => 100755 rename master.css => jeu/master.css (100%) mode change 100644 => 100755 rename tirette.png => jeu/tirette.png (100%) mode change 100644 => 100755 delete mode 100644 login.php create mode 100755 login/cible_login.php create mode 100755 login/cible_sign-up.php rename login.css => login/login.css (100%) mode change 100644 => 100755 create mode 100755 login/login.php create mode 100644 login/users.db create mode 100755 users.db 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 0000000000000000000000000000000000000000..952002cf67558d6edd49e1bc02184703fd2039f4 GIT binary patch literal 16384 zcmeI(%}&BF00;0EP&16q1F)mbP7sLU8;_zch6sprCK6*zWyP5Ay`hQmqF3L=*WfjL z3Ga4OLgc`SgCYNBZP(AWzgx5I;=KCc3fAtAy4+W|`mz18pf{Qz009U<00Izz00bZa0SG`~B?Z)XVlI7SpG%nW zH5S~^G>yJ(y8Nyq#*P>{eiAw|jk0Aht9)2BnC{oXvb0m?>HGT6(-I zbj32REU#w39p|Y(vS&4|es|!?9hhsAqi!X_iAHE$ zOD1X4UzRiM$fNtMBZgzqYl*pH@Xu1`8spyDQgUR%Kg9b