<?php
defined('_JEXEC') or die( 'Restricted access' );

JTable::addIncludePath( JPATH_COMPONENT.DS.'tables' );

$view = strtolower(JRequest::getCmd('view', 'rules'));
$task = strtolower(JRequest::getCmd('task', 'display'));
$prefix = substr($option,4); //controller class prefix

JRequest::setVar('view', $view);

$controllerPath	= JPATH_COMPONENT.DS.'controllers'.DS.$view.'.php';
	
if (file_exists($controllerPath))
	require_once($controllerPath);
else
	JError::raiseError(500, 'Controller file "'.$controllerPath.'" not found');

$controllerClass = ucfirst($prefix).'Controller'.ucfirst($view);
if (class_exists($controllerClass))
	$controller = new $controllerClass();
else
	JError::raiseError(500, 'Invalid Controller Class - '.$controllerClass );


JHTML::stylesheet( 'component.css', 'administrator/components/'.$option.'/assets/css/' );
if($task=='display'){
	JSubMenuHelper::addEntry(JText::_('IP filters'), 'index.php?option='.$option.'&view=rules', $view=='rules');
	JSubMenuHelper::addEntry(JText::_('Settings'), 'index.php?option='.$option.'&view=settings', $view=='settings');
}


//$config	=& JFactory::getConfig();
$controller->execute($task);
$controller->redirect();
