示例#1
0
include $gl_root_path . 'include/functions_installhelpers.php';
// Init Langauge first!
IncludeLanguageFile($gl_root_path . '/lang/' . $LANG . '/main.php');
InitBasicPhpLogCon();
if (InitPhpLogConConfigFile(false)) {
    DieWithErrorMsg($content['LN_INSTALL_ERRORINSTALLED']);
}
// Set some static values
define('MAX_STEPS', 8);
$content['web_theme'] = "default";
$content['user_theme'] = "default";
$configsamplefile = $content['BASEPATH'] . "include/config.sample.php";
$content['HeaderDefaultEncoding'] = ENC_ISO_8859_1;
// Set Default encoding!
// New Set Font settingdefaults
InitFontSettings();
//ini_set('error_reporting', E_ALL); // DEBUG ENABLE
// ***					*** //
// --- CONTENT Vars
$content['TITLE'] = "LogAnalyzer :: " . $content['LN_INSTALL_TITLE'];
// ---
// --- Read Vars
if (isset($_GET['step'])) {
    $content['INSTALL_STEP'] = intval(DB_RemoveBadChars($_GET['step']));
    if ($content['INSTALL_STEP'] > MAX_STEPS) {
        $content['INSTALL_STEP'] = 1;
    }
} else {
    $content['INSTALL_STEP'] = 1;
}
// Set Next Step
function InitConfigurationValues()
{
    global $content, $CFG, $LANG, $gl_root_path;
    // To avoid this code in case of conversion
    if (!defined('IN_PHPLOGCON_CONVERT')) {
        // If Database is enabled, try to read from database!
        if (GetConfigSetting("UserDBEnabled", false)) {
            // Get configuration variables
            $result = DB_Query("SELECT * FROM `" . DB_CONFIG . "` WHERE is_global = true");
            if ($result) {
                $rows = DB_GetAllRows($result, true);
                // Read results from DB and overwrite in $CFG Array!
                if (isset($rows)) {
                    for ($i = 0; $i < count($rows); $i++) {
                        // Obtain the right value
                        if (isset($rows[$i]['propvalue_text']) && strlen($rows[$i]['propvalue_text']) > 0) {
                            $myValue = $rows[$i]['propvalue_text'];
                        } else {
                            $myValue = $rows[$i]['propvalue'];
                        }
                        $CFG[$rows[$i]['propname']] = $myValue;
                        $content[$rows[$i]['propname']] = $myValue;
                    }
                }
            } else {
                // Critical ERROR HERE!
                DieWithFriendlyErrorMsg("Critical Error occured while trying to access the database in table '" . DB_CONFIG . "'");
            }
            // Database Version Checker!
            if ($content['database_internalversion'] > $content['database_installedversion']) {
                // Database is out of date, we need to upgrade
                $content['database_forcedatabaseupdate'] = "yes";
            }
            // Now we init the user session stuff
            InitUserSession();
            if (!$content['SESSION_LOGGEDIN']) {
                // Check if user needs to be logged in
                if (GetConfigSetting("UserDBLoginRequired", false)) {
                    // Redirect USER if not on loginpage or installpage!
                    if (!defined("IS_NOLOGINPAGE") && !defined("IN_PHPLOGCON_INSTALL") && !defined("IN_PHPLOGCON_COMMANDLINE")) {
                        RedirectToUserLogin();
                    }
                } else {
                    if (defined('IS_ADMINPAGE')) {
                        // Language System not initialized yet
                        DieWithFriendlyErrorMsg("You need to be logged in in order to access the admin pages.", "login.php", "Click here to login");
                    }
                }
            }
            // Load field definitions from DB, very first thing todo!
            LoadFieldsFromDatabase();
            // Load Configured Searches
            LoadSearchesFromDatabase();
            // Load Configured Charts
            LoadChartsFromDatabase();
            // Load Configured Views
            LoadViewsFromDatabase();
            // Load Configured Mappings
            LoadDBMappingsFromDatabase();
            // Load Configured Sources
            LoadSourcesFromDatabase();
        } else {
            if (defined('IS_ADMINPAGE') || defined("IS_NOLOGINPAGE")) {
                // Language System not initialized yet
                DieWithFriendlyErrorMsg("The LogAnalyzer user system is currently disabled or not installed.");
            }
        }
    }
    // --- Init Fonttype and size by config setting
    InitFontSettings();
    // ---
    // --- Language Handling
    // Set gen language default
    $content['gen_lang'] = GetConfigSetting("ViewDefaultLanguage", "en", CFGLEVEL_GLOBAL);
    // Now check for current used language
    if (isset($_SESSION['CUSTOM_LANG']) && VerifyLanguage($_SESSION['CUSTOM_LANG'])) {
        $content['user_lang'] = $_SESSION['CUSTOM_LANG'];
        $LANG = $content['user_lang'];
    } else {
        if (isset($content['gen_lang']) && VerifyLanguage($content['gen_lang'])) {
            $content['user_lang'] = $content['gen_lang'];
            $LANG = $content['user_lang'];
        } else {
            $content['user_lang'] = GetConfigSetting("ViewDefaultLanguage", "en", CFGLEVEL_USER);
            $LANG = $content['user_lang'];
            $content['gen_lang'] = $content['user_lang'];
        }
    }
    // ---
    // Paging Size handling!
    if (!isset($_SESSION['PAGESIZE_ID'])) {
        // Default is 0!
        $_SESSION['PAGESIZE_ID'] = 0;
    }
    // Auto reload handling!
    if (!isset($_SESSION['AUTORELOAD_ID'])) {
        if (GetConfigSetting("ViewEnableAutoReloadSeconds", 0, CFGLEVEL_USER) > 0) {
            $_SESSION['AUTORELOAD_ID'] = 1;
        } else {
            // Default is 0, which means auto reload disabled
            $_SESSION['AUTORELOAD_ID'] = 0;
        }
    }
    // --- Theme Handling
    if (!isset($content['web_theme'])) {
        $content['web_theme'] = GetConfigSetting("ViewDefaultTheme", "default", CFGLEVEL_USER);
    }
    if (isset($_SESSION['CUSTOM_THEME']) && VerifyTheme($_SESSION['CUSTOM_THEME'])) {
        $content['user_theme'] = $_SESSION['CUSTOM_THEME'];
    } else {
        $content['user_theme'] = $content['web_theme'];
    }
    /*
    	// Init Theme About Info ^^
    	InitThemeAbout($content['user_theme']);
    	// ---
    */
    // --- Handle HTML Injection stuff
    if (strlen(GetConfigSetting("InjectHtmlHeader", false)) > 0) {
        $content['EXTRA_HTMLHEAD'] .= $CFG['InjectHtmlHeader'];
    } else {
        $content['InjectHtmlHeader'] = "";
    }
    // Init Option
    if (strlen(GetConfigSetting("InjectBodyHeader", false)) > 0) {
        $content['EXTRA_HEADER'] .= $CFG['InjectBodyHeader'];
    } else {
        $content['InjectBodyHeader'] = "";
    }
    // Init Option
    if (strlen(GetConfigSetting("InjectBodyFooter", false)) > 0) {
        $content['EXTRA_FOOTER'] .= $CFG['InjectBodyFooter'];
    } else {
        $content['InjectBodyFooter'] = "";
    }
    // Init Option
    // ---
    // --- Handle Optional Logo URL!
    if (strlen(GetConfigSetting("PhplogconLogoUrl", false)) > 0) {
        $content['EXTRA_PHPLOGCON_LOGO'] = $CFG['PhplogconLogoUrl'];
    } else {
        $content['PhplogconLogoUrl'] = "";
    }
    // Init Option
    // ---
    // --- Set Proxy Option
    if (strlen(GetConfigSetting("UseProxyServerForRemoteQueries", false)) <= 0) {
        $content['UseProxyServerForRemoteQueries'] = "";
    }
    // Init Option
    // ---
    // --- Read Encoding Option, and set default!
    $content['HeaderDefaultEncoding'] = GetConfigSetting("HeaderDefaultEncoding", ENC_ISO_8859_1);
    // ---
    // --- Read ContextLinks Option, and set default!
    $content['EnableContextLinks'] = GetConfigSetting("EnableContextLinks", 1);
    // ---
    // Init main langauge file now!
    IncludeLanguageFile($gl_root_path . '/lang/' . $LANG . '/main.php');
    // Init other things which are needed
    InitFrontEndVariables();
}