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.");
            }
        }
    }
    // --- 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();
}
示例#2
0
// Run Optional Params first: userid/groupid
if (isset($_SERVER["argv"][4])) {
    // Set to SourceID property!
    $tmpvar = $_SERVER["argv"][4];
    if (strpos($tmpvar, "=") !== false) {
        $tmparr = explode("=", $tmpvar);
        if ($tmparr[0] == "userid") {
            // Set logged in state for LogAnalyzer System
            $_SESSION['SESSION_LOGGEDIN'] = true;
            $content['SESSION_LOGGEDIN'] = true;
            $_SESSION['SESSION_USERID'] = $tmparr[1];
            $content['SESSION_USERID'] = $tmparr[1];
        } else {
            if ($tmparr[0] == "groupid") {
                $_SESSION['SESSION_GROUPIDS'] = $tmparr[1];
                $content['SESSION_GROUPIDS'] = $tmparr[1];
            }
        }
    }
    // Reload Configured Sources
    LoadSourcesFromDatabase();
    InitSourceConfigs();
}
// ---
// --- Operation Handling now
if ($operation == "runreport") {
    // Create Report
    RunReport();
}
// ---
// ---