private function _init()
 {
     $Classes = array('config' => 'Config', 'router' => 'Router', 'uri' => 'URI', 'output' => 'Output');
     foreach ($Classes as $public_var => $Class) {
         $this->{$public_var} = common::register($Class);
     }
 }
 public function _display($output = '')
 {
     if ($output == '') {
         $output =& $this->final_output;
     }
     if ($this->cache_expiration > 0) {
         $this->_write_cache($output);
     }
     $elapsed = common::register('Benchmark')->elapsed_time('total_execution_time_start', 'total_execution_time_end');
     $output = str_replace('{elapsed_time}', $elapsed, $output);
     $memory = !function_exists('memory_get_usage') ? '0' : round(memory_get_usage() / 1024 / 1024, 2) . ' MB';
     $output = str_replace('{memory_usage}', $memory, $output);
     // --------------------------------------------------------------------
     // Is compression requested?
     /*if (common::config_item('compress_output', 'cache') === TRUE)
             {
                 if (extension_loaded('zlib'))
                 {             
                     if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
                     {   // Obullo changes .. 
                         ini_set('zlib.output_compression_level', config_item('compression_level', 'cache'));  
                         ob_start('ob_gzhandler');
                     }
                 }
             }
     	*/
     if (count($this->headers) > 0) {
         foreach ($this->headers as $header) {
             @header($header[0], $header[1]);
         }
     }
     if (!function_exists('this')) {
         echo $output;
         return TRUE;
     }
     if ($this->enable_profiler == TRUE) {
         $profiler = base::register('Profiler');
         if (preg_match("|</body>.*?</html>|is", $output)) {
             $output = preg_replace("|</body>.*?</html>|is", '', $output);
             $output .= $profiler->run();
             $output .= '</body></html>';
         } else {
             $output .= $profiler->run();
         }
     }
     $ob = base::getInstance();
     if (method_exists($ob, '_output')) {
         $ob->_output($output);
     } else {
         echo $output;
         // Send it to the browser!
     }
 }
 public function __construct()
 {
     //$routes = get_config('routes');   // Obullo changes..
     //print_r($routes);
     require APP . 'config' . DS . 'routes' . PHP_EXT;
     $this->routes = (!isset($routes) or !is_array($routes)) ? array() : $routes;
     //print_r($this->routes);
     unset($routes);
     $this->method = $this->routes['index_method'];
     $this->uri = common::register('Uri');
     $this->_set_routing();
     //log_message('debug', "Router Class Initialized");
 }
function _view($file, $arr_data = array(), $return_string)
{
    if (!file_exists($file)) {
        throw new Exception("Can't load template file: " . $file);
    }
    if (sizeof($arr_data) > 0) {
        extract($arr_data, EXTR_SKIP);
    }
    ob_start();
    include $file;
    if ($return_string) {
        $content = ob_get_contents();
        @ob_end_clean();
        return $content;
    }
    common::register('Output')->append_output(ob_get_contents());
    @ob_end_clean();
    return;
}
 function parse($template, $data, $return = TRUE)
 {
     loader::sys_helper('view');
     $output = common::register('Output');
     $template = view($template, $data, TRUE);
     if ($template == '') {
         return FALSE;
     }
     foreach ($data as $key => $val) {
         if (is_array($val)) {
             $template = $this->_parse_pair($key, $val, $template);
         } else {
             $template = $this->_parse_single($key, (string) $val, $template);
         }
     }
     if ($return == FALSE) {
         $output->append_output($template);
     }
     return $template;
 }
 private static function _library($library, $folder = 'system')
 {
     if ($library == '') {
         return false;
     }
     $library = strtolower($library);
     switch ($folder) {
         case 'system':
             $lib_folder = SYS . 'libraries' . DS;
             break;
         case 'application':
             $lib_folder = APP . 'libraries' . DS;
             break;
         case 'directories':
             $lib_folder = DIR . $GLOBALS['d'] . DS . 'libraries' . DS;
             break;
     }
     if (file_exists($lib_folder . $library . '_library' . PHP_EXT)) {
         require $lib_folder . $library . '_library' . PHP_EXT;
         base::getInstance()->{$library} = common::register($library);
     } else {
         throw new Exception("Can't load library file: " . $library);
     }
 }
require SYS . 'error' . DS . 'errors.php';
require SYS . 'libraries' . DS . 'benchmark_library.php';
$benchmark = common::register('Benchmark');
$benchmark->mark('total_execution_time_start');
require SYS . 'core' . DS . 'loader.php';
require SYS . 'core' . DS . 'base.php';
require SYS . 'core' . DS . 'controller.php';
require SYS . 'core' . DS . 'model.php';
require SYS . 'libraries' . DS . 'router_library.php';
require SYS . 'libraries' . DS . 'uri_library.php';
require SYS . 'libraries' . DS . 'output_library.php';
require SYS . 'libraries' . DS . 'config_library.php';
date_default_timezone_set(common::config_item('timezone_set'));
$uri = common::register('Uri');
$router = common::register('Router');
$output = common::register('Output');
if ($output->_display_cache($uri) == TRUE) {
    exit;
}
$GLOBALS['d'] = $router->fetch_directory();
// Get requested directory
$GLOBALS['c'] = $router->fetch_class();
// Get requested controller
$GLOBALS['m'] = $router->fetch_method();
// Get requested method
//panggil default controller pada directory application/controller
if (!file_exists(DIR . $GLOBALS['d'] . DS . 'controllers' . DS . $GLOBALS['c'] . PHP_EXT)) {
    if ($router->query_string) {
        show_404("{$GLOBALS['d']}/{$GLOBALS['c']}/{$GLOBALS['m']}");
    }
    throw new Exception('Unable to load your default controller.Please make sure the controller specified in your Routes.php file is valid.');