All pastes #220915 Raw Edit

Stuff

public text v1 · immutable
#220915 ·published 2006-10-25 11:57 UTC
rendered paste body
config/restricted_pages
<?php
$config['restricted_pages']	=   array(
    'bedrijf/toevoegen',
    'bedrijf/wijzigen',
    'gebruiker/toevoegen',
    'gebruiker/wijzigen',
    'content/nieuws_toevoegen',
    'content/nieuws_wijzigen',
    'categorie/toevoegen',
    'categorie/wijzigen',
    'content/gemelde_items'
  );
?>



config/hooks.php
<?php
$hook['post_controller_constructor'][] = array(
                                'class'    => 'Restricted_Access',
                                'function' => 'restrict',
                                'filename' => 'restricted_access.php',
                                'filepath' => 'hooks',
                                'params'   => array()                                
                                );
?>

hooks/restricted_access.php

<?php
class Restricted_Access {

    private $obj;
    
    // Initialize: start a session
    public function Restricted_Access()
    {
         $this->obj =& get_instance();         
    }
  
  
    public function restrict($pages)
    {
        $this->obj->load->config('restricted_pages');
        
        $current = $this->obj->uri->slash_segment(1) . $this->obj->uri->segment(2);        
        if(in_array($current, $this->obj->config->item('restricted_pages')))
        {
            if($_SESSION['gebruiker']['beheer'] != '1')
            {
              show_error('Geen toegang');
            }            
        }
        return;
    }
}
?>