Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master'

PCYoshi 9 anni fa
parent
commit
3411fc1432

web/index.php → web/api/index.php Vedi File

@@ -1,15 +1,15 @@
1
-<?php
2
-
3
-require_once('model/classes.php');
4
-
5
-header("Content-Type:application/json");
6
-
7
-if(!empty($_GET['page'])) {
8
-  if($_GET['page'] == "palmares") {
9
-    include("view/palmares.php");
10
-    echo json_encode($scArray);
11
-  }
12
-} else {
13
-  include("view/questions.php");
14
-	echo json_encode($categories);
15
-}
1
+<?php
2
+
3
+require_once('model/classes.php');
4
+
5
+header("Content-Type:application/json");
6
+
7
+if(!empty($_GET['page'])) {
8
+  if($_GET['page'] == "palmares") {
9
+    include("view/palmares.php");
10
+    echo json_encode($scArray);
11
+  }
12
+} else {
13
+  include("view/questions.php");
14
+	echo json_encode($categories);
15
+}

web/model/class.categorie.php → web/api/model/class.categorie.php Vedi File

@@ -1,65 +1,70 @@
1
-<?php
2
-
3
-class Categorie {
4
-	private $bdd;
5
-	private $nomCat;
6
-	private $questsets;
7
-	
8
-	function __construct($nomCat) {
9
-		$this->bdd = new Connector();
10
-		$this->selectCat($nomCat);
11
-		$this->questsets = array();
12
-		$this->load();
13
-	}
14
-
15
-	private function selectCat($nomCat) {
16
-		$options = array(
17
-			"where" => array(
18
-				array("nom_cat", "=", $nomCat)
19
-			)
20
-		);
21
-
22
-		if(!is_null($this->bdd->Select('*', 'categorie', $options))) {
23
-			$this->nomCat = $nomCat;
24
-		} else {
25
-			throw new Exception('Catégorie introuvable');
26
-		}
27
-	}
28
-
29
-	private function load() {
30
-		$options = array(
31
-			"where" => array(
32
-				array("nom_cat", "=", $this->nomCat)
33
-			),
34
-			"order by" => array("rand()"),
35
-			"limit" => array("2")
36
-		);
37
-
38
-		$resp = $this->bdd->Select('*', 'reponses', $options);
39
-		foreach($resp as $questset) {
40
-			array_push($this->questsets, new Questset(array($questset['reponse1'], $questset['reponse2'])));
41
-		}
42
-	}
43
-
44
-	public static function randSelect() {
45
-		$bdd = new Connector();
46
-		$arrayCat = $bdd->Select("*", "categorie");
47
-		$return = array();
48
-		for($i = 0; $i < 2; $i++) {
49
-			$catIndex = rand(0, sizeof($arrayCat)-1);
50
-			array_push($return, new Categorie($arrayCat[$catIndex]['nom_cat']));
51
-		}
52
-		return $return;
53
-	}
54
-
55
-	public function getArray() {
56
-		$questsets = array();
57
-		foreach($this->questsets as $questset) {
58
-			array_push($questsets, $questset->getArray());
59
-		}
60
-		return array(
61
-			"nom_cat" => utf8_encode($this->nomCat),
62
-			"themes" => $questsets
63
-		);
64
-	}
65
-}
1
+<?php
2
+
3
+class Categorie {
4
+	private $bdd;
5
+	private $nomCat;
6
+	private $questsets;
7
+	
8
+	function __construct($nomCat) {
9
+		$this->bdd = new Connector();
10
+		$this->selectCat($nomCat);
11
+		$this->questsets = array();
12
+		$this->load();
13
+	}
14
+
15
+	private function selectCat($nomCat) {
16
+		$options = array(
17
+			"where" => array(
18
+				array("nom_cat", "=", $nomCat)
19
+			)
20
+		);
21
+
22
+		if(!is_null($this->bdd->Select('*', 'categorie', $options))) {
23
+			$this->nomCat = $nomCat;
24
+		} else {
25
+			throw new Exception('Catégorie introuvable');
26
+		}
27
+	}
28
+
29
+	private function load() {
30
+		$options = array(
31
+			"where" => array(
32
+				array("nom_cat", "=", $this->nomCat)
33
+			),
34
+			"order by" => array("rand()"),
35
+			"limit" => array("2")
36
+		);
37
+
38
+		$resp = $this->bdd->Select('*', 'reponses', $options);
39
+		foreach($resp as $questset) {
40
+			array_push($this->questsets, new Questset(array($questset['reponse1'], $questset['reponse2'])));
41
+		}
42
+	}
43
+
44
+	public static function randSelect() {
45
+		$bdd = new Connector();
46
+		$arrayCat = $bdd->Select("*", "categorie");
47
+		$return = array();
48
+		$catIndex = -1;
49
+		$previousIndex = -1;
50
+		for($i = 0; $i < 2; $i++) {
51
+			do {
52
+				$previousIndex = $catIndex;
53
+				$catIndex = rand(0, sizeof($arrayCat)-1);
54
+			} while($catIndex == $previousIndex);
55
+			array_push($return, new Categorie($arrayCat[$catIndex]['nom_cat']));
56
+		}
57
+		return $return;
58
+	}
59
+
60
+	public function getArray() {
61
+		$questsets = array();
62
+		foreach($this->questsets as $questset) {
63
+			array_push($questsets, $questset->getArray());
64
+		}
65
+		return array(
66
+			"nom_cat" => utf8_encode($this->nomCat),
67
+			"themes" => $questsets
68
+		);
69
+	}
70
+}

