Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php defined('SYSPATH') OR die('No direct access allowed.');
- class Admin_Controller extends Controller
- {
- public function __construct()
- {
- parent::__construct();
- $this->session = Session::instance();
- }
- public function index()
- {
- if (isset($_SESSION['auth']))
- {
- url::redirect('/admin/panel');
- }
- $this->session->create();
- $view = new View('admin/admin_view');
- $view->error = "";
- $view->render(TRUE);
- }
- public function login()
- {
- // sha1 pass
- $pass = 'd0be2dc421be4fcd0172e5afceea3970e2f3d940';
- $username = $_POST['username'];
- $password = $_POST['password'];
- if($username == "admin" && sha1($password) == $pass)
- {
- $_SESSION['auth'] = true;
- if(isset($_SESSION['auth']))
- {
- url::redirect('/admin/panel');
- }
- }
- else
- {
- $view = new View('/admin/admin_view');
- $view->error = "Bad Username/Password";
- $view->render(TRUE);
- }
- }
- public function logout()
- {
- $this->session->destroy();
- url::redirect('/admin');
- }
- }
Add Comment
Please, Sign In to add comment