Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class UserController extends MainController
- {
- protected $name = 'user';
- //////////////////////////////////////////////////////////////
- /// View == Déconnexion du membre ///
- //////////////////////////////////////////////////////////////
- public function deconnexionAction()
- {
- SessionManager::getInstance()->destroy();
- header('location:../public');
- }
- //////////////////////////////////////////////////////////////
- /// View == Inscription, Insertion des données dans la BDD ///
- //////////////////////////////////////////////////////////////
- public function inscriptionAction()
- {
- $this->setView('inscription');
- if (false !== Tools::getParam('email')) {
- if ('' !== Tools::getParam('password')) {
- $user = new User();
- $user->setUsername(Tools::getParam('username'));
- $user->setPassword(Tools::getParam('password'));
- $user->setEmail(Tools::getParam('email'));
- $user->save();
- }
- }
- $this->view->render();
- }
- //////////////////////////////////////////////////////////////
- /// View == Connexion ///
- //////////////////////////////////////////////////////////////
- public function connexionAction()
- {
- $this->setView('connexion');
- if (false !== Tools::getParam('email')) {
- if ('' !== Tools::getParam('password')) {
- // Déclaration/Initialisation
- $user = new User();
- $email = Tools::getParam('email');
- $password = Tools::getParam('password');
- $verif_email = $user->getUser($email);
- $result_verif = $verif_email[0]['password'];
- //Mes vérifications pour la connection
- if($verif_email != FALSE && $result_verif == $password){
- //La session est deja instancier, j'attribue des nom à mes sessions.
- SessionManager::getInstance()->set('email',$verif_email[0]['email']);
- SessionManager::getInstance()->set('id_membre',$verif_email[0]['user_id']);
- header('location:../public');
- }else{
- echo "Email ou Password incorrect.";
- }
- }
- }
- $this->view ->render();
- }
- //////////////////////////////////////////////////////////////
- /// View == Configuration ///
- //////////////////////////////////////////////////////////////
- public function configurationAction()
- {
- $this->setView('configuration');
- $this->view->assign(array('videos' => Video::getVideo_user(SessionManager::getInstance()->get('id_membre'))));
- $this->view ->render();
- }
- //////////////////////////////////////////////////////////////
- /// View == Display Video ///
- //////////////////////////////////////////////////////////////
- public function display_videoAction()
- {
- $this->setView('display_video');
- $video = new Video();
- if (false === $video->getByShort(Tools::getParam('video'))) {
- Tools::fourOFour();
- }
- $video->updateViews();
- $this->view->assign(array('video' => $video));
- $this->view->render();
- }
- }
- ?>
Add Comment
Please, Sign In to add comment