web/model/class.connector.php → web/api/model/class.connector.php Vedi File

@@ -1,120 +1,120 @@
1
-<?php
2
-
3
-class Connector {
4
-
5
-	private $bdd;
6
-
7
-	function __construct() {
8
-		$host = "localhost";
9
-		$db = "burgerquizz";
10
-		$user = "alain";
11
-		$pass = "chabat";
12
-
13
-		$this->bdd = new PDO("mysql:host=$host;dbname=$db", $user, $pass);
14
-		$this->bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
15
-	}
16
-
17
-	/*
18
-		Exemple de $options :
19
-
20
-		$options = array(
21
-			"where" => array(
22
-				array("foo", "=", "bar"),
23
-				array("blbl", ">", 5)
24
-			),
25
-			"order by" => array("foo", "desc"),
26
-			"limit" => array(0, 10) // Ou array(10)
27
-		);
28
-	*/
29
-	function Select($fields, $tables, $options = array()) {
30
-		$request = "SELECT $fields FROM $tables ";
31
-		$arrayVerif = array();
32
-		foreach($options as $name=>$value) {
33
-			if(($upName = strtoupper($name)) == "WHERE") {
34
-				$whereClause = " $upName ";
35
-				foreach($value as $array) {
36
-					if(sizeof($array) != 3) {
37
-						throw new Exception('Nombre de paramètres incorrect (WHERE). Les paramètres passés sont : '
38
-							.implode(',',$array));
39
-					}
40
-
41
-					$whereClause .= $array[0]." ".$array[1]." :".$array[0]." AND ";
42
-					$arrayVerif[":".$array[0]] = $array[2];
43
-				}
44
-				$request .= substr($whereClause, 0, -5);
45
-			} else if(($upName = strtoupper($name)) == "ORDER BY") {
46
-				if(sizeof($value) != 2 && substr($value[0], -2) != "()") {
47
-					throw new Exception('Nombre de paramètres incorrects (ORDER BY). Les paramètres passés sont : '
48
-						.implode(',', $value));
49
-				}
50
-
51
-				$request .= " ".$upName." ".implode(' ', $value);
52
-			} else if(($upName = strtoupper($name)) == "LIMIT") {
53
-				if(sizeof($value) == 1) {
54
-					// La colonne "limit" ne contient qu'un nombre de champs
55
-					$request .= " $upName ".$value[0];
56
-				} else if(sizeof($value) == 2) {
57
-					// La colonne "limit" contient un index de départ et un nombre de champs
58
-					$request .= " $upName ".$value[0].",".$value[1];
59
-				} else {
60
-					throw new Exception('Nombre de paramètres incorrects (LIMIT). Les paramètres passés sont : '
61
-						.implode(',', $value));
62
-				}
63
-			} else {
64
-				throw new Exception('Argument '.strtoupper($name).' inconnu');
65
-			}
66
-		}
67
-
68
-		$stmt = $this->bdd->prepare($request);
69
-
70
-		if($stmt->execute($arrayVerif)) {
71
-			return $stmt->fetchAll();
72
-		} else {
73
-			return null;
74
-		}
75
-	}
76
-
77
-	function Insert($table, $values) {
78
-		$request = "INSERT INTO $table(";
79
-		$valeurs = "VALUES(";
80
-		$arrayVerif = array();
81
-		foreach($values as $name=>$value) {
82
-			$request .= $name.",";
83
-			$valeurs .= "?,";
84
-				array_push($arrayVerif, $value);
85
-		}
86
-
87
-		$request = substr($request, 0, -1).") ".substr($valeurs, 0, -1).")";
88
-
89
-		$stmt = $this->bdd->prepare($request);
90
-
91
-		$stmt->execute($arrayVerif);
92
-	}
93
-
94
-	function Update($table, $update) {
95
-		$request = "UPDATE $table SET ";
96
-		$arrayVerif = array();
97
-		foreach($update['set'] as $name=>$value) {
98
-			$request .= $name."=?,";
99
-			array_push($arrayVerif, $value);
100
-		}
101
-		$request = substr($request, 0, -1)." WHERE ";
102
-		var_dump($request);
103
-		foreach($update['where'] as $value) {
104
-			$request .= $value[0].$value[1]."? AND ";
105
-			array_push($arrayVerif, $value[2]);			
106
-		}
107
-		$request = substr($request, 0, -5);
108
-
109
-		$stmt = $this->bdd->prepare($request);
110
-		$stmt->execute($arrayVerif);
111
-	}
112
-
113
-	function beginTransaction() {
114
-		$this->bdd->beginTransaction();
115
-	}
116
-
117
-	function commit() {
118
-		$this->bdd->commit();
119
-	}
120
-}
1
+<?php
2
+
3
+class Connector {
4
+
5
+	private $bdd;
6
+
7
+	function __construct() {
8
+		$host = "localhost";
9
+		$db = "burgerquizz";
10
+		$user = "alain";
11
+		$pass = "chabat";
12
+
13
+		$this->bdd = new PDO("mysql:host=$host;dbname=$db", $user, $pass);
14
+		$this->bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
15
+	}
16
+
17
+	/*
18
+		Exemple de $options :
19
+
20
+		$options = array(
21
+			"where" => array(
22
+				array("foo", "=", "bar"),
23
+				array("blbl", ">", 5)
24
+			),
25
+			"order by" => array("foo", "desc"),
26
+			"limit" => array(0, 10) // Ou array(10)
27
+		);
28
+	*/
29
+	function Select($fields, $tables, $options = array()) {
30
+		$request = "SELECT $fields FROM $tables ";
31
+		$arrayVerif = array();
32
+		foreach($options as $name=>$value) {
33
+			if(($upName = strtoupper($name)) == "WHERE") {
34
+				$whereClause = " $upName ";
35
+				foreach($value as $array) {
36
+					if(sizeof($array) != 3) {
37
+						throw new Exception('Nombre de paramètres incorrect (WHERE). Les paramètres passés sont : '
38
+							.implode(',',$array));
39
+					}
40
+
41
+					$whereClause .= $array[0]." ".$array[1]." :".$array[0]." AND ";
42
+					$arrayVerif[":".$array[0]] = $array[2];
43
+				}
44
+				$request .= substr($whereClause, 0, -5);
45
+			} else if(($upName = strtoupper($name)) == "ORDER BY") {
46
+				if(sizeof($value) != 2 && substr($value[0], -2) != "()") {
47
+					throw new Exception('Nombre de paramètres incorrects (ORDER BY). Les paramètres passés sont : '
48
+						.implode(',', $value));
49
+				}
50
+
51
+				$request .= " ".$upName." ".implode(' ', $value);
52
+			} else if(($upName = strtoupper($name)) == "LIMIT") {
53
+				if(sizeof($value) == 1) {
54
+					// La colonne "limit" ne contient qu'un nombre de champs
55
+					$request .= " $upName ".$value[0];
56
+				} else if(sizeof($value) == 2) {
57
+					// La colonne "limit" contient un index de départ et un nombre de champs
58
+					$request .= " $upName ".$value[0].",".$value[1];
59
+				} else {
60
+					throw new Exception('Nombre de paramètres incorrects (LIMIT). Les paramètres passés sont : '
61
+						.implode(',', $value));
62
+				}
63
+			} else {
64
+				throw new Exception('Argument '.strtoupper($name).' inconnu');
65
+			}
66
+		}
67
+
68
+		$stmt = $this->bdd->prepare($request);
69
+
70
+		if($stmt->execute($arrayVerif)) {
71
+			return $stmt->fetchAll();
72
+		} else {
73
+			return null;
74
+		}
75
+	}
76
+
77
+	function Insert($table, $values) {
78
+		$request = "INSERT INTO $table(";
79
+		$valeurs = "VALUES(";
80
+		$arrayVerif = array();
81
+		foreach($values as $name=>$value) {
82
+			$request .= $name.",";
83
+			$valeurs .= "?,";
84
+				array_push($arrayVerif, $value);
85
+		}
86
+
87
+		$request = substr($request, 0, -1).") ".substr($valeurs, 0, -1).")";
88
+
89
+		$stmt = $this->bdd->prepare($request);
90
+
91
+		$stmt->execute($arrayVerif);
92
+	}
93
+
94
+	function Update($table, $update) {
95
+		$request = "UPDATE $table SET ";
96
+		$arrayVerif = array();
97
+		foreach($update['set'] as $name=>$value) {
98
+			$request .= $name."=?,";
99
+			array_push($arrayVerif, $value);
100
+		}
101
+		$request = substr($request, 0, -1)." WHERE ";
102
+		var_dump($request);
103
+		foreach($update['where'] as $value) {
104
+			$request .= $value[0].$value[1]."? AND ";
105
+			array_push($arrayVerif, $value[2]);			
106
+		}
107
+		$request = substr($request, 0, -5);
108
+
109
+		$stmt = $this->bdd->prepare($request);
110
+		$stmt->execute($arrayVerif);
111
+	}
112
+
113
+	function beginTransaction() {
114
+		$this->bdd->beginTransaction();
115
+	}
116
+
117
+	function commit() {
118
+		$this->bdd->commit();
119
+	}
120
+}

