/** * 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(); }
* This file is part of the xanthin+ project. * * Copyright (C) 2006 Mario Casciaro <xshadow [at] email (dot) it> * * Licensed under: * - Apache License, Version 2.0 or * - GNU General Public License (GPL) * You should have received at least one copy of them along with this program. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED.SEE YOUR CHOOSEN LICENSE FOR MORE DETAILS. */ //include right lib if (xanth_conf_get('db_type', 'mysql') == 'mysql') { require_once 'mysql_db.inc.php'; } else { } /** * Helper function for db_query(). */ function _xanth_db_query_callback($match, $init = FALSE) { static $args = NULL; if ($init) { $args = $match; return; } switch ($match[1]) { case '%d':
/** * Function for logging messages and error. For every logging level a specific action will be taken. \n * LOG_LEVEL_FATAL_ERROR: Application will die immediately and message will be displayed only on screen.\n * LOG_LEVEL_ERROR: Application will stop execution, but a basic environment will be created for displaying message on screen,a log entry is added in db\n * LOG_LEVEL_WARNING/LOG_LEVEL_NOTICE: Application will continue execution and a message is displayed on a region of screen,a log entry is added in db\n * LOG_LEVEL_USER_MESSAGE: A message is displayed to the user\n * LOG_LEVEL_AUDIT: Application will log a message only in database\n * LOG_LEVEL_DEBUG: Print debug message only in database if $debug is defined in config\n */ function xanth_log($level, $message, $component = '', $filename_or_function = '', $line = 0) { if ($level == LOG_LEVEL_FATAL_ERROR) { exit("Fatal Error on component {$component} ({$filename_or_function}@{$line}), {$message}"); } if ($level == LOG_LEVEL_ERROR || $level == LOG_LEVEL_WARNING || $level == LOG_LEVEL_NOTICE || $level == LOG_LEVEL_USER_MESSAGE) { xanth_add_screen_log($level, $component, $message, $filename_or_function, $line); } if ($level > LOG_LEVEL_FATAL_ERROR && $level < LOG_LEVEL_DEBUG && $level != LOG_LEVEL_USER_MESSAGE) { xanth_db_log($level, $component, $message, $filename_or_function, $line); } if ($level == LOG_LEVEL_DEBUG && xanth_conf_get('debug', false)) { xanth_db_log($level, $component, $message, $filename_or_function, $line); } }
/** * */ function xanth_get_working_dir() { return $_SERVER['DOCUMENT_ROOT'] . xanth_conf_get('db_doc_path', ''); }
$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";
/** * */ function check_current_user_access($access_rule) { if (xanth_conf_get('debug', FALSE)) { if (!xAccessRule::exists($access_rule)) { xanth_log(LOG_LEVEL_DEBUG, 'Access rule "' . $access_rule . '" does not exists', 'User'); } } $userid = xUser::get_current_userid(); if ($userid !== NULL) { //if user has admin role bypass check $result = xanth_db_query("SELECT * FROM user_to_role WHERE userid = %d AND roleName = '%s'", $userid, 'administrator'); if ($row = xanth_db_fetch_array($result)) { return TRUE; } //select other roles $result = xanth_db_query("SELECT role_access_rule.access_rule FROM user_to_role,role_access_rule WHERE \r\n\t\t\t\tuser_to_role.userid = %d AND (role_access_rule.roleName = user_to_role.roleName OR role_access_rule.roleName = '%s') \r\n\t\t\t\tAND\trole_access_rule.access_rule = '%s'", $userid, 'authenticated', $access_rule); } else { $result = xanth_db_query("SELECT role_access_rule.access_rule FROM role_access_rule WHERE \r\n\t\t\t\trole_access_rule.roleName = '%s' AND role_access_rule.access_rule = '%s'", 'anonymous', $access_rule); } if ($row = xanth_db_fetch_array($result)) { return TRUE; } return FALSE; }