• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
advanced restrict

#1
[eluser]nagata[/eluser]
So I Have been writting more advanced restrict access function for my website,
which is supposed to accept multiple check's like
(Sample Argument var_dump)
array(1) {
[0]=>
array(2) {
["type"]=>
string(5) "group"
["value"]=>
string(14) "Administrators"
}
}

Code:
function restrict($user_group = FALSE)
{
  if($user_group == 'logged_out')
  {
   if ($this->logged_in())
   {
    redirect('/member');
   }
  }
  else if($user_group == 'logged_in')
  {
   if (!$this->logged_in())
   {
    redirect('/member/login');
   }  
  }
  else if (is_array($user_group)) {
  var_dump($user_group);
   foreach ($user_group as $item) {
    if (is_array($item)) {
    var_dump($item);
     foreach ($item as $object) {
     if ($object['type']=='group'){
       if ($object['value']==$this->CI->user->user_group){
              
       }else{redirect('/member');}
      }
     else if ($object['type']=='username'){
       if ($object['value']==$this->CI->user->username){
              
       }else{redirect('/member');}
      }
     }  
    }
   }  
  }
  else if( ! $this->logged_in())
  {
   $this->CI->session->set_flashdata('referrer', $this->CI->uri->uri_string());
   redirect('/member/login');
  }
  else if ($user_group AND $this->CI->user->user_group !== $user_group)
  {
   $this->CI->session->set_flashdata('referrer', $this->CI->uri->uri_string());
   redirect('/member/login');
  }

  var_dump($this->CI->user);
}
I cant seem to get this thing work for me, when I try enter Admin Panel with a normal acc, it dosent redirect it, guys help!

#2
[eluser]InsiteFX[/eluser]
For one take the forward slash off of all your /member redirects.

#3
[eluser]nagata[/eluser]
I did it but it dosent work, maybe some actualy usefull suggestion now?

#4
[eluser]nagata[/eluser]
I have came to solution, no help is needed anymore.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.