web/model/class.question.php → web/api/model/class.question.php Vedi File

@@ -1,52 +1,52 @@
1
-<?php
2
-
3
-class Question {
4
-	private $reponse1;
5
-	private $reponse2;
6
-	private $intitule;
7
-	private $bonneReponse;
8
-
9
-	function __construct($intitule) {
10
-		try{
11
-			$this->intitule = $intitule;
12
-
13
-			$bdd = new Connector();
14
-
15
-			$options = array(
16
-				"where" => array(
17
-					array("intitule", "=", $intitule)
18
-				)
19
-			);
20
-			$question = $bdd->Select('*', 'questions', $options);
21
-
22
-			$this->reponse1 = $question[0]['reponse1'];
23
-			$this->reponse2 = $question[0]['reponse2'];
24
-			
25
-			$this->bonneReponse = $question[0]['num_reponse'];
26
-		} catch(Exception $e) {
27
-			throw $e;
28
-		}
29
-	}
30
-
31
-	function getIntitule() {
32
-		return $this->intitule;
33
-	}
34
-
35
-	function getReponses() {
36
-		return array(
37
-			"reponse1" => $this->reponse1,
38
-			"reponse2" => $this->reponse2
39
-		);
40
-	}
41
-
42
-	function getBonneReponse() {
43
-		return $this->bonneReponse;
44
-	}
45
-
46
-	function getArray() {
47
-		return array(
48
-			"intitule" => utf8_encode($this->intitule),
49
-			"bonneReponse" => utf8_encode($this->bonneReponse)
50
-		);
51
-	}
52
-}
1
+<?php
2
+
3
+class Question {
4
+	private $reponse1;
5
+	private $reponse2;
6
+	private $intitule;
7
+	private $bonneReponse;
8
+
9
+	function __construct($intitule) {
10
+		try{
11
+			$this->intitule = $intitule;
12
+
13
+			$bdd = new Connector();
14
+
15
+			$options = array(
16
+				"where" => array(
17
+					array("intitule", "=", $intitule)
18
+				)
19
+			);
20
+			$question = $bdd->Select('*', 'questions', $options);
21
+
22
+			$this->reponse1 = $question[0]['reponse1'];
23
+			$this->reponse2 = $question[0]['reponse2'];
24
+			
25
+			$this->bonneReponse = $question[0]['num_reponse'];
26
+		} catch(Exception $e) {
27
+			throw $e;
28
+		}
29
+	}
30
+
31
+	function getIntitule() {
32
+		return $this->intitule;
33
+	}
34
+
35
+	function getReponses() {
36
+		return array(
37
+			"reponse1" => $this->reponse1,
38
+			"reponse2" => $this->reponse2
39
+		);
40
+	}
41
+
42
+	function getBonneReponse() {
43
+		return $this->bonneReponse;
44
+	}
45
+
46
+	function getArray() {
47
+		return array(
48
+			"intitule" => utf8_encode($this->intitule),
49
+			"bonneReponse" => utf8_encode($this->bonneReponse)
50
+		);
51
+	}
52
+}

