Guest User

Untitled

a guest
May 10th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. <?php defined('SYSPATH') OR die('No direct access allowed.');
  2.  
  3. class Admin_Controller extends Controller
  4. {
  5. public function __construct()
  6. {
  7. parent::__construct();
  8. $this->session = Session::instance();
  9. }
  10.  
  11. public function index()
  12. {
  13. if (isset($_SESSION['auth']))
  14. {
  15. url::redirect('/admin/panel');
  16. }
  17.  
  18. $this->session->create();
  19.  
  20. $view = new View('admin/admin_view');
  21. $view->error = "";
  22. $view->render(TRUE);
  23. }
  24.  
  25. public function login()
  26. {
  27. // sha1 pass
  28. $pass = 'd0be2dc421be4fcd0172e5afceea3970e2f3d940';
  29.  
  30. $username = $_POST['username'];
  31. $password = $_POST['password'];
  32.  
  33. if($username == "admin" && sha1($password) == $pass)
  34. {
  35. $_SESSION['auth'] = true;
  36. if(isset($_SESSION['auth']))
  37. {
  38. url::redirect('/admin/panel');
  39. }
  40. }
  41. else
  42. {
  43. $view = new View('/admin/admin_view');
  44. $view->error = "Bad Username/Password";
  45. $view->render(TRUE);
  46. }
  47. }
  48.  
  49. public function logout()
  50. {
  51. $this->session->destroy();
  52. url::redirect('/admin');
  53. }
  54. }
Add Comment
Please, Sign In to add comment