예제 #1
0
function LoadDataFile($szFileName)
{
    global $content;
    // Lets read the table definitions :)
    $buffer = "";
    $handle = @fopen($szFileName, "r");
    if ($handle === false) {
        RevertOneStep($content['INSTALL_STEP'] - 1, GetAndReplaceLangStr($content['LN_INSTALL_FAILEDREADINGFILE'], $szFileName));
    } else {
        while (!feof($handle)) {
            $buffer .= fgets($handle, 4096);
        }
        fclose($handle);
    }
    // return file buffer!
    return $buffer;
}
                }
            }
            //$fields[SYSLOG_UID]['FieldID']
        } else {
            // This will disable to Main SyslogView and show an error message
            $content['error_occured'] = true;
            $content['error_details'] = GetErrorMessage($res);
            if (isset($extraErrorDescription)) {
                $content['error_details'] .= "\n\n" . GetAndReplaceLangStr($content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
            }
        }
        // Close file!
        $stream->Close();
    } else {
        $content['error_occured'] = true;
        $content['error_details'] = GetAndReplaceLangStr($content['LN_GEN_ERROR_SOURCENOTFOUND'], $currentSourceID);
    }
}
if ($content['error_occured']) {
    // Use JpGraph to display errors!
    $myError = new JpGraphErrObjectImg();
    $myError->SetTitle($content['LN_GEN_ERRORDETAILS']);
    if (GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1) {
        $myError->Raise($content['error_details'] . "\n\nDebug Details: \n" . var_export($content['DEBUGMSG'], true), true);
    } else {
        $myError->Raise($content['error_details'], true);
    }
    // Exit in any case
    exit;
}
// ---
예제 #3
0
 // Process definitions ^^
 if (strlen($totaldbdefs) <= 0) {
     $content['failedstatements'][$content['sql_failed']]['myerrmsg'] = GetAndReplaceLangStr($content['LN_INSTALL_ERRORINVALIDDBFILE'], $content['BASEPATH'] . "include/db_template.txt");
     $content['failedstatements'][$content['sql_failed']]['mystatement'] = "";
     $content['sql_failed']++;
 }
 // Replace stats_ with the custom one ;)
 $totaldbdefs = str_replace("`logcon_", "`" . GetConfigSetting("UserDBPref"), $totaldbdefs);
 // Now split by sql command
 $mycommands = split(";\n", $totaldbdefs);
 //		// check for different linefeed
 //		if ( count($mycommands) <= 1 )
 //			$mycommands = split( ";\n", $totaldbdefs );
 //Still only one? Abort
 if (count($mycommands) <= 1) {
     $content['failedstatements'][$content['sql_failed']]['myerrmsg'] = GetAndReplaceLangStr($content['LN_INSTALL_ERRORINSQLCOMMANDS'], $content['BASEPATH'] . "include/db_template.txt");
     $content['failedstatements'][$content['sql_failed']]['mystatement'] = "";
     $content['sql_failed']++;
 }
 // Append INSERT Statement for Config Table to set the Database Version ^^!
 $mycommands[count($mycommands)] = "INSERT INTO `" . GetConfigSetting("UserDBPref") . "config` (`propname`, `propvalue`, `is_global`) VALUES ('database_installedversion', '" . $content['database_internalversion'] . "', 1)";
 // --- Now execute all commands
 ini_set('error_reporting', E_WARNING);
 // Enable Warnings!
 // Establish DB Connection
 DB_Connect();
 for ($i = 0; $i < count($mycommands); $i++) {
     if (strlen(trim($mycommands[$i])) > 1) {
         $result = DB_Query($mycommands[$i], false);
         if ($result == FALSE) {
             $content['failedstatements'][$content['sql_failed']]['myerrmsg'] = DB_ReturnSimpleErrorMsg();
예제 #4
0
        // Everything was alright, go and check if the entry exists!
        $result = DB_Query("SELECT FieldID FROM " . DB_FIELDS . " WHERE FieldID = '" . $content['FieldID'] . "'");
        $myrow = DB_GetSingleRow($result, true);
        if (!isset($myrow['FieldID'])) {
            // Add custom Field now!
            $sqlquery = "INSERT INTO " . DB_FIELDS . " (FieldID, FieldCaption, FieldDefine, SearchField, FieldAlign, DefaultWidth, FieldType, SearchOnline) \n\t\t\tVALUES (\n\t\t\t\t\t'" . $content['FieldID'] . "', \n\t\t\t\t\t'" . $content['FieldCaption'] . "',\n\t\t\t\t\t'" . $content['FieldDefine'] . "',\n\t\t\t\t\t'" . $content['SearchField'] . "',\n\t\t\t\t\t'" . $content['FieldAlign'] . "', \n\t\t\t\t\t" . $content['DefaultWidth'] . ", \n\t\t\t\t\t" . $content['FieldType'] . ", \n\t\t\t\t\t" . $content['SearchOnline'] . " \n\t\t\t\t\t)";
            $result = DB_Query($sqlquery);
            DB_FreeQuery($result);
            // Do the final redirect
            RedirectResult(GetAndReplaceLangStr($content['LN_FIELDS_HASBEENADDED'], DB_StripSlahes($content['FieldCaption'])), "fields.php");
        } else {
            // Edit the Search Entry now!
            $result = DB_Query("UPDATE " . DB_FIELDS . " SET \n\t\t\t\tFieldCaption = '" . $content['FieldCaption'] . "', \n\t\t\t\tFieldDefine = '" . $content['FieldDefine'] . "', \n\t\t\t\tSearchField = '" . $content['SearchField'] . "', \n\t\t\t\tFieldAlign = '" . $content['FieldAlign'] . "', \n\t\t\t\tDefaultWidth = " . $content['DefaultWidth'] . ", \n\t\t\t\tFieldType = " . $content['FieldType'] . ", \n\t\t\t\tSearchOnline = " . $content['SearchOnline'] . "\n\t\t\t\tWHERE FieldID = '" . $content['FieldID'] . "'");
            DB_FreeQuery($result);
            // Done redirect!
            RedirectResult(GetAndReplaceLangStr($content['LN_FIELDS_HASBEENEDIT'], DB_StripSlahes($content['FieldCaption'])), "fields.php");
        }
    }
}
if (!isset($_POST['op']) && !isset($_GET['op'])) {
    // Default Mode = List Searches
    $content['LISTFIELDS'] = "true";
    // Copy Search array for further modifications
    $content['FIELDS'] = $fields;
    $i = 0;
    // Help counter!
    foreach ($content['FIELDS'] as &$myField) {
        // Allow Delete Operation
        if ($myField['IsInternalField'] && $myField['FieldFromDB']) {
            $myField['AllowDelete'] = true;
            $myField['DELETEIMG'] = $content['MENU_DELETE_FROMDB'];
예제 #5
0
 // --- Process Sources
 $i = 0;
 // Help counter!
 foreach ($content['SOURCES'] as &$mySource) {
     // --- Set Image for Type
     // NonNUMERIC are config files Sources, can not be editied
     if (is_numeric($mySource['ID'])) {
         // Allow EDIT
         $mySource['ActionsAllowed'] = true;
         if ($mySource['userid'] != null) {
             $mySource['SourcesAssignedToImage'] = $content["MENU_ADMINUSERS"];
             $mySource['SourcesAssignedToText'] = $content["LN_GEN_USERONLY"];
         } else {
             if ($mySource['groupid'] != null) {
                 $mySource['SourcesAssignedToImage'] = $content["MENU_ADMINGROUPS"];
                 $mySource['SourcesAssignedToText'] = GetAndReplaceLangStr($content["LN_GEN_GROUPONLYNAME"], $mySource['groupname']);
                 // Check if is ADMIN User, deny if normal user!
                 if (!isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0) {
                     $mySource['ActionsAllowed'] = false;
                 }
             } else {
                 $mySource['SourcesAssignedToImage'] = $content["MENU_GLOBAL"];
                 $mySource['SourcesAssignedToText'] = $content["LN_GEN_GLOBAL"];
                 // Check if is ADMIN User, deny if normal user!
                 if (!isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0) {
                     $mySource['ActionsAllowed'] = false;
                 }
             }
         }
     } else {
         // Disallow EDIT
예제 #6
0
 // Copy Search array for further modifications
 $content['SEARCHES'] = $content['Search'];
 $i = 0;
 // Help counter!
 foreach ($content['SEARCHES'] as &$mySearch) {
     $mySearch['SearchQuery_Display'] = strlen($mySearch['SearchQuery']) > 25 ? substr($mySearch['SearchQuery'], 0, 25) . " ..." : $mySearch['SearchQuery'];
     // Allow EDIT
     $mySearch['ActionsAllowed'] = true;
     // --- Set Image for Type
     if ($mySearch['userid'] != null) {
         $mySearch['SearchTypeImage'] = $content["MENU_ADMINUSERS"];
         $mySearch['SearchTypeText'] = $content["LN_GEN_USERONLY"];
     } else {
         if ($mySearch['groupid'] != null) {
             $mySearch['SearchTypeImage'] = $content["MENU_ADMINGROUPS"];
             $mySearch['SearchTypeText'] = GetAndReplaceLangStr($content["LN_GEN_GROUPONLYNAME"], $mySearch['groupname']);
             // Check if is ADMIN User, deny if normal user!
             if (!isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0) {
                 $mySearch['ActionsAllowed'] = false;
             }
         } else {
             $mySearch['SearchTypeImage'] = $content["MENU_GLOBAL"];
             $mySearch['SearchTypeText'] = $content["LN_GEN_GLOBAL"];
             // Check if is ADMIN User, deny if normal user!
             if (!isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0) {
                 $mySearch['ActionsAllowed'] = false;
             }
         }
     }
     // ---
     // --- Set CSS Class
예제 #7
0
function CheckConfiguredLogStreamSource($myReport, $mySourceID)
{
    global $content, $extraErrorDescription;
    // Get Objectreference to report
    $myReportObj = $myReport["ObjRef"];
    // Handle GET and POST input!
    $content['MSG_WARNING_FORMURL'] = $_SERVER['SCRIPT_NAME'] . "?";
    $content['MSG_CHECK_URL'] = $_SERVER['SCRIPT_NAME'] . "?";
    foreach ($_GET as $varname => $varvalue) {
        // All variables!
        $content['MSG_WARNING_FORMURL'] .= $varname . "=" . $varvalue . "&";
        // Skip the Optimize variable!
        if (strpos($varname, "optimize") === false) {
            $content['MSG_CHECK_URL'] .= $varname . "=" . $varvalue . "&";
        }
    }
    foreach ($_POST as $varname => $varvalue) {
        $content['POST_VARIABLES'][] = array("varname" => $varname, "varvalue" => $varvalue);
    }
    // Append Force Optimice Paramater
    $content['MSG_CHECK_URL'] .= "forcecheckoptimize=true";
    // Check if optimize variable is set!
    if (isset($_GET['optimize'])) {
        // Check what we have to do
        if ($_GET['optimize'] == "addfields") {
            // This will create all INDEXES we need for this logstream!
            $res = $myReportObj->CreateMissingLogStreamFields($mySourceID);
            if ($res != SUCCESS) {
                $content['ISERROR'] = true;
                $content['ERROR_MSG'] = GetAndReplaceLangStr($content['LN_REPORTS_ERROR_FAILED_ADDING_FIELDS'], $content['SOURCES'][$mySourceID]['Name'], $res);
                if (isset($extraErrorDescription)) {
                    $content['ERROR_MSG'] .= "<br><br>" . GetAndReplaceLangStr($content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
                }
            }
            // Show information in performance warning area
            $content['ISSOURCENOTOPTIMIZED'] = true;
            $content['MSG_WARNING_TITLE'] = $content['LN_REPORTS_FIELDS_CREATED'];
            $content['MSG_WARNING_CLASS'] = 'PriorityNotice';
            $content['MSG_WARNING_DETAILS'] = GetAndReplaceLangStr($content['LN_REPORTS_FIELDS_CREATED_SUCCESS'], $content['SOURCES'][$mySourceID]['Name']);
            $content['MSG_WARNING_SUBMITFORM'] = "false";
            // return result
            return $res;
        } else {
            if ($_GET['optimize'] == "indexes") {
                // This will create all INDEXES we need for this logstream!
                $res = $myReportObj->CreateLogStreamIndexes($mySourceID);
                if ($res != SUCCESS) {
                    $content['ISERROR'] = true;
                    $content['ERROR_MSG'] = GetAndReplaceLangStr($content['LN_REPORTS_ERROR_FAILED_CREATE_INDEXES'], $content['SOURCES'][$mySourceID]['Name'], $res);
                    if (isset($extraErrorDescription)) {
                        $content['ERROR_MSG'] .= "<br><br>" . GetAndReplaceLangStr($content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
                    }
                }
                // Show information in performance warning area
                $content['ISSOURCENOTOPTIMIZED'] = true;
                $content['MSG_WARNING_TITLE'] = $content['LN_REPORTS_INDEX_CREATED'];
                $content['MSG_WARNING_CLASS'] = 'PriorityNotice';
                $content['MSG_WARNING_DETAILS'] = GetAndReplaceLangStr($content['LN_REPORTS_INDEX_CREATED_SUCCESS'], $content['SOURCES'][$mySourceID]['Name']);
                $content['MSG_WARNING_SUBMITFORM'] = "false";
                // return result
                return $res;
            } else {
                if ($_GET['optimize'] == "trigger") {
                    // This will create all INDEXES we need for this logstream!
                    $res = $myReportObj->CreateLogStreamTrigger($mySourceID);
                    if ($res != SUCCESS) {
                        $content['ISERROR'] = true;
                        $content['ERROR_MSG'] = GetAndReplaceLangStr($content['LN_REPORTS_ERROR_FAILED_CREATE_TRIGGER'], $content['SOURCES'][$mySourceID]['Name'], $res);
                        if (isset($extraErrorDescription)) {
                            $content['ERROR_MSG'] .= "<br><br>" . GetAndReplaceLangStr($content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
                        }
                    } else {
                        // Show information in performance warning area
                        $content['ISSOURCENOTOPTIMIZED'] = true;
                        $content['MSG_WARNING_TITLE'] = $content['LN_REPORTS_TRIGGER_CREATED'];
                        $content['MSG_WARNING_CLASS'] = 'PriorityNotice';
                        $content['MSG_WARNING_DETAILS'] = GetAndReplaceLangStr($content['LN_REPORTS_TRIGGER_CREATED_SUCCESS'], $content['SOURCES'][$mySourceID]['Name']);
                        $content['MSG_WARNING_SUBMITFORM'] = "false";
                    }
                    // return result
                    return $res;
                } else {
                    if ($_GET['optimize'] == "checksum") {
                        // This will create all INDEXES we need for this logstream!
                        $res = $myReportObj->ChangeChecksumFieldUnsigned($mySourceID);
                        if ($res != SUCCESS) {
                            $content['ISERROR'] = true;
                            $content['ERROR_MSG'] = GetAndReplaceLangStr($content['LN_REPORTS_ERROR_FAILED_CHANGE_CHECKSUM'], $content['SOURCES'][$mySourceID]['Name'], $res);
                            if (isset($extraErrorDescription)) {
                                $content['ERROR_MSG'] .= "<br><br>" . GetAndReplaceLangStr($content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
                            }
                        } else {
                            // Show information in performance warning area
                            $content['ISSOURCENOTOPTIMIZED'] = true;
                            $content['MSG_WARNING_TITLE'] = $content['LN_REPORTS_CHECKSUM_CHANGED'];
                            $content['MSG_WARNING_CLASS'] = 'PriorityNotice';
                            $content['MSG_WARNING_DETAILS'] = GetAndReplaceLangStr($content['LN_REPORTS_CHECKSUM_CHANGED_SUCCESS'], $content['SOURCES'][$mySourceID]['Name']);
                            $content['MSG_WARNING_SUBMITFORM'] = "false";
                        }
                        // return result
                        return $res;
                    }
                }
            }
        }
    }
    // Use SESSION to check if Source needs to be checked for optimization
    $bForceCheck = false;
    if (!isset($_SESSION['Sources'][$mySourceID]['optimized']) || $_SESSION['Sources'][$mySourceID]['optimized'] == false || isset($_GET['forcecheckoptimize']) && $_GET['forcecheckoptimize'] == "true") {
        // Set Checking to true!
        $bForceCheck = true;
    }
    // Lets see if we need to check
    if ($bForceCheck) {
        // Run checks
        $res = $myReportObj->CheckLogStreamSource($mySourceID);
        if ($res != SUCCESS) {
            // Current Logstream Source is not optimized! Show to user!
            $content['ISSOURCENOTOPTIMIZED'] = true;
            if ($res == ERROR_DB_DBFIELDNOTFOUND) {
                $content['MSG_WARNING_TITLE'] = $content['LN_REPORTS_PERFORMANCE_WARNING'];
                $content['MSG_WARNING_CLASS'] = 'PriorityWarning';
                $content['MSG_WARNING_DETAILS'] = GetAndReplaceLangStr($content['LN_REPORTS_ADD_MISSINGFIELDS'], $content['SOURCES'][$mySourceID]['Name']);
                $content['MSG_WARNING_SUBMITFORM'] = "true";
                $content['MSG_WARNING_FORMURL'] .= "optimize=addfields";
                // Addmissing fields
            } else {
                if ($res == ERROR_DB_INDEXESMISSING) {
                    $content['MSG_WARNING_TITLE'] = $content['LN_REPORTS_PERFORMANCE_WARNING'];
                    $content['MSG_WARNING_CLASS'] = 'PriorityWarning';
                    $content['MSG_WARNING_DETAILS'] = GetAndReplaceLangStr($content['LN_REPORTS_OPTIMIZE_INDEXES'], $content['SOURCES'][$mySourceID]['Name']);
                    $content['MSG_WARNING_SUBMITFORM'] = "true";
                    $content['MSG_WARNING_FORMURL'] .= "optimize=indexes";
                    // Add missing INDEXES
                } else {
                    if ($res == ERROR_DB_TRIGGERMISSING) {
                        $content['MSG_WARNING_TITLE'] = $content['LN_REPORTS_PERFORMANCE_WARNING'];
                        $content['MSG_WARNING_CLASS'] = 'PriorityWarning';
                        $content['MSG_WARNING_DETAILS'] = GetAndReplaceLangStr($content['LN_REPORTS_OPTIMIZE_TRIGGER'], $content['SOURCES'][$mySourceID]['Name']);
                        $content['MSG_WARNING_SUBMITFORM'] = "true";
                        $content['MSG_WARNING_FORMURL'] .= "optimize=trigger";
                        // Add missing TRIGGERS
                    } else {
                        if ($res == ERROR_DB_CHECKSUMERROR) {
                            $content['MSG_WARNING_TITLE'] = $content['LN_REPORTS_PERFORMANCE_WARNING'];
                            $content['MSG_WARNING_CLASS'] = 'PriorityWarning';
                            $content['MSG_WARNING_DETAILS'] = GetAndReplaceLangStr($content['LN_REPORTS_CHANGE_CHECKSUM'], $content['SOURCES'][$mySourceID]['Name']);
                            $content['MSG_WARNING_SUBMITFORM'] = "true";
                            $content['MSG_WARNING_FORMURL'] .= "optimize=checksum";
                            // Change Checksum field!
                        } else {
                            $content['MSG_WARNING_TITLE'] = $content['LN_REPORTS_SOURCE_WARNING'];
                            $content['MSG_WARNING_CLASS'] = 'PriorityWarning';
                            $content['MSG_WARNING_DETAILS'] = GetAndReplaceLangStr($content['LN_REPORTS_ERROR_FAILED_SOURCE_CHECK'], $content['SOURCES'][$mySourceID]['Name'], GetErrorMessage($res));
                            $content['MSG_WARNING_SUBMITFORM'] = "true";
                            $content['MSG_WARNING_FORMURL'] .= "forcecheckoptimize=true";
                            // Change Checksum field!
                        }
                    }
                }
            }
        } else {
            // Check was successfull! Set Checked Property in LogStream Source
            $_SESSION['Sources'][$mySourceID]['optimized'] = true;
        }
    }
}
function CheckLDAPUserLogin($username, $password)
{
    global $content;
    // Create LDAP Searchfilter
    $ldap_filter = '(&' . $content['LDAPSearchFilter'] . '(' . $content['LDAPUidAttribute'] . '=' . $username . '))';
    // Get LDAP Connection
    $ldapConn = DoLDAPConnect();
    if ($ldapConn) {
        if (!DoLDAPBind($ldapConn)) {
            if (GetConfigSetting("DebugUserLogin", 0) == 1) {
                // Die with error
                DebugLDAPErrorAndDie(GetAndReplaceLangStr($content['LN_LOGIN_LDAP_USERBINDFAILED'], $content['LDAPBindDN'], ldap_err2str(ldap_errno($ldapConn))), $ldap_filter);
            }
            return false;
        }
    } else {
        if (GetConfigSetting("DebugUserLogin", 0) == 1) {
            // Die with error
            DebugLDAPErrorAndDie(GetAndReplaceLangStr($content['LN_LOGIN_LDAP_SERVERFAILED'], $content['LDAPServer'] . ":" . $content['LDAPPort'], ldap_err2str(ldap_errno($ldapConn))), $ldap_filter);
        }
        // return false in this case
        return false;
    }
    // Search for the user
    if (!($r = @ldap_search($ldapConn, $content['LDAPBaseDN'], $ldap_filter, array("uid", "cn", "localentryid", "userpassword")))) {
        if (GetConfigSetting("DebugUserLogin", 0) == 1) {
            // Die with error
            DebugLDAPErrorAndDie(GetAndReplaceLangStr($content['LN_LOGIN_LDAP_USERCOULDNOTLOGIN'], $username, ldap_err2str(ldap_errno($ldapConn))), $ldap_filter);
        }
        // return false in this case
        return false;
    }
    $info = ldap_get_entries($ldapConn, $r);
    if (!$info || $info["count"] != 1) {
        if (GetConfigSetting("DebugUserLogin", 0) == 1) {
            // Die with error
            DebugLDAPErrorAndDie(GetAndReplaceLangStr($content['LN_LOGIN_LDAP_USERNOTFOUND'], $username), $ldap_filter);
        }
        // return false in this case
        return false;
    }
    // now we have the user data. Do a bind to check for his password
    if (!($r = @ldap_bind($ldapConn, $info[0]['dn'], $password))) {
        if (GetConfigSetting("DebugUserLogin", 0) == 1) {
            // Die with error
            DebugLDAPErrorAndDie(GetAndReplaceLangStr($content['LN_LOGIN_LDAP_PASSWORDFAIL'], $username), $ldap_filter);
        }
        // return false in this case
        return false;
    }
    // for the moment when a user logs in from LDAP, create it in the DB.
    // then the prefs and group management is done in the DB and we don't rewrite the whole Loganalyzer code…
    //
    // added by czhujer
    //
    $ldapadmingroup = "cn=loganalyzeradminusers,cn=groups,cn=accounts,dc=someorg,dc=en";
    if (LdapCheckGroup($ldapConn, $info[0]['dn'], $ldapadmingroup)) {
        $ldapuser_is_admin = 1;
        $ldapuser_is_readonly = 0;
        //echo "You're (".$info[0]['dn'].") member of \"".$ldapadmingroup."\"";
    } else {
        //echo "You're (".$info[0]['dn'].") not member of \"".$ldapadmingroup."\"";
        $ldapuser_admin = 0;
        $ldapuser_is_readonly = 1;
    }
    /* debug   
       echo "<pre>";  
       print_r($info);  
       echo "</pre>";  
       DebugLDAPErrorAndDie("" , $ldap_filter );   
       */
    //
    // end of czhujer modify
    //
    /* DB_RemoveBadChars() needs to be done here to maintain backwards compatibility even if it is not needed here*/
    $md5pass = md5(DB_RemoveBadChars($password));
    // check if the user already exist
    $sqlquery = "SELECT * FROM `" . DB_USERS . "` WHERE username = '******'";
    $result = DB_Query($sqlquery);
    $myrow = DB_GetSingleRow($result, true);
    if (!isset($myrow['is_admin'])) {
        // Create User | use password to create MD5 Hash, so technically the user could login without LDAP as well
        //$sqlcmd = "INSERT INTO `" . DB_USERS . "` (username, password, is_admin, is_readonly) VALUES ('" . $username . "', '" . $md5pass . "', 0, 1)";
        //modified by czhujer
        $sqlcmd = "INSERT INTO `" . DB_USERS . "` (username, password, is_admin, is_readonly) VALUES " . "('" . $username . "', '" . $md5pass . "', " . intval($ldapuser_is_admin) . ", " . intval($ldapuser_is_readonly) . ")";
        $result = DB_Query($sqlcmd);
        DB_FreeQuery($result);
        $myrow['is_admin'] = 0;
        $myrow['last_login'] = 0;
        $myrow['is_readonly'] = 1;
    }
    // Construct Row and return
    $myrowfinal['username'] = $username;
    $myrowfinal['password'] = $md5pass;
    $myrowfinal['dn'] = $info[0]['dn'];
    if (isset($myrow['ID'])) {
        $myrowfinal['ID'] = $myrow['ID'];
    } else {
        $myrowfinal['ID'] = DB_ReturnLastInsertID();
    }
    // Get from last insert!
    $myrowfinal['is_admin'] = $myrow['is_admin'];
    $myrowfinal['is_readonly'] = $myrow['is_readonly'];
    $myrowfinal['last_login'] = $myrow['last_login'];
    return $myrowfinal;
}
예제 #9
0
 /**
  * Verify if the file exists!
  *
  * @return integer Error state
  */
 public function Verify()
 {
     global $content;
     // --- Check if Filename is within allowed directories!
     $szFileDirName = dirname($this->_logStreamConfigObj->FileName) . '/';
     $bIsAllowedDir = false;
     foreach ($content['DiskAllowed'] as $szAllowedDir) {
         if (strpos($szFileDirName, $szAllowedDir) !== FALSE) {
             $bIsAllowedDir = true;
             break;
         }
     }
     if (!$bIsAllowedDir) {
         global $extraErrorDescription;
         $extraErrorDescription = GetAndReplaceLangStr($content['LN_ERROR_PATH_NOT_ALLOWED_EXTRA'], $this->_logStreamConfigObj->FileName, implode(", ", $content['DiskAllowed']));
         return ERROR_PATH_NOT_ALLOWED;
     }
     // ---
     // Check if file exists!
     if (!file_exists($this->_logStreamConfigObj->FileName)) {
         return ERROR_FILE_NOT_FOUND;
     }
     // Check if file is readable!
     if (!is_readable($this->_logStreamConfigObj->FileName)) {
         return ERROR_FILE_NOT_READABLE;
     }
     // reached this point means success ;)!
     return SUCCESS;
 }
예제 #10
0
// --- CONTENT Vars
if (isset($_GET['redir'])) {
    // Only automatically redirect if above 0
    if ($content['REDIRSECONDS'] > 0) {
        $content['EXTRA_METATAGS'] = '<meta HTTP-EQUIV="REFRESH" CONTENT="' . $content['REDIRSECONDS'] . '; URL=' . urldecode($_GET['redir']) . '">';
    }
    // Set redir string
    $content['SZREDIR'] = urldecode($_GET['redir']);
} else {
    $_GET['redir'] = "index.php";
}
if (isset($_GET['msg'])) {
    $content['SZMSG'] = DB_StripSlahes($_GET['msg']);
} else {
    $content['SZMSG'] = $content["LN_ADMIN_UNKNOWNSTATE"];
}
if ($content['REDIRSECONDS'] > 0) {
    $content['TITLE'] = "LogAnalyzer - Redirecting to '" . $content['SZREDIR'] . "' in " . $content['REDIRSECONDS'] . " seconds";
    // Title of the Page
    $content['LN_ADMIN_RESULTLINK'] = GetAndReplaceLangStr($content['LN_ADMIN_RESULTREDIRECT'], $content['SZREDIR'], $content['REDIRSECONDS']);
} else {
    $content['TITLE'] = "LogAnalyzer - Redirecting to '" . $content['SZREDIR'] . "'";
    // Title of the Page
    $content['LN_ADMIN_RESULTLINK'] = GetAndReplaceLangStr($content['LN_ADMIN_RESULTCLICK'], $content['SZREDIR']);
}
// ---
// --- Parsen and Output
InitTemplateParser();
$page->parser($content, "admin/result.html");
$page->output();
// ---
예제 #11
0
 // --- Process Sources
 $i = 0;
 // Help counter!
 foreach ($content['CHARTS'] as &$myChart) {
     // --- Set Image for Type
     // NonNUMERIC are config files Sources, can not be editied
     if (is_numeric($myChart['ID'])) {
         // Allow EDIT
         $myChart['ActionsAllowed'] = true;
         if ($myChart['userid'] != null) {
             $myChart['ChartAssignedToImage'] = $content["MENU_ADMINUSERS"];
             $myChart['ChartAssignedToText'] = $content["LN_GEN_USERONLY"];
         } else {
             if ($myChart['groupid'] != null) {
                 $myChart['ChartAssignedToImage'] = $content["MENU_ADMINGROUPS"];
                 $myChart['ChartAssignedToText'] = GetAndReplaceLangStr($content["LN_GEN_GROUPONLYNAME"], $myChart['groupname']);
                 // Check if is ADMIN User, deny if normal user!
                 if (!isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0) {
                     $myChart['ActionsAllowed'] = false;
                 }
             } else {
                 $myChart['ChartAssignedToImage'] = $content["MENU_GLOBAL"];
                 $myChart['ChartAssignedToText'] = $content["LN_GEN_GLOBAL"];
                 // Check if is ADMIN User, deny if normal user!
                 if (!isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0) {
                     $myChart['ActionsAllowed'] = false;
                 }
             }
         }
     } else {
         // Disallow EDIT
예제 #12
0
$content['helplinksenabled'] = true;
// Loop through all Sources
$i = 0;
foreach ($content['Sources'] as $mySource) {
    $myHelpLink['SourceName'] = $mySource['Name'];
    $myHelpLink['MsgUrl'] = $content['BASEPATH'] . "index.php?filter=" . urlencode($content['oracle_query']) . "&search=Search&sourceid=" . $mySource['ID'];
    //	$myHelpLink['MsgDisplayName'] = GetAndReplaceLangStr( $content['LN_ORACLE_SEARCHINFIELD'], "Message" );
    $myHelpLink['SourceUrl'] = $content['BASEPATH'] . "index.php?filter=" . urlencode("source:=" . $content['oracle_query']) . "&search=Search&sourceid=" . $mySource['ID'];
    //	$myHelpLink['SourceDisplayName'] = GetAndReplaceLangStr( $content['LN_ORACLE_SEARCHINFIELD'], "Source" );
    // --- Set CSS Class
    if ($i % 2 == 0) {
        $myHelpLink['cssclass'] = "line1";
    } else {
        $myHelpLink['cssclass'] = "line2";
    }
    $i++;
    // ---
    // Add to help Link array!
    $content['HelpLinks'][] = $myHelpLink;
}
// ---
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
// Append custom title part!
$content['TITLE'] .= GetAndReplaceLangStr($content['LN_ORACLE_TITLE'], urlencode($content['oracle_query']));
// --- END CREATE TITLE
// --- Parsen and Output
InitTemplateParser();
$page->parser($content, "asktheoracle.html");
$page->output();
// ---
예제 #13
0
 $content['VIEWS'] = $content['Views'];
 // --- Process Views
 $i = 0;
 // Help counter!
 foreach ($content['VIEWS'] as &$myView) {
     // So internal Views can not be edited but seen
     if (is_numeric($myView['ID'])) {
         $myView['ActionsAllowed'] = true;
         // --- Set Image for Type
         if ($myView['userid'] != null) {
             $myView['ViewTypeImage'] = $content["MENU_ADMINUSERS"];
             $myView['ViewTypeText'] = $content["LN_GEN_USERONLY"];
         } else {
             if ($myView['groupid'] != null) {
                 $myView['ViewTypeImage'] = $content["MENU_ADMINGROUPS"];
                 $myView['ViewTypeText'] = GetAndReplaceLangStr($content["LN_GEN_GROUPONLYNAME"], $myView['groupname']);
                 // Check if is ADMIN User, deny if normal user!
                 if (!isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0) {
                     $myView['ActionsAllowed'] = false;
                 }
             } else {
                 $myView['ViewTypeImage'] = $content["MENU_GLOBAL"];
                 $myView['ViewTypeText'] = $content["LN_GEN_GLOBAL"];
                 // Check if is ADMIN User, deny if normal user!
                 if (!isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0) {
                     $myView['ActionsAllowed'] = false;
                 }
             }
         }
         // ---
     } else {
예제 #14
0
function CleanData($optParam1, $optParam2, $optParam3, $optParam4)
{
    global $content, $gl_root_path;
    // Get Source reference!
    $mySource = $content['Sources'][$content['SOURCEID']];
    // Check Source Type
    if ($mySource['SourceType'] == SOURCE_DB || $mySource['SourceType'] == SOURCE_PDO) {
        // Include LogStream facility
        include $gl_root_path . 'classes/logstream.class.php';
        //Debug Output
        PrintHTMLDebugInfo(DEBUG_INFO, "CleanData", GetAndReplaceLangStr($content["LN_CMD_CLEANINGDATAFOR"], $mySource['Name']));
        // Create LogStream Object
        $stream = $mySource['ObjRef']->LogStreamFactory($mySource['ObjRef']);
        $res = $stream->Verify();
        if ($res == SUCCESS) {
            // Gather Database Stats
            $content['ROWCOUNT'] = $stream->GetLogStreamTotalRowCount();
            if (isset($content['ROWCOUNT'])) {
                //Debug Output
                PrintHTMLDebugInfo(DEBUG_INFO, "CleanData", GetAndReplaceLangStr($content["LN_CMD_ROWSFOUND"], $content['ROWCOUNT'], $mySource['Name']));
                if ($optParam1 != NULL) {
                    if ($optParam1 == "all") {
                        $timestamp = 0;
                    } else {
                        if ($optParam1 == "olderthan" && $optParam2 != NULL) {
                            // Take current time and subtract Seconds
                            $nSecondsSubtract = intval($optParam2);
                            $timestamp = time() - $nSecondsSubtract;
                        } else {
                            if ($optParam1 == "date" && $optParam2 != NULL && $optParam3 != NULL && $optParam4 != NULL) {
                                // Generate Timestamp
                                $timestamp = mktime(0, 0, 0, intval($optParam2), intval($optParam3), intval($optParam4));
                            } else {
                                // Print error and die!
                                DieWithErrorMsg($content["LN_CMD_WRONGSUBOPORMISSING"]);
                            }
                        }
                    }
                    // Continue with delete only if $timestamp is set!
                    if (isset($timestamp)) {
                        //Debug Output
                        PrintHTMLDebugInfo(DEBUG_INFO, "CleanData", GetAndReplaceLangStr($content["LN_CMD_DELETINGOLDERTHEN"], date("Y-m-d", $timestamp)));
                        // Now perform the data cleanup!
                        $content['affectedrows'] = $stream->CleanupLogdataByDate($timestamp);
                        if (isset($content['affectedrows'])) {
                            //Debug Output
                            PrintHTMLDebugInfo(DEBUG_INFO, "CleanData", GetAndReplaceLangStr($content["LN_CMD_DELETEDROWS"], $content['affectedrows']));
                        } else {
                            // Print error and die!
                            DieWithErrorMsg(GetAndReplaceLangStr($content["LN_CMD_FAILEDTOCLEANDATA"], $mySource['Name']));
                        }
                    }
                } else {
                    // Print error and die!
                    DieWithErrorMsg($content["LN_CMD_SUBPARAM1MISSING"]);
                }
            } else {
                // Print error and die!
                DieWithErrorMsg(GetAndReplaceLangStr($content["LN_CMD_COULDNOTGETROWCOUNT"], $mySource['Name']));
            }
        } else {
            // Print error and die!
            $szErroMsg = GetAndReplaceLangStr($content["LN_SOURCES_ERROR_WITHINSOURCE"], $mySource['Name'], GetErrorMessage($res));
            if (isset($extraErrorDescription)) {
                $szErroMsg .= "\r\n\r\n" . GetAndReplaceLangStr($content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
            }
            DieWithErrorMsg($szErroMsg);
        }
    } else {
        // Print error and die!
        DieWithErrorMsg(GetAndReplaceLangStr($content["LN_SOURCES_ERROR_NOCLEARSUPPORT"], $content['SOURCEID']));
    }
}
예제 #15
0
                                    $sqlquery = "INSERT INTO " . DB_FIELDS . " (FieldID, FieldCaption, FieldDefine, SearchField, FieldAlign, DefaultWidth, FieldType, SearchOnline) \n\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t'" . $myField['FieldID'] . "', \n\t\t\t\t\t\t\t\t\t'" . $myField['FieldCaption'] . "',\n\t\t\t\t\t\t\t\t\t'" . $myField['FieldDefine'] . "',\n\t\t\t\t\t\t\t\t\t'" . $myField['SearchField'] . "',\n\t\t\t\t\t\t\t\t\t'" . $myField['FieldAlign'] . "', \n\t\t\t\t\t\t\t\t\t" . $myField['DefaultWidth'] . ", \n\t\t\t\t\t\t\t\t\t" . $myField['FieldType'] . ", \n\t\t\t\t\t\t\t\t\t" . $myField['SearchOnline'] . " \n\t\t\t\t\t\t\t\t\t)";
                                    $result = DB_Query($sqlquery);
                                    DB_FreeQuery($result);
                                    // increment counter
                                    $addedFields++;
                                }
                            }
                            // Do the final redirect
                            RedirectResult(GetAndReplaceLangStr($content['LN_PARSERS_ERROR_HASBEENADDED'], $myParser['DisplayName'], $addedFields), "parsers.php");
                        } else {
                            $content['ISERROR'] = true;
                            $content['ERROR_MSG'] = GetAndReplaceLangStr($content['LN_PARSERS_ERROR_NOFIELDS'], $content['ParserID']);
                        }
                    } else {
                        $content['ISERROR'] = true;
                        $content['ERROR_MSG'] = GetAndReplaceLangStr($content['LN_PARSERS_ERROR_IDNOTFOUND'], $content['ParserID']);
                    }
                } else {
                    $content['ISERROR'] = true;
                    $content['ERROR_MSG'] = $content['LN_PARSERS_ERROR_INVALIDID'];
                }
            }
        }
    }
}
// Default mode!
if (!isset($_POST['op']) && !isset($_GET['op'])) {
    if (isset($content['PARSERS'])) {
        // Default Mode = List Searches
        $content['LISTPARSERS'] = "true";
        $i = 0;
예제 #16
0
function AddOnClickMenu(&$fieldGridItem, $fieldType, $FieldID)
{
    global $content, $fields, $myStrCharLimit;
    // Set OnClick Menu for SYSLOG_SYSLOGTAG
    $fieldGridItem['hasbuttons'] = true;
    // Set Field Caption
    if (isset($content['fields'][$FieldID]['FieldCaption']) && strlen($content['fields'][$FieldID]['FieldCaption']) > 0) {
        $szFieldDisplayName = $content['fields'][$FieldID]['FieldCaption'];
    } else {
        $szFieldDisplayName = $FieldID;
    }
    // Set FieldSearch Value
    if ($fieldType == FILTER_TYPE_STRING && isset($fieldGridItem['encodedfieldvalue'])) {
        $szEncodedFieldValue = urlencode($fieldGridItem['encodedfieldvalue']);
    } else {
        $szEncodedFieldValue = $fieldGridItem['fieldvalue'];
    }
    // Set FieldSearchName
    if (isset($fields[$FieldID]['SearchField'])) {
        $szSearchFieldName = $fields[$FieldID]['SearchField'];
    } else {
        $szSearchFieldName = $FieldID;
    }
    // Menu Option to append filter
    if (strlen($content['searchstr']) > 0) {
        $fieldGridItem['buttons'][] = array('ButtonUrl' => '?filter=' . urlencode($content['searchstr']) . '+' . $szSearchFieldName . '%3A%3D' . $szEncodedFieldValue . '&search=Search' . $content['additional_url_sourceonly'], 'ButtonTarget' => '_top', 'ButtonAppendUrl' => true, 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_ADDTOFILTER'], $fieldGridItem['fieldvalue']), 'IconSource' => $content['MENU_BULLET_GREEN']);
        $fieldGridItem['buttons'][] = array('ButtonUrl' => '?filter=' . urlencode($content['searchstr']) . '+' . $szSearchFieldName . '%3A-%3D' . $szEncodedFieldValue . '&search=Search' . $content['additional_url_sourceonly'], 'ButtonTarget' => '_top', 'ButtonAppendUrl' => true, 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_EXCLUDEFILTER'], $fieldGridItem['fieldvalue']), 'IconSource' => $content['MENU_BULLET_GREEN']);
    }
    // More Menu entries
    $fieldGridItem['buttons'][] = array('ButtonUrl' => '?filter=' . $szSearchFieldName . '%3A%3D' . $szEncodedFieldValue . '&search=Search' . $content['additional_url_sourceonly'], 'ButtonTarget' => '_top', 'ButtonAppendUrl' => true, 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $fieldGridItem['fieldvalue']), 'IconSource' => $content['MENU_BULLET_BLUE']);
    $fieldGridItem['buttons'][] = array('ButtonUrl' => '?filter=' . $szSearchFieldName . '%3A-%3D' . $szEncodedFieldValue . '&search=Search' . $content['additional_url_sourceonly'], 'ButtonTarget' => '_top', 'ButtonAppendUrl' => true, 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_SHOWALLBUT'], $fieldGridItem['fieldvalue']), 'IconSource' => $content['MENU_BULLET_BLUE']);
    // Add Online Search Button
    if (isset($fields[$FieldID]['SearchOnline']) && $fields[$FieldID]['SearchOnline'] && strlen($fieldGridItem['fieldvalue']) > 0) {
        $fieldGridItem['buttons'][] = array('ButtonUrl' => 'http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=' . $FieldID . '&q=' . $szEncodedFieldValue, 'ButtonTarget' => '_top', 'ButtonAppendUrl' => true, 'DisplayName' => $content['LN_VIEW_SEARCHFOR'] . " " . $szFieldDisplayName . " '" . $fieldGridItem['fieldvalue'] . "'", 'IconSource' => $content['MENU_NETWORK']);
        if (GetConfigSetting("InlineOnlineSearchIcons", 1, CFGLEVEL_USER) == 1) {
            // Enable SearchOnline Icon
            $fieldGridItem['searchonline'] = true;
            $fieldGridItem['SearchOnlineUrl'] = 'http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=' . $FieldID . '&q=' . $szEncodedFieldValue;
        }
    }
    // Search for links within the fieldcontent!
    if ($fieldType == FILTER_TYPE_STRING && preg_match("#([\\w]+?://[\\w\\#\$%&~/.\\-;:=,?@\\[\\]+]*)#is", $fieldGridItem['rawfieldvalue'], $szLink) >= 1) {
        $fieldGridItem['buttons'][] = array('ButtonUrl' => $szLink[0], 'ButtonTarget' => '_blank', 'ButtonAppendUrl' => false, 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_VISITLINK'], strlen($szLink[0]) > $myStrCharLimit ? substr($szLink[0], 0, $myStrCharLimit) . "..." : $szLink[0]), 'IconSource' => $content['MENU_NETWORK']);
    }
}
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'];
    }
    // ---
}
예제 #18
0
                                                } else {
                                                    // Report error!
                                                    $content['ISEDITORNEWDBMP'] = false;
                                                    $content['ISERROR'] = true;
                                                    $content['ERROR_MSG'] = GetAndReplaceLangStr($content['LN_DBMP_ERROR_MISSINGFIELDNAME'], $myColKey);
                                                    // Abort loop
                                                    break;
                                                }
                                            }
                                            // Only perform if no error occured
                                            if (!isset($content['ISERROR'])) {
                                                // Edit the Search Entry now!
                                                $result = DB_Query("UPDATE " . DB_MAPPINGS . " SET \n\t\t\t\t\t\t\t\tDisplayName = '" . $content['DisplayName'] . "', \n\t\t\t\t\t\t\t\tMappings = '" . $content['SUBMAPPINGS'] . "' \n\t\t\t\t\t\t\t\tWHERE ID = " . $content['DBMPID']);
                                                DB_FreeQuery($result);
                                                // Done redirect!
                                                RedirectResult(GetAndReplaceLangStr($content['LN_DBMP_HASBEENEDIT'], DB_StripSlahes($content['DisplayName'])), "dbmappings.php");
                                            }
                                        } else {
                                            $content['ISERROR'] = true;
                                            $content['ERROR_MSG'] = $content['LN_DBMP_ERROR_NOCOLUMNS'];
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
예제 #19
0
 if (isset($_GET['op'])) {
     if ($_GET['op'] == "upgrade") {
         // Lets start the uodating!
         $content['UPGRADE_RUNNING'] = "1";
         $content['sql_sucess'] = 0;
         $content['sql_failed'] = 0;
         $totaldbdefs = "";
         $tblPref = GetConfigSetting("UserDBPref", "logcon");
         // +1 so we start at the right DB Version!
         for ($i = $content['database_installedversion'] + 1; $i <= $content['database_internalversion']; $i++) {
             $myfilename = "db_update_v" . $i . ".txt";
             // Lets read the table definitions :)
             $handle = @fopen($content['BASEPATH'] . "include/" . $myfilename, "r");
             if ($handle === false) {
                 $content['ISERROR'] = "true";
                 $content['ERROR_MSG'] = GetAndReplaceLangStr($content['LN_DBUPGRADE_DBFILENOTFOUND'], $myfilename);
             } else {
                 while (!feof($handle)) {
                     $buffer = fgets($handle, 4096);
                     $pos = strpos($buffer, "--");
                     if ($pos === false) {
                         $totaldbdefs .= $buffer;
                     } else {
                         if ($pos > 2 && strlen(trim($buffer)) > 1) {
                             $totaldbdefs .= $buffer;
                         }
                     }
                 }
                 fclose($handle);
             }
         }
function GetErrorMessage($errorCode)
{
    global $content;
    switch ($errorCode) {
        case ERROR_FILE_NOT_FOUND:
            return $content['LN_ERROR_FILE_NOT_FOUND'];
        case ERROR_FILE_NOT_READABLE:
            return $content['LN_ERROR_FILE_NOT_READABLE'];
        case ERROR_FILE_EOF:
            return $content['LN_ERROR_FILE_EOF'];
        case ERROR_FILE_BOF:
            return $content['LN_ERROR_FILE_BOF'];
        case ERROR_FILE_CANT_CLOSE:
            return $content['LN_ERROR_FILE_CANT_CLOSE'];
        case ERROR_UNDEFINED:
            return $content['LN_ERROR_UNDEFINED'];
        case ERROR_EOS:
            return $content['LN_ERROR_EOS'];
        case ERROR_NOMORERECORDS:
            return $content['LN_ERROR_NORECORDS'];
        case ERROR_FILTER_NOT_MATCH:
            return $content['LN_ERROR_FILTER_NOT_MATCH'];
        case ERROR_DB_CONNECTFAILED:
            return $content['LN_ERROR_DB_CONNECTFAILED'];
        case ERROR_DB_CANNOTSELECTDB:
            return $content['LN_ERROR_DB_CANNOTSELECTDB'];
        case ERROR_DB_QUERYFAILED:
            return isset($content['LN_ERROR_DB_QUERYFAILED']) ? $content['LN_ERROR_DB_QUERYFAILED'] : $errorCode;
        case ERROR_DB_NOPROPERTIES:
            return $content['LN_ERROR_DB_NOPROPERTIES'];
        case ERROR_DB_INVALIDDBMAPPING:
            return $content['LN_ERROR_DB_INVALIDDBMAPPING'];
        case ERROR_DB_INVALIDDBDRIVER:
            return $content['LN_ERROR_DB_INVALIDDBDRIVER'];
        case ERROR_DB_TABLENOTFOUND:
            return $content['LN_ERROR_DB_TABLENOTFOUND'];
        case ERROR_DB_DBFIELDNOTFOUND:
            return $content['LN_ERROR_DB_DBFIELDNOTFOUND'];
        case ERROR_CHARTS_NOTCONFIGURED:
            return $content['LN_ERROR_CHARTS_NOTCONFIGURED'];
        case ERROR_FILE_NOMORETIME:
            return $content['LN_ERROR_FILE_NOMORETIME'];
        case ERROR_SOURCENOTFOUND:
            return $content['LN_GEN_ERROR_SOURCENOTFOUND'];
        case ERROR_REPORT_NODATA:
            return $content['LN_GEN_ERROR_REPORT_NODATA'];
        case ERROR_PATH_NOT_ALLOWED:
            return $content['LN_ERROR_PATH_NOT_ALLOWED'];
        default:
            return GetAndReplaceLangStr($content['LN_ERROR_UNKNOWN'], $errorCode);
    }
}
예제 #21
0
function InitSource(&$mysource)
{
    global $CFG, $content, $gl_root_path, $currentSourceID;
    if (isset($mysource['SourceType'])) {
        // Set Array Index, TODO: Check for invalid characters!
        $iSourceID = $mysource['ID'];
        // --- Set defaults if not set!
        if (!isset($mysource['LogLineType'])) {
            $CFG['Sources'][$iSourceID]['LogLineType'] = "syslog";
            $content['Sources'][$iSourceID]['LogLineType'] = "syslog";
        }
        if (!isset($mysource['userid'])) {
            $CFG['Sources'][$iSourceID]['userid'] = null;
            $content['Sources'][$iSourceID]['userid'] = null;
        }
        if (!isset($mysource['groupid'])) {
            $CFG['Sources'][$iSourceID]['groupid'] = null;
            $content['Sources'][$iSourceID]['groupid'] = null;
        }
        if (!isset($mysource['MsgParserList'])) {
            $CFG['Sources'][$iSourceID]['MsgParserList'] = null;
            $content['Sources'][$iSourceID]['MsgParserList'] = null;
        }
        if (!isset($mysource['MsgNormalize'])) {
            $CFG['Sources'][$iSourceID]['MsgNormalize'] = 0;
            $content['Sources'][$iSourceID]['MsgNormalize'] = 0;
        }
        if (!isset($mysource['MsgSkipUnparseable'])) {
            $CFG['Sources'][$iSourceID]['MsgSkipUnparseable'] = 0;
            $content['Sources'][$iSourceID]['MsgSkipUnparseable'] = 0;
        }
        if (!isset($mysource['Description'])) {
            $CFG['Sources'][$iSourceID]['Description'] = "";
            $content['Sources'][$iSourceID]['Description'] = "";
        }
        if (!isset($mysource['defaultfilter'])) {
            $CFG['Sources'][$iSourceID]['defaultfilter'] = "";
            $content['Sources'][$iSourceID]['defaultfilter'] = "";
        }
        // ---
        // Set default view id to source
        $tmpVar = GetConfigSetting("DefaultViewsID", "", CFGLEVEL_USER);
        $szDefaultViewID = strlen($tmpVar) > 0 ? $tmpVar : "SYSLOG";
        if (isset($_SESSION[$iSourceID . "-View"])) {
            // check if view is valid
            $UserSessionViewID = $_SESSION[$iSourceID . "-View"];
            if (isset($content['Views'][$UserSessionViewID])) {
                // Overwrite configured view!
                $content['Sources'][$iSourceID]['ViewID'] = $_SESSION[$iSourceID . "-View"];
            } else {
                $content['Sources'][$iSourceID]['ViewID'] = $szDefaultViewID;
            }
        } else {
            if (isset($mysource['ViewID']) && strlen($mysource['ViewID']) > 0 && isset($content['Views'][$mysource['ViewID']])) {
                // Set to configured Source ViewID
                $content['Sources'][$iSourceID]['ViewID'] = $mysource['ViewID'];
            } else {
                // Not configured, maybe old legacy cfg. Set default view.
                $content['Sources'][$iSourceID]['ViewID'] = $szDefaultViewID;
            }
        }
        // Only for the display box
        $content['Sources'][$iSourceID]['selected'] = "";
        // Create Config instance!
        if ($mysource['SourceType'] == SOURCE_DISK) {
            // Perform necessary include
            require_once $gl_root_path . 'classes/logstreamconfigdisk.class.php';
            $mysource['ObjRef'] = new LogStreamConfigDisk();
            $mysource['ObjRef']->SetFileName($mysource['DiskFile']);
            $mysource['ObjRef']->LineParserType = $mysource['LogLineType'];
        } else {
            if ($mysource['SourceType'] == SOURCE_DB) {
                // Perform necessary include
                require_once $gl_root_path . 'classes/logstreamconfigdb.class.php';
                $mysource['ObjRef'] = new LogStreamConfigDB();
                $mysource['ObjRef']->DBServer = $mysource['DBServer'];
                $mysource['ObjRef']->DBName = $mysource['DBName'];
                // Workaround a little bug from the installer script
                if (isset($mysource['DBType'])) {
                    $mysource['ObjRef']->DBType = $mysource['DBType'];
                } else {
                    $mysource['ObjRef']->DBType = DB_MYSQL;
                }
                $mysource['ObjRef']->DBTableName = $mysource['DBTableName'];
                // Legacy handling for tabletype!
                if (isset($mysource['DBTableType']) && strtolower($mysource['DBTableType']) == "winsyslog") {
                    $mysource['ObjRef']->DBTableType = "monitorware";
                } else {
                    $mysource['ObjRef']->DBTableType = strtolower($mysource['DBTableType']);
                }
                // Optional parameters!
                if (isset($mysource['DBPort'])) {
                    $mysource['ObjRef']->DBPort = $mysource['DBPort'];
                }
                if (isset($mysource['DBUser'])) {
                    $mysource['ObjRef']->DBUser = $mysource['DBUser'];
                }
                if (isset($mysource['DBPassword'])) {
                    $mysource['ObjRef']->DBPassword = $mysource['DBPassword'];
                }
                if (isset($mysource['DBEnableRowCounting'])) {
                    $mysource['ObjRef']->DBEnableRowCounting = $mysource['DBEnableRowCounting'];
                }
                if (isset($mysource['DBRecordsPerQuery'])) {
                    $mysource['ObjRef']->RecordsPerQuery = $mysource['DBRecordsPerQuery'];
                }
            } else {
                if ($mysource['SourceType'] == SOURCE_PDO) {
                    // Perform necessary include
                    require_once $gl_root_path . 'classes/logstreamconfigpdo.class.php';
                    $mysource['ObjRef'] = new LogStreamConfigPDO();
                    $mysource['ObjRef']->DBServer = $mysource['DBServer'];
                    $mysource['ObjRef']->DBName = $mysource['DBName'];
                    $mysource['ObjRef']->DBType = $mysource['DBType'];
                    $mysource['ObjRef']->DBTableName = $mysource['DBTableName'];
                    $mysource['ObjRef']->DBTableType = strtolower($mysource['DBTableType']);
                    // Optional parameters!
                    if (isset($mysource['DBPort'])) {
                        $mysource['ObjRef']->DBPort = $mysource['DBPort'];
                    }
                    if (isset($mysource['DBUser'])) {
                        $mysource['ObjRef']->DBUser = $mysource['DBUser'];
                    }
                    if (isset($mysource['DBPassword'])) {
                        $mysource['ObjRef']->DBPassword = $mysource['DBPassword'];
                    }
                    if (isset($mysource['DBEnableRowCounting'])) {
                        $mysource['ObjRef']->DBEnableRowCounting = $mysource['DBEnableRowCounting'];
                    }
                } else {
                    if ($mysource['SourceType'] == SOURCE_MONGODB) {
                        // Perform necessary include
                        require_once $gl_root_path . 'classes/logstreamconfigmongodb.class.php';
                        $mysource['ObjRef'] = new LogStreamConfigMongoDB();
                        $mysource['ObjRef']->DBServer = $mysource['DBServer'];
                        $mysource['ObjRef']->DBName = $mysource['DBName'];
                        $mysource['ObjRef']->DBCollection = $mysource['DBTableName'];
                        $mysource['ObjRef']->DBTableType = strtolower($mysource['DBTableType']);
                        // Optional parameters!
                        if (isset($mysource['DBPort'])) {
                            $mysource['ObjRef']->DBPort = $mysource['DBPort'];
                        }
                        if (isset($mysource['DBUser'])) {
                            $mysource['ObjRef']->DBUser = $mysource['DBUser'];
                        }
                        if (isset($mysource['DBPassword'])) {
                            $mysource['ObjRef']->DBPassword = $mysource['DBPassword'];
                        }
                        //			if ( isset($mysource['DBEnableRowCounting']) ) { $mysource['ObjRef']->DBEnableRowCounting = $mysource['DBEnableRowCounting']; }
                    } else {
                        // UNKNOWN, remove config entry!
                        unset($content['Sources'][$iSourceID]);
                        // Output Debug Warning only!
                        OutputDebugMessage(GetAndReplaceLangStr($content['LN_GEN_CRITERROR_UNKNOWNTYPE'], $mysource['SourceType']), DEBUG_ERROR);
                        // DieWithFriendlyErrorMsg( GetAndReplaceLangStr($content['LN_GEN_CRITERROR_UNKNOWNTYPE'], $mysource['SourceType']) );
                        return ERROR;
                    }
                }
            }
        }
        // Set generic configuration options
        $mysource['ObjRef']->_pageCount = GetConfigSetting("ViewEntriesPerPage", 50);
        if (isset($mysource['MsgParserList'])) {
            $mysource['ObjRef']->SetMsgParserList($mysource['MsgParserList']);
        }
        if (isset($mysource['MsgNormalize'])) {
            $mysource['ObjRef']->SetMsgNormalize($mysource['MsgNormalize']);
        }
        if (isset($mysource['MsgSkipUnparseable'])) {
            $mysource['ObjRef']->SetSkipUnparseable($mysource['MsgSkipUnparseable']);
        }
        if (isset($mysource['defaultfilter'])) {
            $mysource['ObjRef']->SetDefaultfilter($mysource['defaultfilter']);
        }
        // Set default SourceID here!
        if (isset($content['Sources'][$iSourceID]) && !isset($currentSourceID)) {
            $currentSourceID = $iSourceID;
        }
        // Copy Object REF into CFG and content Array as well!
        $content['Sources'][$iSourceID]['ObjRef'] = $mysource['ObjRef'];
        $CFG['Sources'][$iSourceID]['ObjRef'] = $mysource['ObjRef'];
    }
}
예제 #22
0
function PerformSQLDelete($szDeleteStm, $szErrMsg, $szUserID)
{
    global $content;
    $result = DB_Query($szDeleteStm);
    if ($result == FALSE) {
        $content['ISERROR'] = true;
        $content['ERROR_MSG'] = GetAndReplaceLangStr($content[$szErrMsg], $szUserID);
        return false;
    } else {
        DB_FreeQuery($result);
    }
    // Success
    return true;
}
예제 #23
0
         }
         // This will enable to Main SyslogView
         $content['messageenabled'] = "true";
     } else {
         // Disable view and print error state!
         $content['messageenabled'] = "false";
         // Set error code
         $content['error_code'] = $ret;
         if ($ret == ERROR_UNDEFINED) {
             $content['detailederror'] = "Undefined error happened within the logstream.";
         } else {
             $content['detailederror'] = "Unknown or unhandeled error occured.";
         }
         // Add extra error stuff
         if (isset($extraErrorDescription)) {
             $content['detailederror'] .= "<br><br>" . GetAndReplaceLangStr($content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
         }
     }
 } else {
     // This will disable to Main SyslogView and show an error message
     $content['messageenabled'] = "false";
     // Set error code
     $content['error_code'] = $ret;
     if ($ret == ERROR_FILE_NOT_FOUND) {
         $content['detailederror'] = $content['LN_ERROR_FILE_NOT_FOUND'];
     } else {
         if ($ret == ERROR_FILE_NOT_READABLE) {
             $content['detailederror'] = $content['LN_ERROR_FILE_NOT_READABLE'];
         } else {
             $content['detailederror'] = $content['LN_ERROR_UNKNOWN'];
         }
예제 #24
0
function RunReport()
{
    global $content, $gl_root_path;
    // Get Reference to report!
    $myReport = $content['REPORTS'][$content['reportid']];
    // Get reference to savedreport
    $mySavedReport = $myReport['SAVEDREPORTS'][$content['savedreportid']];
    // Get Objectreference to report
    $myReportObj = $myReport["ObjRef"];
    // Set SavedReport Settings!
    $myReportObj->InitFromSavedReport($mySavedReport);
    //Debug Output
    PrintHTMLDebugInfo(DEBUG_INFO, "RunReport", GetAndReplaceLangStr($content["LN_CMD_RUNREPORT"], $mySavedReport['customTitle']));
    // Perform check
    $res = $myReportObj->verifyDataSource();
    if ($res != SUCCESS) {
        // Print error and die!
        $szError = GetAndReplaceLangStr($content['LN_GEN_ERROR_REPORTGENFAILED'], $mySavedReport['customTitle'], GetAndReplaceLangStr(GetErrorMessage($res), $mySavedReport['sourceid']));
        if (isset($extraErrorDescription)) {
            $szError .= "<br><br>" . GetAndReplaceLangStr($content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
        }
        DieWithErrorMsg($szError);
    } else {
        // Call processing part now!
        $res = $myReportObj->startDataProcessing();
        if ($res != SUCCESS) {
            DieWithErrorMsg(GetAndReplaceLangStr($content['LN_GEN_ERROR_REPORTGENFAILED'], $mySavedReport['customTitle'], GetErrorMessage($res)));
        } else {
            // --- Perform report output
            // Init IncludePath
            $reportIncludePath = $myReportObj->GetReportIncludePath();
            // Include Custom language file if available
            $myReportObj->InitReportLanguageFile($reportIncludePath);
            // Init template Parser
            $page = new Template();
            $page->set_path($reportIncludePath);
            // Parse template
            $page->parser($content, $myReportObj->GetBaseFileName());
            // Output the result
            $res = $myReportObj->OutputReport($page->result(), $szErrorStr);
            if ($res == SUCCESS && $myReportObj->GetOutputTarget() != REPORT_TARGET_STDOUT) {
                //Debug Output
                PrintHTMLDebugInfo(DEBUG_INFO, "RunReport", GetAndReplaceLangStr($content["LN_GEN_SUCCESS_REPORTWASGENERATED_DETAILS"], $szErrorStr));
            } else {
                if ($res == ERROR) {
                    // Debug Error
                    PrintHTMLDebugInfo(DEBUG_ERROR, "RunReport", GetAndReplaceLangStr($content["LN_GEN_ERROR_REPORTFAILEDTOGENERATE"], $szErrorStr));
                }
            }
            // ---
        }
    }
}