From b2fefbaf3fe920bb8d9389e5aa4c3cd69867c86f Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 23 May 2008 17:33:14 +0200 Subject: [PATCH] Added new PDO Database logstream into install script. This means you can select now between the native MYSQL Server and the PDO database driver. When using the PDO database driver, you choose between different database storage engines. --- src/include/constants_logstream.php | 2 + src/include/functions_common.php | 59 ++++++++++++++++++++++++----- src/install.php | 50 +++++++++++++++--------- src/js/common.js | 24 ++++++++++++ src/lang/de/main.php | 9 +++++ src/lang/en/main.php | 13 ++++++- src/templates/install.html | 55 ++++++++++++++++++++++----- 7 files changed, 175 insertions(+), 37 deletions(-) diff --git a/src/include/constants_logstream.php b/src/include/constants_logstream.php index f4056bd..79eb224 100644 --- a/src/include/constants_logstream.php +++ b/src/include/constants_logstream.php @@ -75,6 +75,8 @@ define('DB_OCI', 4); define('DB_DB2', 5); define('DB_FIREBIRD', 6); define('DB_INFORMIX', 7); +define('DB_SQLITE', 8); + // --- Predefine fields array! $fields[SYSLOG_UID]['FieldID'] = SYSLOG_UID; diff --git a/src/include/functions_common.php b/src/include/functions_common.php index 3e5ee92..6bf22e1 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -236,10 +236,15 @@ function CreateSourceTypesList( $selectedSource ) $content['SOURCETYPES'][SOURCE_DISK]['DisplayName'] = $content['LN_GEN_SOURCE_DISK']; if ( $selectedSource == $content['SOURCETYPES'][SOURCE_DISK]['type'] ) { $content['SOURCETYPES'][SOURCE_DISK]['selected'] = "selected"; } else { $content['SOURCETYPES'][SOURCE_DISK]['selected'] = ""; } - // SOURCE_DB + // SOURCE_DB ( MYSQL NATIVE ) $content['SOURCETYPES'][SOURCE_DB]['type'] = SOURCE_DB; $content['SOURCETYPES'][SOURCE_DB]['DisplayName'] = $content['LN_GEN_SOURCE_DB']; - if ( $selectedSource == $content['SOURCETYPES'][SOURCE_DB]['type'] ) { $content['SOURCETYPES'][SOURCE_DB]['selected'] = "selected"; } else { $content['SOURCETYPES'][SOURCE_DISK]['selected'] = ""; } + if ( $selectedSource == $content['SOURCETYPES'][SOURCE_DB]['type'] ) { $content['SOURCETYPES'][SOURCE_DB]['selected'] = "selected"; } else { $content['SOURCETYPES'][SOURCE_DB]['selected'] = ""; } + + // SOURCE_PDO ( PDO DB Wrapper) + $content['SOURCETYPES'][SOURCE_PDO]['type'] = SOURCE_PDO; + $content['SOURCETYPES'][SOURCE_PDO]['DisplayName'] = $content['LN_GEN_SOURCE_PDO']; + if ( $selectedSource == $content['SOURCETYPES'][SOURCE_PDO]['type'] ) { $content['SOURCETYPES'][SOURCE_PDO]['selected'] = "selected"; } else { $content['SOURCETYPES'][SOURCE_PDO]['selected'] = ""; } } function CreateDBTypesList( $selectedDBType ) @@ -248,21 +253,57 @@ function CreateDBTypesList( $selectedDBType ) // DB_MYSQL $content['DBTYPES'][DB_MYSQL]['type'] = DB_MYSQL; - $content['DBTYPES'][DB_MYSQL]['DisplayName'] = "Mysql"; + $content['DBTYPES'][DB_MYSQL]['typeastext'] = "DB_MYSQL"; + $content['DBTYPES'][DB_MYSQL]['DisplayName'] = $content['LN_GEN_DB_MYSQL']; if ( $selectedDBType == $content['DBTYPES'][DB_MYSQL]['type'] ) { $content['DBTYPES'][DB_MYSQL]['selected'] = "selected"; } else { $content['DBTYPES'][DB_MYSQL]['selected'] = ""; } -/* LATER ... // DB_MSSQL $content['DBTYPES'][DB_MSSQL]['type'] = DB_MSSQL; - $content['DBTYPES'][DB_MSSQL]['DisplayName'] = "Microsoft SQL Server"; + $content['DBTYPES'][DB_MSSQL]['typeastext'] = "DB_MSSQL"; + $content['DBTYPES'][DB_MSSQL]['DisplayName'] = $content['LN_GEN_DB_MSSQL']; if ( $selectedDBType == $content['DBTYPES'][DB_MSSQL]['type'] ) { $content['DBTYPES'][DB_MSSQL]['selected'] = "selected"; } else { $content['DBTYPES'][DB_MSSQL]['selected'] = ""; } // DB_ODBC - $content['DBTYPES'][DB_ODBC]['type'] = DB_MSSQL; - $content['DBTYPES'][DB_ODBC]['DisplayName'] = "ODBC Database Source"; - if ( $selectedDBType == $content['DBTYPES'][DB_ODBC]['type'] ) { $content['DBTYPES'][DB_ODBC]['selected'] = "selected"; } else { $content['DB_ODBC'][DB_MSSQL]['selected'] = ""; } -*/ + $content['DBTYPES'][DB_ODBC]['type'] = DB_ODBC; + $content['DBTYPES'][DB_ODBC]['typeastext'] = "DB_ODBC"; + $content['DBTYPES'][DB_ODBC]['DisplayName'] = $content['LN_GEN_DB_ODBC']; + if ( $selectedDBType == $content['DBTYPES'][DB_ODBC]['type'] ) { $content['DBTYPES'][DB_ODBC]['selected'] = "selected"; } else { $content['DB_ODBC'][DB_ODBC]['selected'] = ""; } + // DB_PGSQL + $content['DBTYPES'][DB_PGSQL]['type'] = DB_PGSQL; + $content['DBTYPES'][DB_PGSQL]['typeastext'] = "DB_PGSQL"; + $content['DBTYPES'][DB_PGSQL]['DisplayName'] = $content['LN_GEN_DB_PGSQL']; + if ( $selectedDBType == $content['DBTYPES'][DB_PGSQL]['type'] ) { $content['DBTYPES'][DB_PGSQL]['selected'] = "selected"; } else { $content['DB_ODBC'][DB_PGSQL]['selected'] = ""; } + + // DB_OCI + $content['DBTYPES'][DB_OCI]['type'] = DB_OCI; + $content['DBTYPES'][DB_OCI]['typeastext'] = "DB_OCI"; + $content['DBTYPES'][DB_OCI]['DisplayName'] = $content['LN_GEN_DB_OCI']; + if ( $selectedDBType == $content['DBTYPES'][DB_OCI]['type'] ) { $content['DBTYPES'][DB_OCI]['selected'] = "selected"; } else { $content['DB_ODBC'][DB_OCI]['selected'] = ""; } + + // DB_DB2 + $content['DBTYPES'][DB_DB2]['type'] = DB_DB2; + $content['DBTYPES'][DB_DB2]['typeastext'] = "DB_DB2"; + $content['DBTYPES'][DB_DB2]['DisplayName'] = $content['LN_GEN_DB_DB2']; + if ( $selectedDBType == $content['DBTYPES'][DB_DB2]['type'] ) { $content['DBTYPES'][DB_DB2]['selected'] = "selected"; } else { $content['DB_ODBC'][DB_DB2]['selected'] = ""; } + + // DB_FIREBIRD + $content['DBTYPES'][DB_FIREBIRD]['type'] = DB_FIREBIRD; + $content['DBTYPES'][DB_FIREBIRD]['typeastext'] = "DB_FIREBIRD"; + $content['DBTYPES'][DB_FIREBIRD]['DisplayName'] = $content['LN_GEN_DB_FIREBIRD']; + if ( $selectedDBType == $content['DBTYPES'][DB_FIREBIRD]['type'] ) { $content['DBTYPES'][DB_FIREBIRD]['selected'] = "selected"; } else { $content['DB_ODBC'][DB_FIREBIRD]['selected'] = ""; } + + // DB_INFORMIX + $content['DBTYPES'][DB_INFORMIX]['type'] = DB_INFORMIX; + $content['DBTYPES'][DB_INFORMIX]['typeastext'] = "DB_INFORMIX"; + $content['DBTYPES'][DB_INFORMIX]['DisplayName'] = $content['LN_GEN_DB_INFORMIX']; + if ( $selectedDBType == $content['DBTYPES'][DB_INFORMIX]['type'] ) { $content['DBTYPES'][DB_INFORMIX]['selected'] = "selected"; } else { $content['DB_ODBC'][DB_INFORMIX]['selected'] = ""; } + + // DB_SQLITE + $content['DBTYPES'][DB_SQLITE]['type'] = DB_SQLITE; + $content['DBTYPES'][DB_SQLITE]['typeastext'] = "DB_SQLITE"; + $content['DBTYPES'][DB_SQLITE]['DisplayName'] = $content['LN_GEN_DB_SQLITE']; + if ( $selectedDBType == $content['DBTYPES'][DB_SQLITE]['type'] ) { $content['DBTYPES'][DB_SQLITE]['selected'] = "selected"; } else { $content['DB_ODBC'][DB_SQLITE]['selected'] = ""; } } function CreatePagesizesList() diff --git a/src/install.php b/src/install.php index 10f79df..d6b00e5 100644 --- a/src/install.php +++ b/src/install.php @@ -347,7 +347,7 @@ else if ( $content['INSTALL_STEP'] == 5 ) $totaldbdefs = str_replace( "`logcon_", "`" . $_SESSION["UserDBPref"], $totaldbdefs ); // Now split by sql command - $mycommands = split( ";\r\n", $totaldbdefs ); + $mycommands = split( ";\n", $totaldbdefs ); // check for different linefeed if ( count($mycommands) <= 1 ) @@ -527,7 +527,7 @@ else if ( $content['INSTALL_STEP'] == 8 ) if ( !is_file($_SESSION['SourceDiskFile']) ) RevertOneStep( $content['INSTALL_STEP']-1, "Failed to open the syslog file " .$_SESSION['SourceDiskFile'] . "! Check if the file exists and phplogcon has sufficient rights to it
" ); } - else if ( $_SESSION['SourceType'] == SOURCE_DB) + else if ( $_SESSION['SourceType'] == SOURCE_DB || $_SESSION['SourceType'] == SOURCE_PDO ) { if ( isset($_POST['SourceDBType']) ) $_SESSION['SourceDBType'] = DB_RemoveBadChars($_POST['SourceDBType']); @@ -594,26 +594,42 @@ else if ( $content['INSTALL_STEP'] == 8 ) } //Add the first source! - $firstsource = "\$CFG['DefaultSourceID'] = 'Source1';\r\n\r\n" . - "\$CFG['Sources']['Source1']['ID'] = 'Source1';\r\n" . - "\$CFG['Sources']['Source1']['Name'] = '" . $_SESSION['SourceName'] . "';\r\n" . - "\$CFG['Sources']['Source1']['SourceType'] = " . $_SESSION['SourceType'] . ";\r\n"; + $firstsource = "\$CFG['DefaultSourceID'] = 'Source1';\n\n" . + "\$CFG['Sources']['Source1']['ID'] = 'Source1';\n" . + "\$CFG['Sources']['Source1']['Name'] = '" . $_SESSION['SourceName'] . "';\n"; if ( $_SESSION['SourceType'] == SOURCE_DISK ) { - $firstsource .= "\$CFG['Sources']['Source1']['LogLineType'] = '" . $_SESSION['SourceLogLineType'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DiskFile'] = '" . $_SESSION['SourceDiskFile'] . "';\r\n" . + $firstsource .= "\$CFG['Sources']['Source1']['SourceType'] = SOURCE_DISK;\n" . + "\$CFG['Sources']['Source1']['LogLineType'] = '" . $_SESSION['SourceLogLineType'] . "';\n" . + "\$CFG['Sources']['Source1']['DiskFile'] = '" . $_SESSION['SourceDiskFile'] . "';\n" . ""; } - else if ( $_SESSION['SourceType'] == SOURCE_DB ) + else if ( $_SESSION['SourceType'] == SOURCE_DB ) { - $firstsource .= "\$CFG['Sources']['Source1']['DBTableType'] = '" . $_SESSION['SourceDBTableType'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DBType'] = '" . $_SESSION['SourceDBType'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DBServer'] = '" . $_SESSION['SourceDBServer'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DBName'] = '" . $_SESSION['SourceDBName'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DBUser'] = '" . $_SESSION['SourceDBUser'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DBPassword'] = '" . $_SESSION['SourceDBPassword'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DBTableName'] = '" . $_SESSION['SourceDBTableName'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DBEnableRowCounting'] = " . $_SESSION['SourceDBEnableRowCounting'] . ";\r\n" . + $firstsource .= "\$CFG['Sources']['Source1']['SourceType'] = SOURCE_DB;\n" . + "\$CFG['Sources']['Source1']['DBTableType'] = '" . $_SESSION['SourceDBTableType'] . "';\n" . + "\$CFG['Sources']['Source1']['DBServer'] = '" . $_SESSION['SourceDBServer'] . "';\n" . + "\$CFG['Sources']['Source1']['DBName'] = '" . $_SESSION['SourceDBName'] . "';\n" . + "\$CFG['Sources']['Source1']['DBUser'] = '" . $_SESSION['SourceDBUser'] . "';\n" . + "\$CFG['Sources']['Source1']['DBPassword'] = '" . $_SESSION['SourceDBPassword'] . "';\n" . + "\$CFG['Sources']['Source1']['DBTableName'] = '" . $_SESSION['SourceDBTableName'] . "';\n" . + "\$CFG['Sources']['Source1']['DBEnableRowCounting'] = " . $_SESSION['SourceDBEnableRowCounting'] . ";\n" . + ""; + } + else if ( $_SESSION['SourceType'] == SOURCE_PDO ) + { + // Need to create the LIST first! + CreateDBTypesList($_SESSION['SourceDBType']); + + $firstsource .= "\$CFG['Sources']['Source1']['SourceType'] = SOURCE_PDO;\n" . + "\$CFG['Sources']['Source1']['DBTableType'] = '" . $_SESSION['SourceDBTableType'] . "';\n" . + "\$CFG['Sources']['Source1']['DBType'] = " . $content['DBTYPES'][$_SESSION['SourceDBType']]['typeastext'] . ";\n" . + "\$CFG['Sources']['Source1']['DBServer'] = '" . $_SESSION['SourceDBServer'] . "';\n" . + "\$CFG['Sources']['Source1']['DBName'] = '" . $_SESSION['SourceDBName'] . "';\n" . + "\$CFG['Sources']['Source1']['DBUser'] = '" . $_SESSION['SourceDBUser'] . "';\n" . + "\$CFG['Sources']['Source1']['DBPassword'] = '" . $_SESSION['SourceDBPassword'] . "';\n" . + "\$CFG['Sources']['Source1']['DBTableName'] = '" . $_SESSION['SourceDBTableName'] . "';\n" . + "\$CFG['Sources']['Source1']['DBEnableRowCounting'] = " . $_SESSION['SourceDBEnableRowCounting'] . ";\n" . ""; } $patterns[] = "/\/\/ --- \%Insert Source Here\%/"; diff --git a/src/js/common.js b/src/js/common.js index 46137bf..fef542a 100644 --- a/src/js/common.js +++ b/src/js/common.js @@ -67,6 +67,30 @@ function togglevisibility(ElementNameToggle, ElementNameButton) } } +/* +* Helper function to hide a div area +*/ +function showvisibility(ElementNameToggle, ElementNameButton) +{ + var toggle = document.getElementById(ElementNameToggle); + + // Button is optional + if (ElementNameButton != null) + { + var button = document.getElementById(ElementNameButton); + } + else + var button = null; + + if (button != null) + { + button.className = "topmenu2 ExpansionMinus"; + } + + toggle.style.visibility = "visible"; + toggle.style.display = "inline"; +} + /* * Helper function to hide a div area */ diff --git a/src/lang/de/main.php b/src/lang/de/main.php index 6ac4cbc..d169e0c 100644 --- a/src/lang/de/main.php +++ b/src/lang/de/main.php @@ -46,6 +46,15 @@ $content['LN_GEN_SOURCE_DB'] = "Datenbank"; $content['LN_GEN_RECORDSPERPAGE'] = "records per page"; $content['LN_GEN_PRECONFIGURED'] = "Preconfigured"; $content['LN_GEN_AVAILABLESEARCHES'] = "Available searches"; + $content['LN_GEN_DB_MYSQL'] = "Mysql Server"; + $content['LN_GEN_DB_MSSQL'] = "Microsoft SQL Server"; + $content['LN_GEN_DB_ODBC'] = "ODBC Database Source"; + $content['LN_GEN_DB_PGSQL'] = "PostgreSQL"; + $content['LN_GEN_DB_OCI'] = "Oracle Call Interface"; + $content['LN_GEN_DB_DB2'] = " IBM DB2"; + $content['LN_GEN_DB_FIREBIRD'] = "Firebird/Interbase 6"; + $content['LN_GEN_DB_INFORMIX'] = "IBM Informix Dynamic Server"; + $content['LN_GEN_DB_SQLITE'] = "SQLite 2"; // Index Site $content['LN_ERROR_INSTALLFILEREMINDER'] = "Warnung! Du hast das Installationsscript 'install.php' noch nicht aus dem phpLogCon Hauptordner entfernt!"; diff --git a/src/lang/en/main.php b/src/lang/en/main.php index 52ba085..b84919d 100644 --- a/src/lang/en/main.php +++ b/src/lang/en/main.php @@ -42,11 +42,20 @@ $content['LN_GEN_PAGERSIZE'] = "Records per page"; $content['LN_GEN_PAGE'] = "Page"; $content['LN_GEN_PREDEFINEDSEARCHES'] = "Predefined Searches"; $content['LN_GEN_SOURCE_DISK'] = "Diskfile"; -$content['LN_GEN_SOURCE_DB'] = "Database"; +$content['LN_GEN_SOURCE_DB'] = "MYSQL Native"; +$content['LN_GEN_SOURCE_PDO'] = "Database (PDO)"; $content['LN_GEN_RECORDSPERPAGE'] = "records per page"; $content['LN_GEN_PRECONFIGURED'] = "Preconfigured"; $content['LN_GEN_AVAILABLESEARCHES'] = "Available searches"; - +$content['LN_GEN_DB_MYSQL'] = "Mysql Server"; +$content['LN_GEN_DB_MSSQL'] = "Microsoft SQL Server"; +$content['LN_GEN_DB_ODBC'] = "ODBC Database Source"; +$content['LN_GEN_DB_PGSQL'] = "PostgreSQL"; +$content['LN_GEN_DB_OCI'] = "Oracle Call Interface"; +$content['LN_GEN_DB_DB2'] = " IBM DB2"; +$content['LN_GEN_DB_FIREBIRD'] = "Firebird/Interbase 6"; +$content['LN_GEN_DB_INFORMIX'] = "IBM Informix Dynamic Server"; +$content['LN_GEN_DB_SQLITE'] = "SQLite 2"; // Main Index Site $content['LN_ERROR_INSTALLFILEREMINDER'] = "Warning! You still have NOT removed the 'install.php' from your phpLogCon main directory!"; diff --git a/src/templates/install.html b/src/templates/install.html index ccea573..75e40d5 100644 --- a/src/templates/install.html +++ b/src/templates/install.html @@ -8,6 +8,35 @@ + + @@ -265,7 +294,7 @@
{LN_CFG_SOURCETYPE} - @@ -278,7 +307,7 @@ - +
{LN_CFG_DISKTYPEOPTIONS}
{LN_CFG_LOGLINETYPE}{LN_CFG_LOGLINETYPE} +
{LN_CFG_DATABASETYPEOPTIONS}
+ +
+ - - - - - + +
{LN_CFG_DBTABLETYPE}
{LN_CFG_DBSTORAGEENGINE}{LN_CFG_DBSTORAGEENGINE}
+
+ + + + + + @@ -332,7 +369,7 @@ - + @@ -348,7 +385,7 @@
{LN_CFG_DBTABLETYPE}
{LN_CFG_DBSERVER}
{LN_CFG_DBROWCOUNTING}{LN_CFG_DBROWCOUNTING} Yes No