public function LogStreamMongoDB($streamConfigObj) { $this->_logStreamConfigObj = $streamConfigObj; // Probe if a function exists! if (!function_exists("bson_encode")) { DieWithFriendlyErrorMsg("Error, MongoDB PHP Driver Extensions is not installed! Please see <a href\"http://www.php.net/manual/en/mongo.installation.php\">http://www.php.net/manual/en/mongo.installation.php</a> for installation details."); } }
public function LogStreamDB($streamConfigObj) { $this->_logStreamConfigObj = $streamConfigObj; if ($this->_logStreamConfigObj->DBType == DB_MYSQL) { // Probe if a function exists! if (!function_exists("mysql_connect")) { DieWithFriendlyErrorMsg("Error, MYSQL Extensions are not enabled! Function 'mysql_connect' does not exist."); } } }
public function LogStreamPDO($streamConfigObj) { $this->_logStreamConfigObj = $streamConfigObj; // Verify if Extension is enabled if (extension_loaded('pdo') == 0) { DieWithFriendlyErrorMsg("Error, PDO Extensions are not enabled or installed! This Source can not operate."); } /* if ( $this->_logStreamConfigObj->DBType == DB_MYSQL ) { // Probe if a function exists! if ( !function_exists("mysql_connect") ) DieWithFriendlyErrorMsg("Error, MYSQL Extensions are not enabled! Function 'mysql_connect' does not exist."); } */ }
// Set PAGE to be ADMINPAGE! define('IS_ADMINPAGE', true); $content['IS_ADMINPAGE'] = true; InitPhpLogCon(); InitSourceConfigs(); InitFrontEndDefaults(); // Only in WebFrontEnd InitFilterHelpers(); // Helpers for frontend filtering! // Init admin langauge file now! IncludeLanguageFile($gl_root_path . '/lang/' . $LANG . '/admin.php'); // --- // --- BEGIN Custom Code // Only if the user is an admin! if (!isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0) { DieWithFriendlyErrorMsg($content['LN_ADMIN_ERROR_NOTALLOWED']); } if (isset($_GET['op'])) { if ($_GET['op'] == "add") { // Set Mode to add $content['ISEDITORNEWFIELD'] = "true"; $content['FIELD_FORMACTION'] = "addnewfield"; $content['FIELD_SENDBUTTON'] = $content['LN_FIELDS_ADD']; //PreInit these values $content['FieldID'] = ""; $content['FieldDefine'] = "SYSLOG_"; $content['FieldCaption'] = ""; // Field Caption $content['SearchField'] = ""; // Should be set to FieldID for now! $content['SearchOnline'] = false;
// include($gl_root_path . 'classes/logstream.class.php'); // Set PAGE to be ADMINPAGE! define('IS_ADMINPAGE', true); $content['IS_ADMINPAGE'] = true; InitPhpLogCon(); InitSourceConfigs(); InitFrontEndDefaults(); // Only in WebFrontEnd InitFilterHelpers(); // Helpers for frontend filtering! // Init admin langauge file now! IncludeLanguageFile($gl_root_path . '/lang/' . $LANG . '/admin.php'); // --- Deny if User is READONLY! if (!isset($_SESSION['SESSION_ISREADONLY']) || $_SESSION['SESSION_ISREADONLY'] == 1) { if (isset($_POST['op']) || isset($_GET['op']) && $_GET['op'] == "enableuserops") { DieWithFriendlyErrorMsg($content['LN_ADMIN_ERROR_READONLY']); } } // --- // --- BEGIN Custom Code if (isset($_SESSION['SESSION_ISADMIN']) && $_SESSION['SESSION_ISADMIN'] == 1) { $content['EditAllowed'] = true; $content['DISABLE_GLOBALEDIT_FORMCONTROL'] = ""; } else { $content['EditAllowed'] = false; $content['DISABLE_GLOBALEDIT_FORMCONTROL'] = "disabled"; } // --- First thing to do is to check the op get parameter! // Check for changes first | Abort if Edit is not allowed if (isset($_GET['op']) && isset($_GET['value'])) { if ($_GET['op'] == "enableuserops") {
function WriteConfigValue($szPropName, $is_global = true, $userid = false, $groupid = false, $bForceStripSlahes = false) { global $content; // --- Abort in this case! if (GetConfigSetting("UserDBEnabled", false) == false) { return; } // --- if ($is_global) { if (isset($content[$szPropName])) { // Copy value for DB and check for BadDB Chars! $szDbValue = PrepareValueForDB($content[$szPropName], $bForceStripSlahes); } else { // Set empty in this case $szDbValue = ""; $content[$szPropName] = ""; } // Copy to $CFG array as well $CFG[$szPropName] = $content[$szPropName]; // Check if we need to INSERT or UPDATE $result = DB_Query("SELECT propname FROM `" . DB_CONFIG . "` WHERE propname = '" . $szPropName . "' AND is_global = " . $is_global); $rows = DB_GetAllRows($result, true); if (!isset($rows)) { // New Entry if (strlen($szDbValue) < 255) { $result = DB_Query("INSERT INTO `" . DB_CONFIG . "` (propname, propvalue, is_global) VALUES ( '" . $szPropName . "', '" . $szDbValue . "', " . $is_global . ")"); } else { $result = DB_Query("INSERT INTO `" . DB_CONFIG . "` (propname, propvalue_text, is_global) VALUES ( '" . $szPropName . "', '" . $szDbValue . "', " . $is_global . ")"); } DB_FreeQuery($result); } else { // Update Entry if (strlen($szDbValue) < 255) { $result = DB_Query("UPDATE `" . DB_CONFIG . "` SET propvalue = '" . $szDbValue . "', propvalue_text = '' WHERE propname = '" . $szPropName . "' AND is_global = " . $is_global); } else { $result = DB_Query("UPDATE `" . DB_CONFIG . "` SET propvalue_text = '" . $szDbValue . "', propvalue = '' WHERE propname = '" . $szPropName . "' AND is_global = " . $is_global); } DB_FreeQuery($result); } } else { if ($userid != false) { global $USERCFG; if (isset($USERCFG[$szPropName])) { // Copy value for DB and check for BadDB Chars! $szDbValue = PrepareValueForDB($USERCFG[$szPropName], $bForceStripSlahes); } else { // Set empty in this case $szDbValue = ""; $USERCFG[$szPropName] = ""; } // Check if we need to INSERT or UPDATE $result = DB_Query("SELECT propname FROM `" . DB_CONFIG . "` WHERE propname = '" . $szPropName . "' AND userid = " . $userid); $rows = DB_GetAllRows($result, true); if (!isset($rows)) { // New Entry $result = DB_Query("INSERT INTO `" . DB_CONFIG . "` (propname, propvalue, userid) VALUES ( '" . $szPropName . "', '" . $szDbValue . "', " . $userid . ")"); DB_FreeQuery($result); } else { // Update Entry $result = DB_Query("UPDATE `" . DB_CONFIG . "` SET propvalue = '" . $szDbValue . "' WHERE propname = '" . $szPropName . "' AND userid = " . $userid); DB_FreeQuery($result); } } else { if ($groupid != false) { DieWithFriendlyErrorMsg("Critical Error occured in WriteConfigValue, writing GROUP specific properties is not supported yet!"); } } } }
function ConvertCustomSources() { global $CFG, $content; // Insert all searches into the DB! foreach ($CFG['Sources'] as $sourceid => &$mySource) { // Correct VIEWID! if (isset($mySource['ViewID'])) { if (isset($CFG['Views'][$mySource['ViewID']]['DBID'])) { $mySource['ViewID'] = $CFG['Views'][$mySource['ViewID']]['DBID']; } } else { $mySource['ViewID'] = ""; } // Set empty default // Add New Entry if ($mySource['SourceType'] == SOURCE_DISK) { $result = DB_Query("INSERT INTO `" . DB_SOURCES . "` (Name, Description, SourceType, MsgParserList, MsgNormalize, ViewID, LogLineType, DiskFile) VALUES ( " . "'" . PrepareValueForDB($mySource['Name']) . "', " . "'" . PrepareValueForDB($mySource['Description']) . "', " . " " . PrepareValueForDB($mySource['SourceType']) . " , " . "'" . PrepareValueForDB($mySource['MsgParserList']) . "', " . " " . PrepareValueForDB($mySource['MsgNormalize']) . " , " . "'" . PrepareValueForDB($mySource['ViewID']) . "', " . "'" . PrepareValueForDB($mySource['LogLineType']) . "', " . "'" . PrepareValueForDB($mySource['DiskFile']) . "'" . ")"); } else { if ($mySource['SourceType'] == SOURCE_DB || $mySource['SourceType'] == SOURCE_PDO) { // Set Default for number fields if (!isset($mySource['DBEnableRowCounting'])) { $mySource['DBEnableRowCounting'] = 0; } else { // Force to number $mySource['DBEnableRowCounting'] = intval($mySource['DBEnableRowCounting']); } if (!isset($mySource['DBType'])) { $mySource['DBType'] = DB_MYSQL; } // Perform the insert $result = DB_Query("INSERT INTO `" . DB_SOURCES . "` (Name, Description, SourceType, MsgParserList, MsgNormalize, ViewID, DBTableType, DBType, DBServer, DBName, DBUser, DBPassword, DBTableName, DBEnableRowCounting) VALUES ( " . "'" . PrepareValueForDB($mySource['Name']) . "', " . "'" . PrepareValueForDB($mySource['Description']) . "', " . " " . PrepareValueForDB($mySource['SourceType']) . " , " . "'" . PrepareValueForDB($mySource['MsgParserList']) . "', " . " " . PrepareValueForDB($mySource['MsgNormalize']) . " , " . "'" . PrepareValueForDB($mySource['ViewID']) . "', " . "'" . PrepareValueForDB($mySource['DBTableType']) . "', " . " " . PrepareValueForDB($mySource['DBType']) . " , " . "'" . PrepareValueForDB($mySource['DBServer']) . "', " . "'" . PrepareValueForDB($mySource['DBName']) . "', " . "'" . PrepareValueForDB($mySource['DBUser']) . "', " . "'" . PrepareValueForDB($mySource['DBPassword']) . "', " . "'" . PrepareValueForDB($mySource['DBTableName']) . "', " . " " . PrepareValueForDB($mySource['DBEnableRowCounting']) . " " . ")"); } else { DieWithFriendlyErrorMsg(GetAndReplaceLangStr($content['LN_CONVERT_ERROR_SOURCEIMPORT'], $mySource['SourceType'])); } } // Copy DBID! $mySource['DBID'] = DB_ReturnLastInsertID($result); DB_FreeQuery($result); } // --- Check and set DefaultSourceID! if (isset($content['DefaultSourceID']) && strlen($content['DefaultSourceID']) > 0 && isset($CFG['Sources'][$content['DefaultSourceID']]['DBID'])) { // Copy the new DefaultSourceID back! $content['DefaultSourceID'] = $CFG['Sources'][$content['DefaultSourceID']]['DBID']; $CFG['DefaultSourceID'] = $content['DefaultSourceID']; } // --- }
function list_files($directory, $failOnError = true) { $result = array(); if (!($directoryHandler = @opendir($directory))) { if ($failOnError) { DieWithFriendlyErrorMsg("list_directories: directory \"{$directory}\" doesn't exist!"); } else { return null; } } while (false !== ($fileName = @readdir($directoryHandler))) { if (is_file($directory . $fileName) && ($fileName != "." && $fileName != "..")) { @array_push($result, $fileName); } } if (@count($result) === 0) { if ($failOnError) { DieWithFriendlyErrorMsg("list_directories: no files in \"{$directory}\" found!"); } else { return null; } } else { sort($result); return $result; } }
function DebugLDAPErrorAndDie($szErrorMsg, $szLdapFilter) { global $content; // Add extra debug if wanted! if (GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1) { $szErrorMsg .= "</br></br>LDAPBind DN: " . $content['LDAPBindDN'] . "</br>Search Filter: " . $szLdapFilter . "</br><pre>Session Array: </br>" . var_export($_SESSION, true) . "</pre>"; } // USER NOT FOUND DieWithFriendlyErrorMsg($szErrorMsg); }