Guest User

Untitled

a guest
Feb 25th, 2016
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. class UserController extends MainController
  6. {
  7. protected $name = 'user';
  8.  
  9.  
  10.  
  11. //////////////////////////////////////////////////////////////
  12. /// View == Déconnexion du membre ///
  13. //////////////////////////////////////////////////////////////
  14.  
  15. public function deconnexionAction()
  16.  
  17. {
  18. SessionManager::getInstance()->destroy();
  19. header('location:../public');
  20.  
  21. }
  22.  
  23.  
  24. //////////////////////////////////////////////////////////////
  25. /// View == Inscription, Insertion des données dans la BDD ///
  26. //////////////////////////////////////////////////////////////
  27.  
  28. public function inscriptionAction()
  29.  
  30. {
  31. $this->setView('inscription');
  32.  
  33. if (false !== Tools::getParam('email')) {
  34. if ('' !== Tools::getParam('password')) {
  35. $user = new User();
  36. $user->setUsername(Tools::getParam('username'));
  37. $user->setPassword(Tools::getParam('password'));
  38. $user->setEmail(Tools::getParam('email'));
  39. $user->save();
  40. }
  41. }
  42.  
  43. $this->view->render();
  44.  
  45. }
  46.  
  47. //////////////////////////////////////////////////////////////
  48. /// View == Connexion ///
  49. //////////////////////////////////////////////////////////////
  50.  
  51. public function connexionAction()
  52.  
  53. {
  54. $this->setView('connexion');
  55. if (false !== Tools::getParam('email')) {
  56. if ('' !== Tools::getParam('password')) {
  57.  
  58. // Déclaration/Initialisation
  59.  
  60.  
  61. $user = new User();
  62. $email = Tools::getParam('email');
  63. $password = Tools::getParam('password');
  64. $verif_email = $user->getUser($email);
  65. $result_verif = $verif_email[0]['password'];
  66.  
  67. //Mes vérifications pour la connection
  68.  
  69. if($verif_email != FALSE && $result_verif == $password){
  70.  
  71. //La session est deja instancier, j'attribue des nom à mes sessions.
  72.  
  73. SessionManager::getInstance()->set('email',$verif_email[0]['email']);
  74. SessionManager::getInstance()->set('id_membre',$verif_email[0]['user_id']);
  75.  
  76. header('location:../public');
  77. }else{
  78. echo "Email ou Password incorrect.";
  79. }
  80.  
  81.  
  82. }
  83. }
  84.  
  85. $this->view ->render();
  86.  
  87. }
  88.  
  89. //////////////////////////////////////////////////////////////
  90. /// View == Configuration ///
  91. //////////////////////////////////////////////////////////////
  92.  
  93. public function configurationAction()
  94.  
  95. {
  96. $this->setView('configuration');
  97. $this->view->assign(array('videos' => Video::getVideo_user(SessionManager::getInstance()->get('id_membre'))));
  98. $this->view ->render();
  99.  
  100. }
  101.  
  102. //////////////////////////////////////////////////////////////
  103. /// View == Display Video ///
  104. //////////////////////////////////////////////////////////////
  105.  
  106. public function display_videoAction()
  107. {
  108. $this->setView('display_video');
  109. $video = new Video();
  110. if (false === $video->getByShort(Tools::getParam('video'))) {
  111. Tools::fourOFour();
  112. }
  113. $video->updateViews();
  114. $this->view->assign(array('video' => $video));
  115. $this->view->render();
  116. }
  117.  
  118. }
  119. ?>
Add Comment
Please, Sign In to add comment