diff --git a/ControllerAdmin.php b/ControllerAdmin.php index 0fe73e7..02a2f95 100644 --- a/ControllerAdmin.php +++ b/ControllerAdmin.php @@ -1,16 +1,15 @@ ajoutSource($_REQUEST["linkSource"]); break; @@ -20,8 +19,12 @@ class controllerAdmin { case "setNbArticlesParPage": $this->setNbArticlesParPage($_REQUEST["nbSourceParPage"]); break; - - } + default: + $gateway = new GatewayNews(new Connection($dsn,$user,$pass)); + $listeNews = $gateway->getNews(); + require('vues/listeNews.php'); + break; + } } catch (PDOException $e) { diff --git a/MdlAdmin.php b/MdlAdmin.php new file mode 100644 index 0000000..6ec6955 --- /dev/null +++ b/MdlAdmin.php @@ -0,0 +1,38 @@ +getCredential($login))){ + $_SESSION['role']='admin'; + $_SESSION['login']=$login; + return new Admin($login,$role); + } + else{ + return NULL; + } + } + + public function déconnexion(){ + session_unset(); + session_destroy(); + $_SESSION = array(); + } + + public function isAdmin(){ + if(isset $_SESSION['login'] && isset $_SESSION['role']) { + $login = Nettoyer::nettoyer_string($_SESSION['login']); + $role = Nettoyer::nettoyer_string($_SESSION['role']); + return new Admin($login,$role) + } + else{ + return null; + } + } +} \ No newline at end of file diff --git a/admins.php b/admins.php index cd375db..ca917f4 100644 --- a/admins.php +++ b/admins.php @@ -3,12 +3,12 @@ class Admin { private string $username; - private string $password; + private string $role; - public function __construct(string $username, string $password) + public function __construct(string $username, string $role) { $this->username = $username; - $this->password = $password; + $this->role = $role; } public function getUsername() @@ -16,9 +16,9 @@ class Admin return $this->username; } - public function getPassword() + public function getRole() { - return $this->password; + return $this->role; } } diff --git a/appel.php b/appel.php index 416678d..67dad7f 100644 --- a/appel.php +++ b/appel.php @@ -1,13 +1,4 @@ -w - addNews($n); } } -/* -$resultFlux = $parser->getResultFlux("https://www.lemonde.fr/sciences/rss_full.xml"); -foreach($resultFlux as $n){ - $gateNews->addNews($n); - echo $n->getTitle(); - echo "
"; - echo $n->getPubdate(); - echo "
"; - echo $n->getLink(); - echo "
"; - echo $n->getDescription(); - echo "
"; - echo "
"; -} -*/ ?> - - diff --git a/config.php b/config.php index 3e4baaf..4da4450 100644 --- a/config.php +++ b/config.php @@ -1,5 +1,5 @@ con->executeQuery($query, array()); + $query = "SELECT password FROM admin WHERE username = :login;"; + $this->con->executeQuery($query, array(':login' => array($login, PDO::PARAM_STR))); $results=$this->con->getResults(); - Foreach ($results as $admin){ - $listeAdmin[] = new Admin($admin["username"],$admin["password"]); - } - return $listeAdmin; + return $results[0]['password']; } } diff --git a/index.php b/index.php index bb76958..681083d 100644 --- a/index.php +++ b/index.php @@ -1,10 +1,13 @@ diff --git a/vues/listeNews.php b/vues/listeNews.php new file mode 100644 index 0000000..8e536ef --- /dev/null +++ b/vues/listeNews.php @@ -0,0 +1,16 @@ + + + getTitle(); + echo "
"; + echo $n->getPubdate(); + echo "
"; + echo $n->getLink(); + echo "
"; + echo $n->getDescription(); + echo "
"; + echo "
"; + } + ?> + \ No newline at end of file