web/model/class.questset.php → web/api/model/class.questset.php Vedi File

@@ -1,57 +1,57 @@
1
-<?php
2
-
3
-class Questset {
4
-	private $reponse1;
5
-	private $reponse2;
6
-	private $questions;
7
-
8
-	function __construct($reponses) {
9
-		if(is_array($reponses)) {
10
-			$this->questions = array();
11
-			$this->reponse1 = $reponses[0];
12
-			$this->reponse2 = $reponses[1];
13
-			try {
14
-				$bdd = new Connector();
15
-
16
-				$options = array(
17
-					"where" => array(
18
-						array("reponse1", "=", $this->reponse1),
19
-						array("reponse2", "=", $this->reponse2)
20
-					)
21
-				);
22
-
23
-				$questions = $bdd->Select('*', 'questions', $options);
24
-
25
-				foreach($questions as $question) {
26
-					array_push($this->questions, new Question($question['intitule']));
27
-				}
28
-
29
-			} catch(Exception $e) {
30
-				throw $e;
31
-			}
32
-		} else {
33
-			throw new Exception('Un tableau de réponses est attendu dans le constructeur.');
34
-		}
35
-	}
36
-
37
-	function getQuestions() {
38
-		return $this->questions;
39
-	}
40
-
41
-	function getLength() {
42
-		return sizeof($this->questions);
43
-	}
44
-
45
-	function getArray() {
46
-		$questions = array();
47
-		foreach($this->questions as $question) {
48
-			array_push($questions, $question->getArray());
49
-		}
50
-
51
-		return array(
52
-			"reponse1" => utf8_encode($this->reponse1),
53
-			"reponse2" => utf8_encode($this->reponse2),
54
-			"questions" => $questions
55
-		);
56
-	}
57
-}
1
+<?php
2
+
3
+class Questset {
4
+	private $reponse1;
5
+	private $reponse2;
6
+	private $questions;
7
+
8
+	function __construct($reponses) {
9
+		if(is_array($reponses)) {
10
+			$this->questions = array();
11
+			$this->reponse1 = $reponses[0];
12
+			$this->reponse2 = $reponses[1];
13
+			try {
14
+				$bdd = new Connector();
15
+
16
+				$options = array(
17
+					"where" => array(
18
+						array("reponse1", "=", $this->reponse1),
19
+						array("reponse2", "=", $this->reponse2)
20
+					)
21
+				);
22
+
23
+				$questions = $bdd->Select('*', 'questions', $options);
24
+
25
+				foreach($questions as $question) {
26
+					array_push($this->questions, new Question($question['intitule']));
27
+				}
28
+
29
+			} catch(Exception $e) {
30
+				throw $e;
31
+			}
32
+		} else {
33
+			throw new Exception('Un tableau de réponses est attendu dans le constructeur.');
34
+		}
35
+	}
36
+
37
+	function getQuestions() {
38
+		return $this->questions;
39
+	}
40
+
41
+	function getLength() {
42
+		return sizeof($this->questions);
43
+	}
44
+
45
+	function getArray() {
46
+		$questions = array();
47
+		foreach($this->questions as $question) {
48
+			array_push($questions, $question->getArray());
49
+		}
50
+
51
+		return array(
52
+			"reponse1" => utf8_encode($this->reponse1),
53
+			"reponse2" => utf8_encode($this->reponse2),
54
+			"questions" => $questions
55
+		);
56
+	}
57
+}

