SHARE
TWEET

Untitled

a guest Oct 2nd, 2017 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class Elib extends CI_Controller {
  4.     private $data;
  5.     private $sidebar;
  6.     private $login;
  7.  
  8.     function  __construct() {
  9.         parent::__construct();
  10.         $this->load->library('session');
  11.         $this->load->helper('url');
  12.  
  13.         $this->data['title'] = "E-Library";
  14.         $this->load->database();
  15.  
  16.         if (!$this->session->userdata('lang'))
  17.             $this->session->set_userdata('lang', 'english');
  18.  
  19.         if($this->login->ADMIN == '1'){
  20.             $this->sidebar = 'sidebar_admin';
  21.         }else{
  22.             $this->sidebar = 'sidebar_member';
  23.         }
  24.     }
  25.  
  26.     function ind() {
  27.         $this->session->set_userdata('lang', 'indonesia');
  28.         redirect($this->session->userdata('page'));
  29.     }
  30.  
  31.     function eng() {
  32.         $this->session->set_userdata('lang', 'english');
  33.         redirect($this->session->userdata('page'));
  34.     }
  35.  
  36.     function index($page='') {
  37.         $this->session->set_userdata('page', 'elib/index');
  38.         $this->lang->load('static', $this->session->userdata('lang'));
  39.         $this->load->database();
  40.         $dropDownList = $this->db->query("SELECT nama_jenis, id_jenis_koleksi FROM jenis_koleksi");
  41.  
  42.         $result['jenisKoleksi'] = array();
  43.         foreach ($dropDownList->result() as $row) {
  44.             $result['jenisKoleksi'][] = $row;
  45.         }
  46.         $this->load->view('header', $this->data);
  47.  
  48.         if($this->session->userdata('error') == 'true') {
  49.             $this->load->view('error_alert');
  50.             $this->session->unset_userdata('error');
  51.         }
  52.         $this->load->view('header2');
  53.         $this->load->view('menu');
  54.         if(!$this->session->userdata('user')) {
  55.             $this->load->view('sidebar_login');
  56.         }
  57.         else {
  58.             $this->load->view($sidebar);
  59.         }
  60.         $this->load->view('sidebar_top10');
  61.         $this->load->view('content', $result);
  62.         $this->load->view('footer');
  63.     }
  64.  
  65.     function login() {
  66.         $username = $_POST['username'];
  67.         $password = $_POST['password'];
  68.  
  69.         $query = "SELECT * FROM member WHERE nim = '$username' AND password = '$password'";
  70.         $result = $this->db->query($query);
  71.         $tbl = $result->result();
  72.         if ($result->num_rows() == 0) {
  73.             $this->session->set_userdata('error', 'true');
  74.             redirect($this->session->userdata('page'));
  75.         }
  76.         else {
  77.             $this->session->set_userdata('login', $tbl[0]);
  78.             $this->login = $this->session->userdata('login');
  79.             redirect($this->session->userdata('page'));
  80.         }
  81.     }
  82.  
  83.     function logout() {
  84.         $this->session->unset_userdata('user');
  85.         $this->session->unset_userdata('admin');
  86.         redirect($this->session->userdata('page'));
  87.     }
  88. }
  89.  
  90. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top