/**
* Init function
* @ingroup Core
*/
function xanth_init()
{
    global $start_time;
    $start_time = gettimeofday(TRUE);
    ob_start();
    xanth_db_query_reset_count();
    set_error_handler('xanth_php_error_handler');
    xanth_db_connect(xanth_conf_get('db_host', ''), xanth_conf_get('db_name', ''), xanth_conf_get('db_user', ''), xanth_conf_get('db_pass', ''), xanth_conf_get('db_port', ''));
    session_set_save_handler("on_session_start", "on_session_end", "on_session_read", "on_session_write", "on_session_destroy", "on_session_gc");
    session_start();
    xComponent::init_all();
    xModule::init_all();
    //xTheme::find_default()->init();
    xanth_invoke_multi_hook(MULTI_HOOK_PAGE_CREATE_EVT, NULL);
    xanth_invoke_mono_hook(MONO_HOOK_PAGE_CREATE, NULL);
    //print log
    echo '<br />';
    echo '<br />';
    echo '<br />';
    echo '<br />';
    echo '<br />';
    foreach (xanth_get_screen_log() as $entry) {
        echo '<br />' . $entry->level . ' ' . $entry->component . ' ' . $entry->message . ' ' . $entry->filename . '@' . $entry->line;
    }
    session_write_close();
    echo ob_get_clean();
}
 function render()
 {
     $theme = xTheme::get_default();
     //retrieve content
     $page_content = xanth_invoke_mono_hook(MONO_HOOK_PAGE_CONTENT_CREATE, $this->xanthpath->base_path, array($this->xanthpath->resource_id));
     if ($page_content === NULL) {
         $page_content = new xPageContent('Page not found', "<b>Page not found</b>");
     }
     $logs = '';
     $log_entries = xanth_get_screen_log();
     //display log messages
     if (!empty($log_entries)) {
         $logs .= '<table border="1" width="90%"><tr><td><ul>';
         foreach ($log_entries as $entry) {
             $logs .= '<li>' . $entry->level . ' ' . $entry->component . ' ' . htmlspecialchars($entry->message) . ' ' . $entry->filename . '@' . $entry->line . '</li>';
         }
         $logs .= '</ul></td></tr></table>' . "\n";
     }
     $page_content->body = $logs . $page_content->body;
     //retrieve areas
     $areas = xThemeArea::find_all();
     $this->areas = array();
     $this->boxes = array();
     //retrieve innermost elements
     foreach ($areas as $area) {
         $xboxes = xBox::find($area->name);
         $this->boxes[$area->name] = array();
         foreach ($xboxes as $xbox) {
             //retrieve box view
             $this->boxes[$area->name][] = $xbox->render();
         }
         //Generate area view (not using view mode)
         $this->areas[$area->name] = $area->render($this->boxes[$area->name], $page_content->body);
     }
     //construct metadata array
     $this->header = array();
     if (empty($page_content->description)) {
         $this->header['description'] = xSettings::get('site_description');
     } else {
         $this->header['description'] = $page_content->description;
     }
     if (empty($page_content->keywords)) {
         $this->header['keywords'] = xSettings::get('site_keywords');
     } else {
         $this->header['keywords'] = $page_content->keywords;
     }
     //retrieve the full page
     $this->header['title'] = xSettings::get('site_name') . ' | ' . $page_content->title;
     $page_ready_to_print = eval($theme->get_view_mode_procedure('page'));
     return $page_ready_to_print;
 }
        $weight_func = 'xanth_db_install_weight_' . $component->name;
        $weighted_components[] = array($weight_func(), $component);
    }
    usort($weighted_components, 'weight_cmp');
    foreach ($weighted_components as $component) {
        $inst_func = 'xanth_db_install_' . $component[1]->name;
        $inst_func();
    }
    $weighted_modules = array();
    foreach (xModule::find_existing() as $module) {
        include_once $module->path . '/install.inc.php';
        $weight_func = 'xanth_db_install_weight_' . $module->name;
        $weighted_modules[] = array($weight_func(), $module);
    }
    usort($weighted_modules, 'weight_cmp');
    foreach ($weighted_modules as $module) {
        $inst_func = 'xanth_db_install_' . $module[1]->name;
        $inst_func();
    }
    xanth_db_commit();
}
xanth_db_connect(xanth_conf_get('db_host', ''), xanth_conf_get('db_name', ''), xanth_conf_get('db_user', ''), xanth_conf_get('db_pass', ''), xanth_conf_get('db_port', ''));
error_reporting(E_ALL);
xComponent::init_all();
xModule::init_all();
xanth_install_db();
//print log
foreach (xanth_get_screen_log() as $entry) {
    echo '<br />' . $entry->level . ' ' . $entry->component . ' ' . $entry->message . ' ' . $entry->filename . '@' . $entry->line;
}
echo "xanthin+ successfully installed";