Welcome Guest, Not a member yet? Register   Sign In
About Library
#1

class Donaturlib {


   function 
is_admin()
    {            
        
$ci     =&get_instance();
            
$cek $ci->donaturlib->security();    
                        if(
$cek != null)
                        {
                                       foreach (
$cek as $key) {
                                       
$username =  $key->username;
                                       }
                                       
$hasil $ci->donaturlib->getPeople($username);
                                       foreach (
$hasil as $levelnya ) {
                                           
$lv $levelnya->level;
                                       }
                                       if (
$lv != 1) {
                                           return 
false;
                                       }
                                       else
                                       {
                                           return 
true;
                                       }
                        }else{
        
$msg="<div class='alert alert-danger alert-dismissible' role='alert'>
  <button type='button' class='close' data-dismiss='alert'>
  <span aria-hidden='true'>&times;</span><span class='sr-only'>Close</span></button>
  <strong>Harap login terlebih dahulu
</div>"
;
        
$ci->session->set_flashdata('donatur',$msg);
        
redirect('welcome','refresh');
                        }

   }
    function 
getPeople($username)
    {
            
$ci     =&get_instance();
            
$query  =   $ci->db->query("select level from user where username ='$username'");
            return 
$query->result();
    }
    function 
checkexist($namadonasi,$tabel1)
    {
            
$ci         =   &get_instance();
            
$fieldpilih    ='*'
            
$hasil         $ci->modeldonatur->pilihdata($tabel1,$namadonasi,$fieldpilih);    
            if(
$hasil!=null)
            {
                return 
true;
            }
            else
            {
                return 
false;
            }
    }
    function 
security()
        {
            
$ci     =&get_instance();
            
$vCuser     $ci->input->cookie('dnt_user');
            
$vCsesi     $ci->input->cookie('dnt_sesi');
            
$tbl='logindata';
            
$fieldpilih='*'
            
$fieldkondisi=array('username'=>$vCuser,'sesi'=>$vCsesi);             
            
$hasil      $ci->modeldonatur->pilihdata($tbl,$fieldkondisi,$fieldpilih);
            
            if(
$hasil!=null)
            {
            
//simpan ke cookie
            
$vCookie1['name']   = 'ik_inv_ck_user';
            
$vCookie1['value']  = $vCuser;
            
$vCookie1['expire'] = '600';
            
$ci->input->set_cookie($vCookie1);
            
            
//simpan ke cookie token/sesi   
            
$vCookie2['name']   = 'ik_inv_ck_sesi';
            
$vCookie2['value']   = $vCsesi;
            
$vCookie2['expire']  = '600';
            
$ci->input->set_cookie($vCookie2);
            }
            
            return 
$hasil;
        }

 } 
Reply
#2

Why did you post that code? What's your question?
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

I was going to ask the same thing.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB