Merge branch 'master' of https://codefirst.iut.uca.fr/git/nathan.boileau/Scripted
commit
239108ed3d
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="PublishConfigData" serverName="scripted">
|
||||||
|
<serverData>
|
||||||
|
<paths name="scripted">
|
||||||
|
<serverdata>
|
||||||
|
<mappings>
|
||||||
|
<mapping local="$PROJECT_DIR$" web="/WEB/src/Main.html" />
|
||||||
|
</mappings>
|
||||||
|
</serverdata>
|
||||||
|
</paths>
|
||||||
|
</serverData>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,7 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="SqlDialectInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="SqlNoDataSourceInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="PhpProjectSharedConfiguration" php_language_level="7.4">
|
<component name="PhpProjectSharedConfiguration" php_language_level="8.1">
|
||||||
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Validation
|
||||||
|
{
|
||||||
|
public function ValidateSet($var) :bool{
|
||||||
|
if (isset($var)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ValidateNotEmpty($var) :bool{
|
||||||
|
if (empty($var)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ValidateURL(string $url) :bool{
|
||||||
|
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$url)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ValidateEmail(string $email) :bool{
|
||||||
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require 'JoueurGateway.php';
|
||||||
|
|
||||||
|
class Controller
|
||||||
|
{
|
||||||
|
private Connection $con;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Connection $con
|
||||||
|
*/
|
||||||
|
function __construct(Connection $con) {
|
||||||
|
$this->con=$con;
|
||||||
|
session_start();
|
||||||
|
try{
|
||||||
|
$action=$_REQUEST['action'];
|
||||||
|
switch($action) {
|
||||||
|
case NULL:
|
||||||
|
//require ('../View/src/pages/Main.html');
|
||||||
|
header('Location: http://londres.uca.local/~nogarnier1/Scripted/WEB/View/src/pages/Main.html');
|
||||||
|
break;
|
||||||
|
case "login":
|
||||||
|
$this->login();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (PDOException $e)
|
||||||
|
{
|
||||||
|
//si erreur BD, pas le cas ici
|
||||||
|
$dataVueEreur[] = "Erreur inattendue!!! ";
|
||||||
|
//require(__DIR__.'/../vues/erreur.php'); // ajout du code de la vue ici
|
||||||
|
}
|
||||||
|
catch (Exception $e2)
|
||||||
|
{
|
||||||
|
$dataVueEreur[] = "Erreur inattendue!!! ";
|
||||||
|
//require ($rep.$vues['erreur']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function login() {
|
||||||
|
$gateway=new JoueurGateway($this->con);
|
||||||
|
$joueur=new Joueur($_REQUEST['email'], $_REQUEST['username'], $_REQUEST['password']);
|
||||||
|
$gateway->insert($joueur);
|
||||||
|
$gateway->showAll();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class DetailPartieGateway
|
||||||
|
{
|
||||||
|
private Connection $con;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Connection $con
|
||||||
|
*/
|
||||||
|
public function __construct(Connection $con)
|
||||||
|
{
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Connection $con
|
||||||
|
*/
|
||||||
|
public function setCon(Connection $con): void
|
||||||
|
{
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function insert(DetailPartie $detailPartie)
|
||||||
|
{
|
||||||
|
$query="INSERT INTO DetailPartie VALUES (:idDetailPartie,:joueur,:partie,:enigme,:pointsObtenus,:classement)";
|
||||||
|
$this->con->executeQuery($query,array(
|
||||||
|
'idDetailPartie' => array($detailPartie->getIdDetailPartie(),PDO::PARAM_STR),
|
||||||
|
'joueur' => array($detailPartie->getJoueur(),PDO::PARAM_STR),
|
||||||
|
'partie' => array($detailPartie->getPartie(),PDO::PARAM_STR),
|
||||||
|
'enigme' => array($detailPartie->getEnigme(),PDO::PARAM_STR),
|
||||||
|
'pointsObtenus' => array($detailPartie->getPointsObtenus(),PDO::PARAM_INT),
|
||||||
|
'classement' => array($detailPartie->getClassement(),PDO::PARAM_INT)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
public function delete(string $partie){
|
||||||
|
$query="DELETE * FROM DetailPartie WHERE partie=:partie";
|
||||||
|
$this->con->executeQuery($query,array(
|
||||||
|
'partie' => array($partie,PDO::PARAM_STR)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
public function showAll(){
|
||||||
|
$query="SELECT * FROM DetailPartie";
|
||||||
|
$this->con->executeQuery($query);
|
||||||
|
$results=$this->con->getResults();
|
||||||
|
foreach($results as $row)
|
||||||
|
{
|
||||||
|
$row['idDetailPartie'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
require_once "../Config/Connection.php";
|
||||||
|
require_once "../Model/Enigme.php";
|
||||||
|
|
||||||
|
class EnigmeGateway
|
||||||
|
{
|
||||||
|
private Connection $con;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Connection $con
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function __construct(Connection $con)
|
||||||
|
{
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Connection $con
|
||||||
|
*/
|
||||||
|
public function setCon(Connection $con): void
|
||||||
|
{
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function insert(Enigme $enigme)
|
||||||
|
{
|
||||||
|
$query = "INSERT INTO Enigme VALUES (:idEnigme,:admin,:enonce,:aide,:rappel,:solution,:test,:tempsDeResolution)";
|
||||||
|
$this->con->executeQuery($query, array(
|
||||||
|
':idEnigme' => array($enigme->getIdEnigme(), PDO::PARAM_STR),
|
||||||
|
':admin' => array($enigme->getAdmin(), PDO::PARAM_STR),
|
||||||
|
':enonce' => array($enigme->getEnonce(), PDO::PARAM_STR),
|
||||||
|
':aide' => array($enigme->getAide(), PDO::PARAM_STR),
|
||||||
|
':rappel' => array($enigme->getRappel(), PDO::PARAM_STR),
|
||||||
|
':solution' => array($enigme->getSolution(), PDO::PARAM_STR),
|
||||||
|
':test' => array($enigme->getTest(), PDO::PARAM_STR),
|
||||||
|
':tempsDeResolution' => array($enigme->getTempsDeResolution(), PDO::PARAM_INT)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(string $idEnigme)
|
||||||
|
{
|
||||||
|
$query= "DELETE FROM Enigme WHERE idEnigme=:idEnigme";
|
||||||
|
$this->con->executequery($query, array(
|
||||||
|
':idEnigme' => array($idEnigme,PDO::PARAM_STR)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findById(string $idEnigme)
|
||||||
|
{
|
||||||
|
$query="SELECT * FROM Enigme WHERE idEnigme =:idEnigme";
|
||||||
|
$this->con->executequery($query,array(
|
||||||
|
':idEnigme' => array($idEnigme,PDO::PARAM_STR)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showAll(): void
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM Enigme";
|
||||||
|
$this->con->executeQuery($query);
|
||||||
|
$results = $this->con->getResults();
|
||||||
|
foreach ($results as $row) {
|
||||||
|
echo $row['idEnigme'] . '</br>';
|
||||||
|
echo $row['admin'] . '</br>';
|
||||||
|
echo $row['enonce'] . '</br>';
|
||||||
|
echo $row['aide'] . '</br>';
|
||||||
|
echo $row['rappel'] . '</br>';
|
||||||
|
echo $row['solution'] . '</br>';
|
||||||
|
echo $row['test'] . '</br>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "../Model/Joueur.php";
|
||||||
|
require_once "../Config/Connection.php";
|
||||||
|
|
||||||
|
class JoueurGateway
|
||||||
|
{
|
||||||
|
private Connection $con;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Connection $con
|
||||||
|
*/
|
||||||
|
public function __construct(Connection $con){
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Connection $con
|
||||||
|
*/
|
||||||
|
public function setCon(Connection $con): void
|
||||||
|
{
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function insert(Joueur $joueur) : void{
|
||||||
|
$query = "INSERT INTO Joueur VALUE (:email,:pseudo,:mdp)";
|
||||||
|
$this->con->executeQuery($query, array(
|
||||||
|
':email' => array($joueur->getEmail(),PDO::PARAM_STR),
|
||||||
|
':pseudo' => array($joueur->getPseudo(),PDO::PARAM_STR),
|
||||||
|
':mdp' => array($joueur->getMdp(),PDO::PARAM_STR)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(string $email) : void{
|
||||||
|
$query = "DELETE FROM Joueur WHERE email=:email";
|
||||||
|
$this->con->executeQuery($query, array(
|
||||||
|
':email' => array($email,PDO::PARAM_STR)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showAll() : void{
|
||||||
|
$query = "SELECT * FROM Joueur";
|
||||||
|
$this->con->executeQuery($query);
|
||||||
|
$results=$this->con->getResults();
|
||||||
|
foreach ($results as $row) {
|
||||||
|
echo $row['email'] . '</br>';
|
||||||
|
echo $row['pseudo'] . '</br>';
|
||||||
|
echo $row['mdp'] . '</br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "../Model/Partie.php";
|
||||||
|
require_once "../Config/Connection.php";
|
||||||
|
|
||||||
|
class PartieGateway
|
||||||
|
{
|
||||||
|
private Connection $con;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Connection $con
|
||||||
|
*/
|
||||||
|
public function __construct(Connection $con)
|
||||||
|
{
|
||||||
|
$this->con = $con;
|
||||||
|
}
|
||||||
|
public function insert(Partie $partie){
|
||||||
|
$query= "INSERT INTO Game VALUES (:idPartie)";
|
||||||
|
$this->con->executeQuery($query, array(':idPartie' => array($partie->getIdPartie(), PDO::PARAM_STR)));
|
||||||
|
}
|
||||||
|
public function delete(string $idPartie){
|
||||||
|
$query= "DELETE FROM Game WHERE idGame = :idPartie";
|
||||||
|
$this->con->executeQuery($query, array(':idPartie' => array($idPartie, PDO::PARAM_STR)));
|
||||||
|
}
|
||||||
|
public function showAll() : void{
|
||||||
|
$query= "SELECT * FROM Partie";
|
||||||
|
$this->con->executeQuery($query);
|
||||||
|
$results=$this->con->getResults();
|
||||||
|
foreach ($results as $row) {
|
||||||
|
echo $row['idPartie'] . '</br>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
require 'Controller.php';
|
||||||
|
$dsn = 'mysql:host=londres.uca.local; dbname=dbnogarnier1';
|
||||||
|
$user = 'nogarnier1';
|
||||||
|
$password = 'achanger';
|
||||||
|
$con = new Connection($dsn, $user, $password);
|
||||||
|
$control = new Controller($con)
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
class Validation
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
<html>
|
|
||||||
<body>
|
|
||||||
<?php
|
|
||||||
class Connection extends PDO {
|
|
||||||
private $stmt;
|
|
||||||
public function __construct(string $dsn, string $username, string $password) {
|
|
||||||
parent::__construct($dsn,$username,$password);
|
|
||||||
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }
|
|
||||||
|
|
||||||
public function executeQuery(string $query, array $parameters = []) :bool {
|
|
||||||
$this->stmt = parent::prepare($query);
|
|
||||||
foreach ($parameters as $name => $value) {
|
|
||||||
$this->stmt->bindValue($name, $value[0], $value[1]); }
|
|
||||||
return $this->stmt->execute(); }
|
|
||||||
public function getResults(): array {
|
|
||||||
return $this->stmt->fetchall();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$email = $_POST['email'];
|
|
||||||
$nom = $_POST['username'];
|
|
||||||
$mdp = $_POST['password'];
|
|
||||||
|
|
||||||
$dsn = 'mysql:host=localhost;dbname=dbnogarnier1';
|
|
||||||
$user = 'nogarnier1';
|
|
||||||
$password = 'achanger';
|
|
||||||
|
|
||||||
$con=new Connection($dsn, $user, $password);
|
|
||||||
$query = "INSERT INTO Joueur VALUE (:email,:nom,:mdp)";
|
|
||||||
$con->executeQuery($query, array(
|
|
||||||
':email' => array($email,PDO::PARAM_STR),
|
|
||||||
':nom' => array($nom,PDO::PARAM_STR),
|
|
||||||
':mdp' => array($mdp,PDO::PARAM_STR)));
|
|
||||||
|
|
||||||
$db = new PDO($dsn, $user, $password);
|
|
||||||
$query= 'SELECT * FROM Joueur';
|
|
||||||
$stmt=$db->prepare($query);
|
|
||||||
$stmt->execute();
|
|
||||||
$results=$stmt->fetchall();
|
|
||||||
Foreach ($results as $row)
|
|
||||||
echo $row['email'].'</br>';
|
|
||||||
?>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Loading…
Reference in new issue