web/model/class.score.php → web/api/model/class.score.php Vedi File

@@ -1,75 +1,75 @@
1
-<?php
2
-
3
-class Score {
4
-  private $login;
5
-  private $score;
6
-  private $bdd;
7
-
8
-  function __construct($login) {
9
-    $this->bdd = new Connector();
10
-
11
-    $options = array(
12
-      "where" => array(
13
-        array("login", "=", $login)
14
-      )
15
-    );
16
-
17
-    $data = $this->bdd->Select("*", "scores", $options);
18
-    $this->login = $data[0]['login'];
19
-    $this->score = $data[0]['score'];
20
-  }
21
-
22
-  function getLogin() {
23
-    return $this->login;
24
-  }
25
-
26
-  function getScore() {
27
-    return $this->score;
28
-  }
29
-
30
-  public static function getScores($nRows, $direction = "desc") {
31
-    $bdd = new Connector();
32
-
33
-    $options = array(
34
-      "order by" => array("score", $direction),
35
-      "limit" => array($nRows)
36
-    );
37
-
38
-    $array = $bdd->Select("*", "scores", $options);
39
-    $scores = array();
40
-    foreach($array as $score) {
41
-      array_push($scores, new Score($score['login']));
42
-    }
43
-
44
-    return $scores;
45
-  }
46
-
47
-  public static function add($login, $score) {
48
-    $bdd = new Connector();
49
-
50
-    $options = array(
51
-      "where" => array(
52
-        array("login", "=", $login)
53
-      )
54
-    );
55
-
56
-    if(!$scores = $bdd->Select("*", "scores", $options)) {
57
-      $values = array(
58
-        "login" => $login,
59
-        "score" => $score
60
-      );
61
-
62
-      $bdd->Insert("scores", $values);
63
-    } else {
64
-      if($score > $scores[0]['score']) {
65
-        $update = array(
66
-          "where" => array(
67
-            array("login", "=", $login)
68
-          ),
69
-          "set" => array("score" => $score)
70
-        );
71
-        $bdd->Update("scores", $update);
72
-      }
73
-    }
74
-  }
75
-}
1
+<?php
2
+
3
+class Score {
4
+  private $login;
5
+  private $score;
6
+  private $bdd;
7
+
8
+  function __construct($login) {
9
+    $this->bdd = new Connector();
10
+
11
+    $options = array(
12
+      "where" => array(
13
+        array("login", "=", $login)
14
+      )
15
+    );
16
+
17
+    $data = $this->bdd->Select("*", "scores", $options);
18
+    $this->login = $data[0]['login'];
19
+    $this->score = $data[0]['score'];
20
+  }
21
+
22
+  function getLogin() {
23
+    return $this->login;
24
+  }
25
+
26
+  function getScore() {
27
+    return $this->score;
28
+  }
29
+
30
+  public static function getScores($nRows, $direction = "desc") {
31
+    $bdd = new Connector();
32
+
33
+    $options = array(
34
+      "order by" => array("score", $direction),
35
+      "limit" => array($nRows)
36
+    );
37
+
38
+    $array = $bdd->Select("*", "scores", $options);
39
+    $scores = array();
40
+    foreach($array as $score) {
41
+      array_push($scores, new Score($score['login']));
42
+    }
43
+
44
+    return $scores;
45
+  }
46
+
47
+  public static function add($login, $score) {
48
+    $bdd = new Connector();
49
+
50
+    $options = array(
51
+      "where" => array(
52
+        array("login", "=", $login)
53
+      )
54
+    );
55
+
56
+    if(!$scores = $bdd->Select("*", "scores", $options)) {
57
+      $values = array(
58
+        "login" => $login,
59
+        "score" => $score
60
+      );
61
+
62
+      $bdd->Insert("scores", $values);
63
+    } else {
64
+      if($score > $scores[0]['score']) {
65
+        $update = array(
66
+          "where" => array(
67
+            array("login", "=", $login)
68
+          ),
69
+          "set" => array("score" => $score)
70
+        );
71
+        $bdd->Update("scores", $update);
72
+      }
73
+    }
74
+  }
75
+}

web/model/classes.php → web/api/model/classes.php Vedi File

@@ -1,8 +1,8 @@
1
-<?php
2
-
3
-// Call this file from the root folder
4
-require_once('model/class.connector.php');
5
-require_once('model/class.question.php');
6
-require_once('model/class.questset.php');
7
-require_once('model/class.categorie.php');
8
-require_once('model/class.score.php');
1
+<?php
2
+
3
+// Call this file from the root folder
4
+require_once('model/class.connector.php');
5
+require_once('model/class.question.php');
6
+require_once('model/class.questset.php');
7
+require_once('model/class.categorie.php');
8
+require_once('model/class.score.php');

web/tests.php → web/api/tests.php Vedi File

@@ -1,9 +1,9 @@
1
-<?php
2
-
3
-require_once('model/classes.php');
4
-
5
-try {
6
-	Score::add("Yolo", 200);
7
-}catch(Exception $e) {
8
-	echo("Erreur : ".$e->getMessage());
9
-}
1
+<?php
2
+
3
+require_once('model/classes.php');
4
+
5
+try {
6
+	Score::add("Yolo", 200);
7
+}catch(Exception $e) {
8
+	echo("Erreur : ".$e->getMessage());
9
+}

web/view/palmares.php → web/api/view/palmares.php Vedi File

@@ -1,14 +1,14 @@
1
-<?php
2
-
3
-try {
4
-	$scores = Score::getScores(10);
5
-	$scArray = array();
6
-	for($i = 0; $i < sizeof($scores); $i++) {
7
-		array_push($scArray, array(
8
-			"login" => utf8_encode($scores[$i]->getLogin()),
9
-			"score" => $scores[$i]->getScore()
10
-		));
11
-	}
12
-}catch(Exception $e) {
13
-	echo json_encode(array("erreur" => $e->getMessage()));
14
-}
1
+<?php
2
+
3
+try {
4
+	$scores = Score::getScores(10);
5
+	$scArray = array();
6
+	for($i = 0; $i < sizeof($scores); $i++) {
7
+		array_push($scArray, array(
8
+			"login" => utf8_encode($scores[$i]->getLogin()),
9
+			"score" => $scores[$i]->getScore()
10
+		));
11
+	}
12
+}catch(Exception $e) {
13
+	echo json_encode(array("erreur" => $e->getMessage()));
14
+}

+ 7
- 0
web/api/view/questions.php Vedi File

@@ -0,0 +1,7 @@
1
+<?php
2
+
3
+$categoriesObj = Categorie::randSelect();
4
+$categories = array();
5
+foreach($categoriesObj as $categorie) {
6
+	array_push($categories, $categorie->getArray());
7
+}

+ 0
- 16
web/view/questions.php Vedi File

@@ -1,16 +0,0 @@
1
-<?php
2
-
3
-// Fichier de tests du modèle
4
-
5
-require_once('model/classes.php');
6
-header("Content-Type:application/json");
7
-
8
-try{
9
-	$categoriesObj = Categorie::randSelect();
10
-	$categories = array();
11
-	foreach($categoriesObj as $categorie) {
12
-		array_push($categories, $categorie->getArray());
13
-	}
14
-}catch(Exception $e) {
15
-	echo json_encode(array("erreur" => $e->getMessage()));
16
-}