Exemplo n.º 1
0
    public function __construct($subject, $config = array())
	{
	    //Intercept the events for profiling
	    if(KDEBUG) 
	    {
	        //Create the event profiler
	        $profiler = KFactory::get('com://admin/debug.profiler.events');
	        
	        //Replace the event dispatcher
	        KFactory::set('koowa:event.dispatcher', $profiler);
		}
		
		parent::__construct($subject, $config);
	}
Exemplo n.º 2
0
	/**
	 * Basic authentication support
	 *
	 * This functions tries to log the user in if authentication credentials are
	 * present in the request.
	 *
	 * @return boolean	Returns TRUE is basic authentication was successful
	 */
	protected function _authenticateUser()
	{
	    if(KRequest::has('server.PHP_AUTH_USER') && KRequest::has('server.PHP_AUTH_PW')) 
	    {
	        $credentials = array(
	            'username' => KRequest::get('server.PHP_AUTH_USER', 'url'),
	            'password' => KRequest::get('server.PHP_AUTH_PW'  , 'url'),
	        );
	        
	        if(KFactory::get('joomla:application')->login($credentials) !== true) 
	        {  
	            throw new KException('Login failed', KHttpResponse::UNAUTHORIZED);
        	    return false;      
	        }
	        
	        //Reset the user object in the factory
	        KFactory::set('joomla:user', JFactory::getUser());
	         
	        //Force the token
	        KRequest::set('request._token', JUtility::getToken());
	        
	        return true;
	    }
	    
	    return false;
	}