Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mathieu Loiseau
GameOfWords
Commits
715b8dd2
Commit
715b8dd2
authored
Apr 19, 2017
by
Mathieu Loiseau
Browse files
solve(?) infamous “jeroboam” bug→time as str in DB
parent
6e882915
Changes
12
Hide whitespace changes
Inline
Side-by-side
GoW.sql
View file @
715b8dd2
...
...
@@ -8,8 +8,6 @@
-- Version de PHP: 5.5.9-1ubuntu4.14
SET
SQL_MODE
=
"NO_AUTO_VALUE_ON_ZERO"
;
SET
time_zone
=
"+00:00"
;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */
;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */
;
...
...
@@ -30,7 +28,7 @@ CREATE TABLE IF NOT EXISTS `arbitrage` (
`arbitrageID`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`enregistrementID`
int
(
11
)
NOT
NULL
,
`idDruide`
int
(
11
)
NOT
NULL
,
`tpsArbitrage`
text
CHARACTER
SET
utf8
COLLATE
utf8_unicode_ci
NOT
NULL
,
`tpsArbitrage`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
`validation`
enum
(
'valid'
,
'invalid'
)
CHARACTER
SET
utf8
COLLATE
utf8_unicode_ci
NOT
NULL
,
PRIMARY
KEY
(
`arbitrageID`
),
KEY
`validation`
(
`validation`
),
...
...
@@ -117,7 +115,7 @@ CREATE TABLE IF NOT EXISTS `enregistrement` (
`idOracle`
int
(
30
)
NOT
NULL
,
`OracleLang`
text
CHARACTER
SET
utf8
COLLATE
utf8_unicode_ci
NOT
NULL
,
`nivpartie`
enum
(
'easy'
,
'medium'
,
'hard'
)
NOT
NULL
DEFAULT
'easy'
COMMENT
'niveau de la partie oracle'
,
`tpsEnregistrement`
text
CHARACTER
SET
utf8
COLLATE
utf8_unicode_ci
NOT
NULL
,
`tpsEnregistrement`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
`carteID`
int
(
11
)
NOT
NULL
,
`nivcarte`
text
CHARACTER
SET
utf8
COLLATE
utf8_unicode_ci
NOT
NULL
,
`validation`
enum
(
'valid'
,
'invalid'
,
'limbo'
)
CHARACTER
SET
utf8
COLLATE
utf8_unicode_ci
NOT
NULL
DEFAULT
'limbo'
,
...
...
@@ -178,7 +176,7 @@ CREATE TABLE IF NOT EXISTS `notif` (
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`state`
int
(
11
)
NOT
NULL
,
`game`
varchar
(
20
)
CHARACTER
SET
utf8
COLLATE
utf8_unicode_ci
NOT
NULL
,
`time`
text
CHARACTER
SET
utf8
COLLATE
utf8_unicode_ci
NOT
NULL
,
`time`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
AUTO_INCREMENT
=
1
;
...
...
@@ -191,9 +189,9 @@ CREATE TABLE IF NOT EXISTS `notif` (
CREATE
TABLE
IF
NOT
EXISTS
`parties`
(
`partieID`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`enregistrementID`
int
(
11
)
NOT
NULL
,
`tpsDevin`
text
CHARACTER
SET
utf8
COLLATE
utf8_unicode_ci
NOT
NULL
,
`tpsDevin`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
`idDevin`
int
(
11
)
NOT
NULL
,
`tpsdejeu`
text
CHARACTER
SET
utf8
COLLATE
utf8_unicode_ci
NO
T
NULL
,
`tpsdejeu`
datetime
NULL
DEFAUL
T
NULL
,
`reussie`
text
CHARACTER
SET
utf8
COLLATE
utf8_unicode_ci
NOT
NULL
,
PRIMARY
KEY
(
`partieID`
),
KEY
`enregistrementID`
(
`enregistrementID`
),
...
...
@@ -226,7 +224,7 @@ CREATE TABLE IF NOT EXISTS `score` (
`scoreDruide`
int
(
100
)
NOT
NULL
,
`scoreDevin`
int
(
100
)
NOT
NULL
,
`langue`
varchar
(
20
)
CHARACTER
SET
utf8
COLLATE
utf8_unicode_ci
NOT
NULL
,
`first_game_time`
text
NOT
NULL
,
`first_game_time`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
PRIMARY
KEY
(
`scoreID`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
AUTO_INCREMENT
=
1
;
...
...
@@ -264,10 +262,10 @@ CREATE TABLE IF NOT EXISTS `themes_cartes` (
CREATE
TABLE
IF
NOT
EXISTS
`user`
(
`userid`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`username`
varchar
(
32
)
NOT
NULL
,
`useremail`
varchar
(
100
)
CHARACTER
SET
latin1
COLLATE
latin1_general
_ci
NOT
NULL
,
`userpass`
varchar
(
32
)
CHARACTER
SET
latin1
COLLATE
latin1_general
_ci
NOT
NULL
,
`useremail`
varchar
(
100
)
CHARACTER
SET
utf8
COLLATE
utf8_unicode
_ci
NOT
NULL
,
`userpass`
varchar
(
32
)
CHARACTER
SET
utf8
COLLATE
utf8_unicode
_ci
NOT
NULL
,
`userlang`
varchar
(
32
)
NOT
NULL
,
`valkey`
varchar
(
100
)
CHARACTER
SET
latin1
COLLATE
latin1_general
_ci
NOT
NULL
,
`valkey`
varchar
(
100
)
CHARACTER
SET
utf8
COLLATE
utf8_unicode
_ci
NOT
NULL
,
`userlang_game`
varchar
(
100
)
NOT
NULL
,
`photo`
varchar
(
100
)
CHARACTER
SET
utf8
COLLATE
utf8_unicode_ci
NOT
NULL
,
`userlvl`
varchar
(
40
)
CHARACTER
SET
utf8
COLLATE
utf8_unicode_ci
NOT
NULL
,
...
...
@@ -299,7 +297,7 @@ INSERT INTO `user` (`userid`, `username`, `useremail`, `userpass`, `userlang`, `
INSERT
INTO
`user_niveau`
(
`id`
,
`userid`
,
`spoken_lang`
,
`niveau`
)
VALUES
(
1
,
1
,
'Français;'
,
'Natif;'
);
INSERT
INTO
`score`
(
`scoreID`
,
`userid`
,
`scoreGlobal`
,
`scoreOracle`
,
`scoreDruide`
,
`scoreDevin`
,
`langue`
,
`first_game_time`
)
VALUES
(
1
,
1
,
0
,
0
,
0
,
0
,
'Français'
,
''
);
(
1
,
1
,
0
,
0
,
0
,
0
,
'Français'
,
CURRENT_TIMESTAMP
);
-- --------------------------------------------------------
...
...
controllers/diviner.class.php
View file @
715b8dd2
...
...
@@ -31,7 +31,6 @@ class diviner_game
private
$adresse
=
''
;
private
$reussie
=
'en cours'
;
private
$temps
=
''
;
private
$mess
=
''
;
...
...
@@ -70,7 +69,6 @@ class diviner_game
else
{
$this
->
userlang
=
$this
->
user
->
langGame
;
}
$this
->
temps
=
date
(
"d/m/Y H:i:s"
);
unset
(
$_SESSION
[
"motDeviner"
]);
//permet de supprimer la sécurité qui empêche le joueur de s'ajouter des points à l'infini
unset
(
$_SESSION
[
"timeOutOracle"
]);
//permet de supprimer la sécurité qui empêche le joueur d'enlever des points à l'oracle à l'infini
...
...
@@ -143,9 +141,7 @@ class diviner_game
//On vérifie ici que l'enregistrement est bien sur le serveur
if
(
file_exists
(
$this
->
adresse
)){
//récupération du contenu de la carte
$carte
=
new
Card
(
$this
->
raisin
->
carteID
);
$this
->
card
=
$carte
;
$this
->
card
=
new
Card
(
$this
->
raisin
->
carteID
);
//Gestion du temps
$gh
=
new
GameHandler
();
$this
->
time
=
$gh
->
get_augur_time
(
$this
->
user
->
userlvl
,
$this
->
raisin
->
duration
);
...
...
@@ -194,7 +190,7 @@ class diviner_game
VALUES('
.
$db
->
escape
((
string
)
$this
->
raisin
->
enregistrementID
)
.
','
.
$db
->
escape
((
string
)
$this
->
diviner
)
.
','
.
$db
->
escape
((
string
)
$this
->
temps
)
.
'
,'
.
'CURRENT_TIMESTAMP
,'
.
$db
->
escape
((
string
)
$this
->
reussie
)
.
')'
;
$db
->
query
(
$sql
);
return
false
;
...
...
controllers/diviner.result.class.php
View file @
715b8dd2
...
...
@@ -48,7 +48,7 @@ class diviner_result
$lang_iso
=
new
IsoLang
();
//Récupération des infos nécessaires
$db
=
db
::
getInstance
();
$query
=
"SET @id_enr
:
=
null
;
$query
=
"SET @id_enr =
NULL
;
UPDATE `parties` SET `reussie`="
.
$db
->
escape
((
string
)
$this
->
reussie
)
.
", `enregistrementID` = (SELECT @id_enr := `enregistrementID`) WHERE idDevin='"
.
$this
->
devin
.
"' ORDER BY tpsDevin DESC LIMIT 1;
SELECT @id_enr;"
;
$db
->
multi_query_last_result
(
$query
);
...
...
controllers/druid.arbitrage.class.php
View file @
715b8dd2
...
...
@@ -22,8 +22,6 @@ class druid_arbitrage
private
$oracle
=
''
;
private
$enregistrement
=
''
;
private
$et_c_est_le_temps_qui_court
=
'd/m/Y H:i'
;
private
$valid
=
'valid'
;
private
$invalid
=
'invalid'
;
...
...
@@ -49,9 +47,6 @@ class druid_arbitrage
$this
->
druid
=
$this
->
user
->
id
;
$this
->
userlang
=
$this
->
user
->
langGame
;
//récupération des points en fonction du niveau de jeu
$this
->
et_c_est_le_temps_qui_court
=
date
(
"d/m/Y H:i"
);
return
true
;
}
//Revoir dans le cas où toutes les cartes ont été supprimés du serveur.
...
...
@@ -149,11 +144,10 @@ class druid_arbitrage
{
// Requête d'insertion des info dans la table 'arbitrage'
$sql
=
'INSERT INTO arbitrage
(enregistrementID,idDruide,
tpsArbitrage,
validation)
(enregistrementID,idDruide,validation)
VALUES('
.
$db
->
escape
((
string
)
$this
->
enregistrement
)
.
', '
.
$db
->
escape
((
string
)
$this
->
druid
)
.
', '
.
$db
->
escape
((
string
)
$this
->
et_c_est_le_temps_qui_court
)
.
', '
.
$db
->
escape
((
string
)
$this
->
invalid
)
.
')'
;
$db
->
query
(
$sql
);
...
...
@@ -175,11 +169,10 @@ class druid_arbitrage
}
elseif
(
isset
(
$_POST
[
'validate'
])){
// insertion des informations dans la table arbitrage
$sql
=
'INSERT INTO arbitrage
(enregistrementID,idDruide,
tpsArbitrage,
validation)
(enregistrementID,idDruide,validation)
VALUES('
.
$db
->
escape
((
string
)
$this
->
enregistrement
)
.
', '
.
$db
->
escape
((
string
)
$this
->
druid
)
.
', '
.
$db
->
escape
((
string
)
$this
->
et_c_est_le_temps_qui_court
)
.
', '
.
$db
->
escape
((
string
)
$this
->
valid
)
.
') '
;
$db
->
query
(
$sql
);
...
...
controllers/druid.card.class.php
View file @
715b8dd2
...
...
@@ -15,7 +15,6 @@ class druid_card
private
$userlang
=
''
;
private
$user
=
''
;
private
$createur
=
''
;
private
$et_c_est_le_temps_qui_court
=
''
;
private
$theme
=
''
;
private
$theme_carte
=
''
;
private
$errors
=
array
();
...
...
@@ -50,11 +49,6 @@ class druid_card
$this
->
userlang
=
$this
->
user
->
langGame
;
$this
->
createur
=
$this
->
user
->
id
;
//récupération de la date au format jour/mois/année/heure
$this
->
et_c_est_le_temps_qui_court
=
date
(
"d/m/Y H:i"
);
// récupération du formulaire de création de carte
$this
->
submit
=
isset
(
$_POST
[
'submit_form'
]);
if
(
$this
->
submit
)
...
...
controllers/notificationMessage.php
View file @
715b8dd2
...
...
@@ -12,8 +12,6 @@ class Notification
$this
->
user
=
user
::
getInstance
();
//connexion à la BD
$this
->
db
=
db
::
getInstance
();
$this
->
time
=
date
(
'Y-m-d H:i:s'
);
}
function
readNotif
()
...
...
@@ -44,13 +42,13 @@ class Notification
}
function
addNotif
(
$userid
,
$notification
,
$emetteur
){
$sql
=
"INSERT INTO `notif`(`userid`, `message`, `emetteur`
, `time`
) VALUES (
$userid
,"
.
$this
->
db
->
escape
(
$notification
)
.
",
$emetteur
,'"
.
$this
->
time
.
"
')"
;
$sql
=
"INSERT INTO `notif`(`userid`, `message`, `emetteur`) VALUES (
$userid
,"
.
$this
->
db
->
escape
(
$notification
)
.
",
'
$emetteur
')"
;
$result
=
$this
->
db
->
query
(
$sql
);
}
function
addNotifGAME
(
$userid
,
$notification
,
$role
){
//add an image to your notification…
$sql
=
"INSERT INTO `notif` (`userid`, `message`, `emetteur` ,`game`
, `time`
) VALUES (
$userid
,"
.
$this
->
db
->
escape
(
$notification
)
.
",0,'"
.
$role
.
"'
,'"
.
$this
->
time
.
"'
)"
;
$sql
=
"INSERT INTO `notif` (`userid`, `message`, `emetteur` ,`game`) VALUES (
$userid
,"
.
$this
->
db
->
escape
(
$notification
)
.
",0,'"
.
$role
.
"')"
;
$result
=
$this
->
db
->
query
(
$sql
);
}
...
...
controllers/oracle.card.alea.class.php
View file @
715b8dd2
...
...
@@ -62,9 +62,6 @@ class oracle_card_alea
$this
->
res
[
'tabou3'
]
=
isset
(
$_POST
[
'tabou3'
])
?
trim
(
$_POST
[
'tabou3'
])
:
''
;
$this
->
res
[
'tabou4'
]
=
isset
(
$_POST
[
'tabou4'
])
?
trim
(
$_POST
[
'tabou4'
])
:
''
;
$this
->
res
[
'tabou5'
]
=
isset
(
$_POST
[
'tabou5'
])
?
trim
(
$_POST
[
'tabou5'
])
:
''
;
$this
->
et_c_est_le_temps_qui_court
=
date
(
"d/m/Y H:i"
);
}
// initialisation du booléen de codiion finale d'acceptation de la génération
...
...
debug.php
View file @
715b8dd2
<?php
//user.class.php
//print_r($this->get_lang_lvl("es").($this->get_lang_lvl("sdfjlkkjls")===false ? "yippie" :"argh"));
/*include("./controllers/update_score_coeff.php");
$gh= new GameHandler();
echo $gh->get_mastery_mult("C1","Débutant");
require_once("./sys/load_iso.php");
$lang_iso = new IsoLang();
echo "<pre>".
$lang_iso->language_code_for("Espagnol")."→".$lang_iso->french_for("es")."\n".
$lang_iso->language_code_for("Avestique")."→".$lang_iso->french_for("ae")."\n".
$lang_iso->language_code_for("sdf,lmsgdlk,")."→".$lang_iso->french_for("sdee")."\n".
"</pre>";
print_r($lang_iso->get_all_codes());
*/
function
myLog
(
$txt
){
$fich
=
fopen
(
"./debug.html"
,
"a"
);
fwrite
(
$fich
,
"<p>"
.
$txt
.
"</p>"
);
fclose
(
$fich
);
}
function
myConsole
(
$xt
){
echo
"<script>console.log(
$this->query
);</script>"
;
}
function
logScores
(
$user
,
$language
=
false
,
$title
=
false
){
require_once
(
"./models/score.class.php"
);
if
(
$language
!==
false
){
...
...
@@ -37,17 +25,4 @@ function logScores($user, $language=false,$title=false){
fwrite
(
$fich
,
$score
);
fclose
(
$fich
);
}
/* fwrite($fich, "blabla".$fileName."\n".$ext);
fclose($fich);
require_once("./sys/db.class.php");
$db = db::getInstance();
$query = "SET @id_enr := null;
UPDATE `parties` SET `reussie`='non', `enregistrementID` = (SELECT @id_enr := `enregistrementID`) WHERE idDevin='4' ORDER BY tpsDevin DESC LIMIT 1;
SELECT @id_enr;";
$db->multi_query_last_result($query);
$record_id = $db->fetch_assoc()["@id_enr"];
//$record_id = $record_id["@id_enr"];
echo "<h1>$record_id</h1>";*/
//$score = array(true => "youpiii", false => "perduuuu");
//echo $score[true]."/".$score[false];
?>
devinLangue.php
View file @
715b8dd2
...
...
@@ -21,8 +21,6 @@
if
(
!
$resultat
->
num_rows
>
0
){
$score
=
0
;
//$time = date('Y-m-d H:i:s');
$sql
=
"INSERT INTO `score`(`userid`, `scoreGlobal`, `scoreOracle`, `scoreDruide`, `scoreDevin`, `langue`) VALUES (
$id
,
$score
,
$score
,
$score
,
$score
,'"
.
$lang_iso
->
french_for
(
$_SESSION
[
"langDevin"
])
.
"')"
;
$db
->
query
(
$sql
);
...
...
index.php
View file @
715b8dd2
...
...
@@ -28,7 +28,7 @@ $userlogged = $user->logged_in();
$modes
=
$mode
?
explode
(
'.'
,
$mode
)
:
array
();
// condition ? if :else
$modes
=
array_slice
(
$modes
,
0
,
1
);
$wmode
=
implode
(
'.'
,
$modes
);
// deux premiers param
�
tres de $mode
$wmode
=
implode
(
'.'
,
$modes
);
// deux premiers param
è
tres de $mode
// Traitement des modes
$html
=
false
;
...
...
@@ -91,7 +91,7 @@ switch ( $wmode )
default
:
$html
=
true
;
unset
(
$_SESSION
[
"CreateCard"
]);
//S
�
curit
�
pour
�
viter que l'utilisateur ne s'ajoute des points
�
l'infini lorsqu'il cr
��
une carte (refresh)
unset
(
$_SESSION
[
"CreateCard"
]);
//S
é
curit
é
pour
é
viter que l'utilisateur ne s'ajoute des points
à
l'infini lorsqu'il cr
éé
une carte (refresh)
include
(
'./views/page.home.html'
);
$mode
=
''
;
...
...
models/item.factory.class.php
View file @
715b8dd2
...
...
@@ -112,7 +112,7 @@ class ItemFactory //a quick and dirty class…
$res
=
false
;
break
;
}
//echo "$this->query<script>console.log($this->query);</script>";
return
true
;
}
...
...
save.php
View file @
715b8dd2
...
...
@@ -15,10 +15,6 @@ foreach(array('audio') as $type) {
}
}
//echo ($fileName);
$temps
=
date
(
"d/m/Y H:i"
);
// récupère dans un tableau de hachage le nom du fichier sans l'extension, l'extension et le chemin
$file
=
pathinfo
(
'./enregistrements/'
.
$fileName
);
...
...
@@ -65,11 +61,10 @@ foreach(array('audio') as $type) {
$duration
=
$mp3_file
->
getDuration
();
}
$sql
=
'INSERT INTO enregistrement
(`cheminEnregistrement`,`idOracle`,`OracleLang`,`
tpsEnregistrement`,`
carteID`,`nivcarte`,`duration`,`nivpartie`)
(`cheminEnregistrement`,`idOracle`,`OracleLang`,`carteID`,`nivcarte`,`duration`,`nivpartie`)
VALUES('
.
$db
->
escape
(
$fileName
)
.
','
.
$_GET
[
"userid"
]
.
','
.
$_GET
[
"gamelang"
]
.
','
.
$db
->
escape
(
$temps
)
.
','
.
$_GET
[
"cardid"
]
.
','
.
$_GET
[
"levelcard"
]
.
','
.
$duration
.
','
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment