SQL Statement: " . $sqlselect );
-
- // Default return false
- return false;
- }
-}
-
-function DoLogOff()
-{
- global $content;
-
- unset( $_SESSION['SESSION_LOGGEDIN'] );
- unset( $_SESSION['SESSION_USERNAME'] );
- unset( $_SESSION['SESSION_ACCESSLEVEL'] );
-
- // Redir to Index Page
- RedirectPage( "index.php");
-}
-
-function RedirectToUserLogin()
-{
- // TODO Referer
- header("Location: login.php?referer=" . $_SERVER['PHP_SELF']);
- exit;
-}
-
-function RedirectToDatabaseUpgrade()
-{
- // TODO Referer
- header("Location: upgrade.php"); // ?referer=" . $_SERVER['PHP_SELF']);
- exit;
-}
-// --- END Usermanagement Function ---
-
-
-?>
+ www.phplogcon.org <- *
+ * ----------------------------------------------------------------- *
+ * Common needed functions *
+ * *
+ * -> *
+ * *
+ * All directives are explained within this file *
+ *
+ * Copyright (C) 2008 Adiscon GmbH.
+ *
+ * This file is part of phpLogCon.
+ *
+ * PhpLogCon is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * PhpLogCon is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpLogCon. If not, see .
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this
+ * distribution.
+ *********************************************************************
+*/
+
+// --- Avoid directly accessing this file!
+if ( !defined('IN_PHPLOGCON') )
+{
+ die('Hacking attempt');
+ exit;
+}
+// ---
+
+// --- Basic Includes
+include($gl_root_path . 'include/constants_general.php');
+include($gl_root_path . 'include/constants_logstream.php');
+
+if ( is_file($gl_root_path . 'config.php') )
+ include($gl_root_path . 'config.php');
+else
+{
+ // Check for installscript!
+ if ( !defined('IN_PHPLOGCON_INSTALL') )
+ CheckForInstallPhp();
+}
+
+include($gl_root_path . 'classes/class_template.php');
+include($gl_root_path . 'include/functions_themes.php');
+include($gl_root_path . 'include/functions_db.php');
+include($gl_root_path . 'include/functions_config.php');
+// ---
+
+// --- Define Basic vars
+$RUNMODE = RUNMODE_WEBSERVER;
+$DEBUGMODE = DEBUG_INFO;
+
+// --- Disable ARGV setting @webserver!
+ini_set( "register_argc_argv", "Off" );
+// ---
+
+// Default language
+$LANG_EN = "en"; // Used for fallback
+$LANG = "en"; // Default language
+
+// Default Template vars
+$content['BUILDNUMBER'] = "2.1.2";
+$content['TITLE'] = "PhpLogCon - Release " . $content['BUILDNUMBER']; // Title of the Page
+$content['BASEPATH'] = $gl_root_path;
+$content['EXTRA_METATAGS'] = "";
+$content['EXTRA_JAVASCRIPT'] = "";
+$content['EXTRA_STYLESHEET'] = "";
+// ---
+
+function InitBasicPhpLogCon()
+{
+ // Needed to make global
+ global $CFG, $gl_root_path, $content;
+
+ // Check RunMode first!
+ CheckAndSetRunMode();
+
+ // Get and Set RunTime Informations
+ InitRuntimeInformations();
+
+ // Set the default line sep
+ SetLineBreakVar();
+
+ // Start the PHP Session
+ StartPHPSession();
+}
+
+function InitPhpLogConConfigFile()
+{
+ // Needed to make global
+ global $CFG, $gl_root_path, $content;
+
+ if ( file_exists($gl_root_path . 'config.php') && GetFileLength($gl_root_path . 'config.php') > 0 )
+ {
+ // Include the main config
+ include_once($gl_root_path . 'config.php');
+
+ // Easier DB Access
+ define('DB_CONFIG', $CFG['UserDBPref'] . "config");
+
+ // If DEBUG Mode is enabled, we prepend the UID field into the col list!
+ if ( $CFG['MiscShowDebugMsg'] == 1 )
+ array_unshift($CFG['Columns'], SYSLOG_UID);
+
+ // Now Copy all entries into content variable
+ foreach ($CFG as $key => $value )
+ $content[$key] = $value;
+
+ // For MiscShowPageRenderStats
+ if ( $CFG['MiscShowPageRenderStats'] == 1 )
+ {
+ $content['ShowPageRenderStats'] = "true";
+ InitPageRenderStats();
+ }
+ }
+ else
+ {
+ // Check for installscript!
+ CheckForInstallPhp();
+ }
+}
+
+function CheckForInstallPhp()
+{
+ // Check for installscript!
+ if ( file_exists($content['BASEPATH'] . "install.php") )
+ $strinstallmsg = '
SQL Statement: " . $sqlselect );
+
+ // Default return false
+ return false;
+ }
+}
+
+function DoLogOff()
+{
+ global $content;
+
+ unset( $_SESSION['SESSION_LOGGEDIN'] );
+ unset( $_SESSION['SESSION_USERNAME'] );
+ unset( $_SESSION['SESSION_ACCESSLEVEL'] );
+
+ // Redir to Index Page
+ RedirectPage( "index.php");
+}
+
+function RedirectToUserLogin()
+{
+ // TODO Referer
+ header("Location: login.php?referer=" . $_SERVER['PHP_SELF']);
+ exit;
+}
+
+function RedirectToDatabaseUpgrade()
+{
+ // TODO Referer
+ header("Location: upgrade.php"); // ?referer=" . $_SERVER['PHP_SELF']);
+ exit;
+}
+// --- END Usermanagement Function ---
+
+
+?>
diff --git a/src/include/functions_config.php b/src/include/functions_config.php
index 639aed9..cab5b6b 100644
--- a/src/include/functions_config.php
+++ b/src/include/functions_config.php
@@ -1,143 +1,143 @@
- www.phplogcon.org <- *
- * ----------------------------------------------------------------- *
- * Maintain and read Source Configurations *
- * *
- * -> Configuration need variables for the Database connection *
- *
- * Copyright (C) 2008 Adiscon GmbH.
- *
- * This file is part of phpLogCon.
- *
- * PhpLogCon is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhpLogCon is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpLogCon. If not, see .
- *
- * A copy of the GPL can be found in the file "COPYING" in this
- * distribution.
- *********************************************************************
- */
-
- // --- Avoid directly accessing this file!
- if ( !defined('IN_PHPLOGCON') )
- {
- die('Hacking attempt');
- exit;
- }
- // ---
-
- // --- Perform necessary includes
- require_once($gl_root_path . 'classes/logstreamconfig.class.php');
- // ---
-
- function InitSourceConfigs()
- {
- global $CFG, $content, $currentSourceID, $gl_root_path;
-
- // Init Source Configs!
- if ( isset($CFG['Sources']) )
- {
- $iCount = count($CFG['Sources']);
- foreach( $CFG['Sources'] as &$mysource )
- {
- if ( isset($mysource['SourceType']) )
- {
- // Set Array Index, TODO: Check for invalid characters!
- $iSourceID = $mysource['ID'];
- // Copy general properties
-// $content['Sources'][$iSourceID]['ID'] = $mysource['ID'];
-// $content['Sources'][$iSourceID]['Name'] = $mysource['Name'];
-// $content['Sources'][$iSourceID]['SourceType'] = $mysource['SourceType'];
-
- // Set default if not set!
- if ( !isset($mysource['LogLineType']) )
- $content['Sources'][$iSourceID]['LogLineType'] = "syslog";
-
- // 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');
-
- $content['Sources'][$iSourceID]['ObjRef'] = new LogStreamConfigDisk();
- $content['Sources'][$iSourceID]['ObjRef']->FileName = $mysource['DiskFile'];
- $content['Sources'][$iSourceID]['ObjRef']->LineParserType = $mysource['LogLineType'];
- }
- else if ( $mysource['SourceType'] == SOURCE_DB )
- {
- // Perform necessary include
- require_once($gl_root_path . 'classes/logstreamconfigdb.class.php');
-
- $content['Sources'][$iSourceID]['ObjRef'] = new LogStreamConfigDB();
- $content['Sources'][$iSourceID]['ObjRef']->DBServer = $mysource['DBServer'];
- $content['Sources'][$iSourceID]['ObjRef']->DBName = $mysource['DBName'];
- $content['Sources'][$iSourceID]['ObjRef']->DBType = $mysource['DBType'];
- $content['Sources'][$iSourceID]['ObjRef']->DBTableName = $mysource['DBTableName'];
-
- // Legacy handling for tabletype!
- if ( isset($mysource['DBTableType']) && strtolower($mysource['DBTableType']) == "winsyslog" )
- $content['Sources'][$iSourceID]['ObjRef']->DBTableType = "monitorware"; // Convert to MonitorWare!
- else
- $content['Sources'][$iSourceID]['ObjRef']->DBTableType = strtolower($mysource['DBTableType']);
-
- // Optional parameters!
- if ( isset($mysource['DBPort']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBPort = $mysource['DBPort']; }
- if ( isset($mysource['DBUser']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBUser = $mysource['DBUser']; }
- if ( isset($mysource['DBPassword']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBPassword = $mysource['DBPassword']; }
- }
- else
- {
- // UNKNOWN, remove config entry!
- unset($content['Sources'][$iSourceID]);
-
- // TODO: Output CONFIG WARNING
- die( "Not supported yet!" );
- }
-
- // Set generic configuration options
- $content['Sources'][$iSourceID]['ObjRef']->_pageCount = $CFG['ViewEntriesPerPage'];
-
- // Set default SourceID here!
- if ( isset($content['Sources'][$iSourceID]) && !isset($currentSourceID) )
- $currentSourceID = $iSourceID;
- }
- }
- }
-
- // Read SourceID from GET Querystring
- if ( isset($_GET['sourceid']) && isset($content['Sources'][$_GET['sourceid']]) )
- {
- $currentSourceID = $_GET['sourceid'];
- $_SESSION['currentSourceID'] = $currentSourceID;
- }
- else
- {
- // Set Source from session if available!
- if ( isset($_SESSION['currentSourceID']) && isset($content['Sources'][$_SESSION['currentSourceID']]) )
- $currentSourceID = $_SESSION['currentSourceID'];
- else
- {
- // No Source stored in session, then to so now!
- $_SESSION['currentSourceID'] = $currentSourceID;
- }
- }
-
- // Set for the selection box in the header
- $content['Sources'][$currentSourceID]['selected'] = "selected";
- }
-
-?>
+ www.phplogcon.org <- *
+ * ----------------------------------------------------------------- *
+ * Maintain and read Source Configurations *
+ * *
+ * -> Configuration need variables for the Database connection *
+ *
+ * Copyright (C) 2008 Adiscon GmbH.
+ *
+ * This file is part of phpLogCon.
+ *
+ * PhpLogCon is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * PhpLogCon is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpLogCon. If not, see .
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this
+ * distribution.
+ *********************************************************************
+ */
+
+ // --- Avoid directly accessing this file!
+ if ( !defined('IN_PHPLOGCON') )
+ {
+ die('Hacking attempt');
+ exit;
+ }
+ // ---
+
+ // --- Perform necessary includes
+ require_once($gl_root_path . 'classes/logstreamconfig.class.php');
+ // ---
+
+ function InitSourceConfigs()
+ {
+ global $CFG, $content, $currentSourceID, $gl_root_path;
+
+ // Init Source Configs!
+ if ( isset($CFG['Sources']) )
+ {
+ $iCount = count($CFG['Sources']);
+ foreach( $CFG['Sources'] as &$mysource )
+ {
+ if ( isset($mysource['SourceType']) )
+ {
+ // Set Array Index, TODO: Check for invalid characters!
+ $iSourceID = $mysource['ID'];
+ // Copy general properties
+// $content['Sources'][$iSourceID]['ID'] = $mysource['ID'];
+// $content['Sources'][$iSourceID]['Name'] = $mysource['Name'];
+// $content['Sources'][$iSourceID]['SourceType'] = $mysource['SourceType'];
+
+ // Set default if not set!
+ if ( !isset($mysource['LogLineType']) )
+ $content['Sources'][$iSourceID]['LogLineType'] = "syslog";
+
+ // 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');
+
+ $content['Sources'][$iSourceID]['ObjRef'] = new LogStreamConfigDisk();
+ $content['Sources'][$iSourceID]['ObjRef']->FileName = $mysource['DiskFile'];
+ $content['Sources'][$iSourceID]['ObjRef']->LineParserType = $mysource['LogLineType'];
+ }
+ else if ( $mysource['SourceType'] == SOURCE_DB )
+ {
+ // Perform necessary include
+ require_once($gl_root_path . 'classes/logstreamconfigdb.class.php');
+
+ $content['Sources'][$iSourceID]['ObjRef'] = new LogStreamConfigDB();
+ $content['Sources'][$iSourceID]['ObjRef']->DBServer = $mysource['DBServer'];
+ $content['Sources'][$iSourceID]['ObjRef']->DBName = $mysource['DBName'];
+ $content['Sources'][$iSourceID]['ObjRef']->DBType = $mysource['DBType'];
+ $content['Sources'][$iSourceID]['ObjRef']->DBTableName = $mysource['DBTableName'];
+
+ // Legacy handling for tabletype!
+ if ( isset($mysource['DBTableType']) && strtolower($mysource['DBTableType']) == "winsyslog" )
+ $content['Sources'][$iSourceID]['ObjRef']->DBTableType = "monitorware"; // Convert to MonitorWare!
+ else
+ $content['Sources'][$iSourceID]['ObjRef']->DBTableType = strtolower($mysource['DBTableType']);
+
+ // Optional parameters!
+ if ( isset($mysource['DBPort']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBPort = $mysource['DBPort']; }
+ if ( isset($mysource['DBUser']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBUser = $mysource['DBUser']; }
+ if ( isset($mysource['DBPassword']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBPassword = $mysource['DBPassword']; }
+ }
+ else
+ {
+ // UNKNOWN, remove config entry!
+ unset($content['Sources'][$iSourceID]);
+
+ // TODO: Output CONFIG WARNING
+ die( "Not supported yet!" );
+ }
+
+ // Set generic configuration options
+ $content['Sources'][$iSourceID]['ObjRef']->_pageCount = $CFG['ViewEntriesPerPage'];
+
+ // Set default SourceID here!
+ if ( isset($content['Sources'][$iSourceID]) && !isset($currentSourceID) )
+ $currentSourceID = $iSourceID;
+ }
+ }
+ }
+
+ // Read SourceID from GET Querystring
+ if ( isset($_GET['sourceid']) && isset($content['Sources'][$_GET['sourceid']]) )
+ {
+ $currentSourceID = $_GET['sourceid'];
+ $_SESSION['currentSourceID'] = $currentSourceID;
+ }
+ else
+ {
+ // Set Source from session if available!
+ if ( isset($_SESSION['currentSourceID']) && isset($content['Sources'][$_SESSION['currentSourceID']]) )
+ $currentSourceID = $_SESSION['currentSourceID'];
+ else
+ {
+ // No Source stored in session, then to so now!
+ $_SESSION['currentSourceID'] = $currentSourceID;
+ }
+ }
+
+ // Set for the selection box in the header
+ $content['Sources'][$currentSourceID]['selected'] = "selected";
+ }
+
+?>
diff --git a/src/include/functions_db.php b/src/include/functions_db.php
index ce89485..b2e0283 100644
--- a/src/include/functions_db.php
+++ b/src/include/functions_db.php
@@ -1,340 +1,340 @@
- www.phplogcon.org <- *
- * ----------------------------------------------------------------- *
- * DB Function Helper File *
- * *
- * -> Needed to establish and maintain the DB connetion *
- * *
- * All directives are explained within this file *
- *
- * Copyright (C) 2008 Adiscon GmbH.
- *
- * This file is part of phpLogCon.
- *
- * PhpLogCon is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhpLogCon is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpLogCon. If not, see .
- *
- * A copy of the GPL can be found in the file "COPYING" in this
- * distribution.
- *********************************************************************
-*/
-
-// --- Avoid directly accessing this file!
-if ( !defined('IN_PHPLOGCON') )
-{
- die('Hacking attempt');
- exit;
-}
-// ---
-
-
-$link_id = 0;
-$errdesc = "";
-$errno = 0;
-
-// --- Current Database Version, this is important for automated database Updates!
-$content['database_internalversion'] = "1"; // Whenever incremented, a database upgrade is needed
-$content['database_installedversion'] = "0"; // 0 is default which means Prior Versioning Database
-// ---
-
-function DB_Connect()
-{
- global $link_id, $CFG;
-
- //TODO: Check variables first
- $link_id = mysql_connect($CFG['DBServer'],$CFG['User'],$CFG['Pass']);
- if (!$link_id)
- DB_PrintError("Link-ID == false, connect to ".$CFG['DBServer']." failed", true);
-
- // --- Now, check Mysql DB Version!
- $strmysqlver = mysql_get_server_info();
- if ( strpos($strmysqlver, "-") !== false )
- {
- $sttmp = explode("-", $strmysqlver );
- $szVerInfo = $sttmp[0];
- }
- else
- $szVerInfo = $strmysqlver;
-
- $szVerSplit = explode(".", $szVerInfo );
-
- //Now check for Major Version
- if ( $szVerSplit[0] <= 3 )
- {
- //Unfortunatelly MYSQL 3.x is NOT Supported dude!
- DieWithFriendlyErrorMsg( "You are running an MySQL 3.x Database Server Version. Unfortunately MySQL 3.x is NOT supported by PhpLogCon due the limited SQL Statement support. If this is a commercial webspace, contact your webhoster in order to upgrade to a higher MySQL Database Version. If this is your own rootserver, consider updating your MySQL Server.");
- }
- // ---
-
- $db_selected = mysql_select_db($CFG['DBName'], $link_id);
- if(!$db_selected)
- DB_PrintError("Cannot use database '" . $CFG['DBName'] . "'", true);
- // :D Success connecting to db
-}
-
-function DB_Disconnect()
-{
- global $link_id;
- mysql_close($link_id);
-}
-
-function DB_Query($query_string, $bProcessError = true, $bCritical = false)
-{
- // --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
- return;
- // ---
-
- global $link_id, $querycount;
- $query_id = mysql_query($query_string,$link_id);
- if (!$query_id && $bProcessError)
- DB_PrintError("Invalid SQL: ".$query_string, $bCritical);
-
- // For the Stats ;)
- $querycount++;
-
- return $query_id;
-}
-
-function DB_FreeQuery($query_id)
-{
- // --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
- return;
- // ---
-
- if ($query_id != false && $query_id != 1 )
- mysql_free_result($query_id);
-}
-
-function DB_GetRow($query_id)
-{
- // --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
- return;
- // ---
-
- $tmp = mysql_fetch_row($query_id);
- $results[] = $tmp;
- return $results[0];
-}
-
-function DB_GetSingleRow($query_id, $bClose)
-{
- // --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
- return;
- // ---
-
- if ($query_id != false && $query_id != 1 )
- {
- $row = mysql_fetch_array($query_id, MYSQL_ASSOC);
-
- if ( $bClose )
- DB_FreeQuery ($query_id);
-
- if ( isset($row) )
- {
- // Return array
- return $row;
- }
- else
- return;
- }
-}
-
-function DB_GetAllRows($query_id, $bClose)
-{
- // --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
- return;
- // ---
-
- if ($query_id != false && $query_id != 1 )
- {
- while ($row = mysql_fetch_array($query_id, MYSQL_ASSOC))
- $var[] = $row;
-
- if ( $bClose )
- DB_FreeQuery ($query_id);
-
- if ( isset($var) )
- {
- // Return array
- return $var;
- }
- else
- return;
- }
-}
-
-function DB_GetMysqlStats()
-{
- // --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
- return;
- // ---
-
- global $link_id;
- $status = explode(' ', mysql_stat($link_id));
- return $status;
-}
-
-function DB_ReturnSimpleErrorMsg()
-{
- // Return Mysql Error
- return "Mysql Error " . mysql_errno() . " - Description: " . mysql_error();
-}
-
-function DB_PrintError($MyErrorMsg, $DieOrNot)
-{
- global $n,$HTTP_COOKIE_VARS, $errdesc, $errno, $linesep, $CFG;
-
- $errdesc = mysql_error();
- $errno = mysql_errno();
-
- $errormsg="Database error: $MyErrorMsg $linesep";
- $errormsg.="mysql error: $errdesc $linesep";
- $errormsg.="mysql error number: $errno $linesep";
- $errormsg.="Date: ".date("d.m.Y @ H:i").$linesep;
- $errormsg.="Script: ".getenv("REQUEST_URI").$linesep;
- $errormsg.="Referer: ".getenv("HTTP_REFERER").$linesep;
-
- if ($DieOrNot == true)
- DieWithErrorMsg( "$linesep" . $errormsg );
- else
- echo $errormsg;
-}
-
-function DB_RemoveParserSpecialBadChars($myString)
-{
-// DO NOT REPLACD! $returnstr = str_replace("\\","\\\\",$myString);
- $returnstr = str_replace("'","\\'",$myString);
- return $returnstr;
-}
-
-function DB_RemoveBadChars($myString)
-{
- $returnstr = str_replace("\\","\\\\",$myString);
- $returnstr = str_replace("'","\\'",$returnstr);
- return $returnstr;
-}
-
-function DB_GetRowCount($query)
-{
- // --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
- return;
- // ---
-
- if ($result = mysql_query($query))
- {
- $num_rows = mysql_num_rows($result);
- mysql_free_result ($result);
- }
- return $num_rows;
-}
-
-function DB_GetRowCountByResult($myresult)
-{
- // --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
- return;
- // ---
-
- if ($myresult)
- return mysql_num_rows($myresult);
-}
-
-function DB_Exec($query)
-{
- // --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
- return;
- // ---
-
- if(mysql_query($query))
- return true;
- else
- return false;
-}
-
-function WriteConfigValue($szValue)
-{
- // --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
- return;
- // ---
-
- global $content;
-
- $result = DB_Query("SELECT name FROM " . STATS_CONFIG . " WHERE name = '" . $szValue . "'");
- $rows = DB_GetAllRows($result, true);
- if ( !isset($rows) )
- {
- // New Entry
- $result = DB_Query("INSERT INTO " . STATS_CONFIG . " (name, value) VALUES ( '" . $szValue . "', '" . $content[$szValue] . "')");
- DB_FreeQuery($result);
- }
- else
- {
- // Update Entry
- $result = DB_Query("UPDATE " . STATS_CONFIG . " SET value = '" . $content[$szValue] . "' WHERE name = '" . $szValue . "'");
- DB_FreeQuery($result);
- }
-}
-
-function GetSingleDBEntryOnly( $myqry )
-{
- // --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
- return;
- // ---
-
- $result = DB_Query( $myqry );
- $row = DB_GetRow($result);
- DB_FreeQuery ($query_id);
-
- if ( isset($row) )
- return $row[0];
- else
- return -1;
-}
-
-function GetRowsAffected()
-{
- // --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
- return;
- // ---
-
- return mysql_affected_rows();
-}
-
-
-
-?>
+ www.phplogcon.org <- *
+ * ----------------------------------------------------------------- *
+ * DB Function Helper File *
+ * *
+ * -> Needed to establish and maintain the DB connetion *
+ * *
+ * All directives are explained within this file *
+ *
+ * Copyright (C) 2008 Adiscon GmbH.
+ *
+ * This file is part of phpLogCon.
+ *
+ * PhpLogCon is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * PhpLogCon is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpLogCon. If not, see .
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this
+ * distribution.
+ *********************************************************************
+*/
+
+// --- Avoid directly accessing this file!
+if ( !defined('IN_PHPLOGCON') )
+{
+ die('Hacking attempt');
+ exit;
+}
+// ---
+
+
+$link_id = 0;
+$errdesc = "";
+$errno = 0;
+
+// --- Current Database Version, this is important for automated database Updates!
+$content['database_internalversion'] = "1"; // Whenever incremented, a database upgrade is needed
+$content['database_installedversion'] = "0"; // 0 is default which means Prior Versioning Database
+// ---
+
+function DB_Connect()
+{
+ global $link_id, $CFG;
+
+ //TODO: Check variables first
+ $link_id = mysql_connect($CFG['DBServer'],$CFG['User'],$CFG['Pass']);
+ if (!$link_id)
+ DB_PrintError("Link-ID == false, connect to ".$CFG['DBServer']." failed", true);
+
+ // --- Now, check Mysql DB Version!
+ $strmysqlver = mysql_get_server_info();
+ if ( strpos($strmysqlver, "-") !== false )
+ {
+ $sttmp = explode("-", $strmysqlver );
+ $szVerInfo = $sttmp[0];
+ }
+ else
+ $szVerInfo = $strmysqlver;
+
+ $szVerSplit = explode(".", $szVerInfo );
+
+ //Now check for Major Version
+ if ( $szVerSplit[0] <= 3 )
+ {
+ //Unfortunatelly MYSQL 3.x is NOT Supported dude!
+ DieWithFriendlyErrorMsg( "You are running an MySQL 3.x Database Server Version. Unfortunately MySQL 3.x is NOT supported by PhpLogCon due the limited SQL Statement support. If this is a commercial webspace, contact your webhoster in order to upgrade to a higher MySQL Database Version. If this is your own rootserver, consider updating your MySQL Server.");
+ }
+ // ---
+
+ $db_selected = mysql_select_db($CFG['DBName'], $link_id);
+ if(!$db_selected)
+ DB_PrintError("Cannot use database '" . $CFG['DBName'] . "'", true);
+ // :D Success connecting to db
+}
+
+function DB_Disconnect()
+{
+ global $link_id;
+ mysql_close($link_id);
+}
+
+function DB_Query($query_string, $bProcessError = true, $bCritical = false)
+{
+ // --- Abort in this case!
+ global $CFG;
+ if ( $CFG['UserDBEnabled'] == false )
+ return;
+ // ---
+
+ global $link_id, $querycount;
+ $query_id = mysql_query($query_string,$link_id);
+ if (!$query_id && $bProcessError)
+ DB_PrintError("Invalid SQL: ".$query_string, $bCritical);
+
+ // For the Stats ;)
+ $querycount++;
+
+ return $query_id;
+}
+
+function DB_FreeQuery($query_id)
+{
+ // --- Abort in this case!
+ global $CFG;
+ if ( $CFG['UserDBEnabled'] == false )
+ return;
+ // ---
+
+ if ($query_id != false && $query_id != 1 )
+ mysql_free_result($query_id);
+}
+
+function DB_GetRow($query_id)
+{
+ // --- Abort in this case!
+ global $CFG;
+ if ( $CFG['UserDBEnabled'] == false )
+ return;
+ // ---
+
+ $tmp = mysql_fetch_row($query_id);
+ $results[] = $tmp;
+ return $results[0];
+}
+
+function DB_GetSingleRow($query_id, $bClose)
+{
+ // --- Abort in this case!
+ global $CFG;
+ if ( $CFG['UserDBEnabled'] == false )
+ return;
+ // ---
+
+ if ($query_id != false && $query_id != 1 )
+ {
+ $row = mysql_fetch_array($query_id, MYSQL_ASSOC);
+
+ if ( $bClose )
+ DB_FreeQuery ($query_id);
+
+ if ( isset($row) )
+ {
+ // Return array
+ return $row;
+ }
+ else
+ return;
+ }
+}
+
+function DB_GetAllRows($query_id, $bClose)
+{
+ // --- Abort in this case!
+ global $CFG;
+ if ( $CFG['UserDBEnabled'] == false )
+ return;
+ // ---
+
+ if ($query_id != false && $query_id != 1 )
+ {
+ while ($row = mysql_fetch_array($query_id, MYSQL_ASSOC))
+ $var[] = $row;
+
+ if ( $bClose )
+ DB_FreeQuery ($query_id);
+
+ if ( isset($var) )
+ {
+ // Return array
+ return $var;
+ }
+ else
+ return;
+ }
+}
+
+function DB_GetMysqlStats()
+{
+ // --- Abort in this case!
+ global $CFG;
+ if ( $CFG['UserDBEnabled'] == false )
+ return;
+ // ---
+
+ global $link_id;
+ $status = explode(' ', mysql_stat($link_id));
+ return $status;
+}
+
+function DB_ReturnSimpleErrorMsg()
+{
+ // Return Mysql Error
+ return "Mysql Error " . mysql_errno() . " - Description: " . mysql_error();
+}
+
+function DB_PrintError($MyErrorMsg, $DieOrNot)
+{
+ global $n,$HTTP_COOKIE_VARS, $errdesc, $errno, $linesep, $CFG;
+
+ $errdesc = mysql_error();
+ $errno = mysql_errno();
+
+ $errormsg="Database error: $MyErrorMsg $linesep";
+ $errormsg.="mysql error: $errdesc $linesep";
+ $errormsg.="mysql error number: $errno $linesep";
+ $errormsg.="Date: ".date("d.m.Y @ H:i").$linesep;
+ $errormsg.="Script: ".getenv("REQUEST_URI").$linesep;
+ $errormsg.="Referer: ".getenv("HTTP_REFERER").$linesep;
+
+ if ($DieOrNot == true)
+ DieWithErrorMsg( "$linesep" . $errormsg );
+ else
+ echo $errormsg;
+}
+
+function DB_RemoveParserSpecialBadChars($myString)
+{
+// DO NOT REPLACD! $returnstr = str_replace("\\","\\\\",$myString);
+ $returnstr = str_replace("'","\\'",$myString);
+ return $returnstr;
+}
+
+function DB_RemoveBadChars($myString)
+{
+ $returnstr = str_replace("\\","\\\\",$myString);
+ $returnstr = str_replace("'","\\'",$returnstr);
+ return $returnstr;
+}
+
+function DB_GetRowCount($query)
+{
+ // --- Abort in this case!
+ global $CFG;
+ if ( $CFG['UserDBEnabled'] == false )
+ return;
+ // ---
+
+ if ($result = mysql_query($query))
+ {
+ $num_rows = mysql_num_rows($result);
+ mysql_free_result ($result);
+ }
+ return $num_rows;
+}
+
+function DB_GetRowCountByResult($myresult)
+{
+ // --- Abort in this case!
+ global $CFG;
+ if ( $CFG['UserDBEnabled'] == false )
+ return;
+ // ---
+
+ if ($myresult)
+ return mysql_num_rows($myresult);
+}
+
+function DB_Exec($query)
+{
+ // --- Abort in this case!
+ global $CFG;
+ if ( $CFG['UserDBEnabled'] == false )
+ return;
+ // ---
+
+ if(mysql_query($query))
+ return true;
+ else
+ return false;
+}
+
+function WriteConfigValue($szValue)
+{
+ // --- Abort in this case!
+ global $CFG;
+ if ( $CFG['UserDBEnabled'] == false )
+ return;
+ // ---
+
+ global $content;
+
+ $result = DB_Query("SELECT name FROM " . STATS_CONFIG . " WHERE name = '" . $szValue . "'");
+ $rows = DB_GetAllRows($result, true);
+ if ( !isset($rows) )
+ {
+ // New Entry
+ $result = DB_Query("INSERT INTO " . STATS_CONFIG . " (name, value) VALUES ( '" . $szValue . "', '" . $content[$szValue] . "')");
+ DB_FreeQuery($result);
+ }
+ else
+ {
+ // Update Entry
+ $result = DB_Query("UPDATE " . STATS_CONFIG . " SET value = '" . $content[$szValue] . "' WHERE name = '" . $szValue . "'");
+ DB_FreeQuery($result);
+ }
+}
+
+function GetSingleDBEntryOnly( $myqry )
+{
+ // --- Abort in this case!
+ global $CFG;
+ if ( $CFG['UserDBEnabled'] == false )
+ return;
+ // ---
+
+ $result = DB_Query( $myqry );
+ $row = DB_GetRow($result);
+ DB_FreeQuery ($query_id);
+
+ if ( isset($row) )
+ return $row[0];
+ else
+ return -1;
+}
+
+function GetRowsAffected()
+{
+ // --- Abort in this case!
+ global $CFG;
+ if ( $CFG['UserDBEnabled'] == false )
+ return;
+ // ---
+
+ return mysql_affected_rows();
+}
+
+
+
+?>
diff --git a/src/include/functions_filters.php b/src/include/functions_filters.php
index ba439ec..a113001 100644
--- a/src/include/functions_filters.php
+++ b/src/include/functions_filters.php
@@ -1,257 +1,257 @@
- www.phplogcon.org <- *
- * ----------------------------------------------------------------- *
- * Filter Helper functions for the frontend *
- *
- * Copyright (C) 2008 Adiscon GmbH.
- *
- * This file is part of phpLogCon.
- *
- * PhpLogCon is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhpLogCon is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpLogCon. If not, see .
- *
- * A copy of the GPL can be found in the file "COPYING" in this
- * distribution.
- *********************************************************************
-*/
-
-// --- Avoid directly accessing this file!
-if ( !defined('IN_PHPLOGCON') )
-{
- die('Hacking attempt');
- exit;
-}
-// ---
-
-// --- Perform necessary includes
-require_once($gl_root_path . 'include/constants_filters.php');
-// ---
-
-function InitFilterHelpers()
-{
- global $CFG, $content, $filters;
-
- // Init Default DateMode from SESSION!
- if ( isset($_SESSION['filter_datemode']) )
- $filters['filter_datemode'] = intval($_SESSION['filter_datemode']);
- else
- $filters['filter_datemode'] = DATEMODE_ALL;
-
- // Init TimeFilter Helper Array
- $content['datemodes'][0]['ID'] = DATEMODE_ALL;
- $content['datemodes'][0]['DisplayName'] = $content['LN_DATEMODE_ALL'];
- if ( $filters['filter_datemode'] == DATEMODE_ALL ) { $content['datemodes'][0]['selected'] = "selected"; } else { $content['datemodes'][0]['selected'] = ""; }
- $content['datemodes'][1]['ID'] = DATEMODE_RANGE;
- $content['datemodes'][1]['DisplayName'] = $content['LN_DATEMODE_RANGE'];
- if ( $filters['filter_datemode'] == DATEMODE_RANGE ) { $content['datemodes'][1]['selected'] = "selected"; } else { $content['datemodes'][1]['selected'] = ""; }
- $content['datemodes'][2]['ID'] = DATEMODE_LASTX;
- $content['datemodes'][2]['DisplayName'] = $content['LN_DATEMODE_LASTX'];
- if ( $filters['filter_datemode'] == DATEMODE_LASTX ) { $content['datemodes'][2]['selected'] = "selected"; } else { $content['datemodes'][2]['selected'] = ""; }
-
- // Init Date Range Parameters
- $currentTime = time();
- $currentDay = date("d", $currentTime);
- $currentMonth = date("m", $currentTime);
- $currentYear = date("Y", $currentTime);
-
- $tomorrowTime = time(); // + 86400; // Add one day!
- $tomorrowDay = date("d", $tomorrowTime);
- $tomorrowMonth = date("m", $tomorrowTime);
- $tomorrowYear = date("Y", $tomorrowTime);
-
- // Init Year, month and day array!
- for ( $i = $currentYear-5; $i <= $currentYear+5; $i++ )
- $content['years'][] = $i;
- for ( $i = 1; $i <= 12; $i++ )
- $content['months'][] = $i;
- for ( $i = 1; $i <= 31; $i++ )
- $content['days'][] = $i;
-
- // Init filter_daterange_from_year
- if ( isset($_SESSION['filter_daterange_from_year']) )
- $filters['filter_daterange_from_year'] = intval($_SESSION['filter_daterange_from_year']);
- else
- $filters['filter_daterange_from_year'] = $currentYear-1;
- FillDateRangeArray($content['years'], "filter_daterange_from_year_list", "filter_daterange_from_year");
-
- // Init filter_daterange_from_month
- if ( isset($_SESSION['filter_daterange_from_month']) )
- $filters['filter_daterange_from_month'] = intval($_SESSION['filter_daterange_from_month']);
- else
- $filters['filter_daterange_from_month'] = $currentMonth;
- FillDateRangeArray($content['months'], "filter_daterange_from_month_list", "filter_daterange_from_month");
-
- // Init filter_daterange_from_day
- if ( isset($_SESSION['filter_daterange_from_day']) )
- $filters['filter_daterange_from_day'] = intval($_SESSION['filter_daterange_from_day']);
- else
- $filters['filter_daterange_from_day'] = $currentDay;
- FillDateRangeArray($content['days'], "filter_daterange_from_day_list", "filter_daterange_from_day");
-
- // Init filter_daterange_to_year
- if ( isset($_SESSION['filter_daterange_to_year']) )
- $filters['filter_daterange_to_year'] = intval($_SESSION['filter_daterange_to_year']);
- else
- $filters['filter_daterange_to_year'] = $tomorrowYear;
- FillDateRangeArray($content['years'], "filter_daterange_to_year_list", "filter_daterange_to_year");
-
- // Init filter_daterange_to_month
- if ( isset($_SESSION['filter_daterange_to_month']) )
- $filters['filter_daterange_to_month'] = intval($_SESSION['filter_daterange_to_month']);
- else
- $filters['filter_daterange_to_month'] = $tomorrowMonth;
- FillDateRangeArray($content['months'], "filter_daterange_to_month_list", "filter_daterange_to_month");
-
- // Init filter_daterange_to_day
- if ( isset($_SESSION['filter_daterange_to_day']) )
- $filters['filter_daterange_to_day'] = intval($_SESSION['filter_daterange_to_day']);
- else
- $filters['filter_daterange_to_day'] = $tomorrowDay;
- FillDateRangeArray($content['days'], "filter_daterange_to_day_list", "filter_daterange_to_day");
-
- // --- Define LASTX Array
-
- // Init Default DateMode from SESSION!
- if ( isset($_SESSION['filter_lastx_default']) )
- $filters['filter_lastx_default'] = intval($_SESSION['filter_lastx_default']);
- else
- $filters['filter_lastx_default'] = DATE_LASTX_24HOURS;
-
- $content['filter_daterange_last_x_list'][0]['ID'] = DATE_LASTX_HOUR;
- $content['filter_daterange_last_x_list'][0]['DisplayName'] = $content['LN_DATE_LASTX_HOUR'];
- if ( $filters['filter_lastx_default'] == DATE_LASTX_HOUR ) { $content['filter_daterange_last_x_list'][0]['selected'] = "selected"; } else { $content['filter_daterange_last_x_list'][0]['selected'] = ""; }
-
- $content['filter_daterange_last_x_list'][1]['ID'] = DATE_LASTX_12HOURS;
- $content['filter_daterange_last_x_list'][1]['DisplayName'] = $content['LN_DATE_LASTX_12HOURS'];
- if ( $filters['filter_lastx_default'] == DATE_LASTX_12HOURS ) { $content['filter_daterange_last_x_list'][1]['selected'] = "selected"; } else { $content['filter_daterange_last_x_list'][1]['selected'] = ""; }
-
- $content['filter_daterange_last_x_list'][2]['ID'] = DATE_LASTX_24HOURS;
- $content['filter_daterange_last_x_list'][2]['DisplayName'] = $content['LN_DATE_LASTX_24HOURS'];
- if ( $filters['filter_lastx_default'] == DATE_LASTX_24HOURS ) { $content['filter_daterange_last_x_list'][2]['selected'] = "selected"; } else { $content['filter_daterange_last_x_list'][2]['selected'] = ""; }
-
- $content['filter_daterange_last_x_list'][3]['ID'] = DATE_LASTX_7DAYS;
- $content['filter_daterange_last_x_list'][3]['DisplayName'] = $content['LN_DATE_LASTX_7DAYS'];
- if ( $filters['filter_lastx_default'] == DATE_LASTX_7DAYS ) { $content['filter_daterange_last_x_list'][3]['selected'] = "selected"; } else { $content['filter_daterange_last_x_list'][3]['selected'] = ""; }
-
- $content['filter_daterange_last_x_list'][4]['ID'] = DATE_LASTX_31DAYS;
- $content['filter_daterange_last_x_list'][4]['DisplayName'] = $content['LN_DATE_LASTX_31DAYS'];
- if ( $filters['filter_lastx_default'] == DATE_LASTX_31DAYS ) { $content['filter_daterange_last_x_list'][4]['selected'] = "selected"; } else { $content['filter_daterange_last_x_list'][4]['selected'] = ""; }
- // ---
-
- // Init Default Syslog Facility from SESSION!
- if ( isset($_SESSION['filter_facility']) )
- $filters['filter_facility'] = intval($_SESSION['filter_facility']);
- else
- $filters['filter_facility'] = array ( SYSLOG_KERN, SYSLOG_USER, SYSLOG_MAIL, SYSLOG_DAEMON, SYSLOG_AUTH, SYSLOG_SYSLOG, SYSLOG_LPR, SYSLOG_NEWS, SYSLOG_UUCP, SYSLOG_CRON, SYSLOG_LOCAL0, SYSLOG_LOCAL1, SYSLOG_LOCAL2, SYSLOG_LOCAL3, SYSLOG_LOCAL4, SYSLOG_LOCAL5, SYSLOG_LOCAL6, SYSLOG_LOCAL7 );
-// $filters['filter_facility'] = SYSLOG_LOCAL0;
-
- $iCount = count($content['filter_facility_list']);
- for ( $i = 0; $i < $iCount; $i++ )
- {
-// echo $content['filter_facility_list'][$i]["ID"] . "-" . $filters['filter_facility'] . " ";
- if ( in_array($content['filter_facility_list'][$i]["ID"], $filters['filter_facility']) )
- $content['filter_facility_list'][$i]["selected"] = "selected";
- }
-
- // Init Default Syslog Severity from SESSION!
- if ( isset($_SESSION['filter_severity']) )
- $filters['filter_severity'] = intval($_SESSION['filter_severity']);
- else
- $filters['filter_severity'] = array ( SYSLOG_EMERG, SYSLOG_ALERT, SYSLOG_CRIT, SYSLOG_ERR, SYSLOG_WARNING, SYSLOG_NOTICE, SYSLOG_INFO, SYSLOG_DEBUG );
-// $filters['filter_severity'] = SYSLOG_NOTICE;
-
- $iCount = count($content['filter_severity_list']);
- for ( $i = 0; $i < $iCount; $i++ )
- {
- if ( in_array( $content['filter_severity_list'][$i]["ID"], $filters['filter_severity']) )
- $content['filter_severity_list'][$i]["selected"] = "selected";
- }
-
-}
-
-function FillDateRangeArray($sourcearray, $szArrayListName, $szFilterName) // $content['years'], "filter_daterange_from_year_list", "filter_daterange_from_year")
-{
- global $CFG, $content, $filters;
- $iCount = count($sourcearray);
-
- for ( $i = 0; $i < $iCount; $i++)
- {
- $content[$szArrayListName][$i]['value'] = $sourcearray[$i];
- if ( $filters[$szFilterName] == $sourcearray[$i] )
- $content[$szArrayListName][$i]['selected'] = "selected";
- else
- $content[$szArrayListName][$i]['selected'] = "";
- }
-}
-
-function GetFacilityDisplayName( $nFacilityID )
-{
- global $content;
-
- foreach( $content['filter_facility_list'] as $myfacility )
- {
- if ( $myfacility['ID'] == $nFacilityID )
- return $myfacility['DisplayName'];
- }
-
- // Default
- return "Unknown Facility($nFacilityID)";
-}
-
-function GetSeverityDisplayName( $nSeverityID )
-{
- global $content;
-
- foreach( $content['filter_severity_list'] as $myseverity )
- {
- if ( $myseverity['ID'] == $nSeverityID )
- return $myseverity['DisplayName'];
- }
-
- // Default
- return "Unknown Severity($nSeverityID)";
-}
-
-function GetMessageTypeDisplayName( $nMsgTypeID )
-{
- global $content;
-
- foreach( $content['filter_messagetype_list'] as $mymsgtype )
- {
- if ( $mymsgtype['ID'] == $nMsgTypeID )
- return $mymsgtype['DisplayName'];
- }
-
- // Default
- return "Unknown MessageType($nMsgTypeID)";
-}
-
-
-function GetTimeStampFromTimeString($szTimeString)
-{
- //Sample: 2008-4-1T00:00:00
- if ( preg_match("/([0-9]{4,4})-([0-9]{1,2})-([0-9]{1,2})T([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})$/", $szTimeString, $out) )
- {
- // return new timestamp
- return mktime($out[4], $out[5], $out[6], $out[2], $out[3], $out[1]);
- }
- else
- {
- OutputDebugMessage("Unparseable Time in GetTimeStampFromTimeString - '" . $szTimeString . "'");
- return $szTimeString;
- }
-}
-
-?>
+ www.phplogcon.org <- *
+ * ----------------------------------------------------------------- *
+ * Filter Helper functions for the frontend *
+ *
+ * Copyright (C) 2008 Adiscon GmbH.
+ *
+ * This file is part of phpLogCon.
+ *
+ * PhpLogCon is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * PhpLogCon is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpLogCon. If not, see .
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this
+ * distribution.
+ *********************************************************************
+*/
+
+// --- Avoid directly accessing this file!
+if ( !defined('IN_PHPLOGCON') )
+{
+ die('Hacking attempt');
+ exit;
+}
+// ---
+
+// --- Perform necessary includes
+require_once($gl_root_path . 'include/constants_filters.php');
+// ---
+
+function InitFilterHelpers()
+{
+ global $CFG, $content, $filters;
+
+ // Init Default DateMode from SESSION!
+ if ( isset($_SESSION['filter_datemode']) )
+ $filters['filter_datemode'] = intval($_SESSION['filter_datemode']);
+ else
+ $filters['filter_datemode'] = DATEMODE_ALL;
+
+ // Init TimeFilter Helper Array
+ $content['datemodes'][0]['ID'] = DATEMODE_ALL;
+ $content['datemodes'][0]['DisplayName'] = $content['LN_DATEMODE_ALL'];
+ if ( $filters['filter_datemode'] == DATEMODE_ALL ) { $content['datemodes'][0]['selected'] = "selected"; } else { $content['datemodes'][0]['selected'] = ""; }
+ $content['datemodes'][1]['ID'] = DATEMODE_RANGE;
+ $content['datemodes'][1]['DisplayName'] = $content['LN_DATEMODE_RANGE'];
+ if ( $filters['filter_datemode'] == DATEMODE_RANGE ) { $content['datemodes'][1]['selected'] = "selected"; } else { $content['datemodes'][1]['selected'] = ""; }
+ $content['datemodes'][2]['ID'] = DATEMODE_LASTX;
+ $content['datemodes'][2]['DisplayName'] = $content['LN_DATEMODE_LASTX'];
+ if ( $filters['filter_datemode'] == DATEMODE_LASTX ) { $content['datemodes'][2]['selected'] = "selected"; } else { $content['datemodes'][2]['selected'] = ""; }
+
+ // Init Date Range Parameters
+ $currentTime = time();
+ $currentDay = date("d", $currentTime);
+ $currentMonth = date("m", $currentTime);
+ $currentYear = date("Y", $currentTime);
+
+ $tomorrowTime = time(); // + 86400; // Add one day!
+ $tomorrowDay = date("d", $tomorrowTime);
+ $tomorrowMonth = date("m", $tomorrowTime);
+ $tomorrowYear = date("Y", $tomorrowTime);
+
+ // Init Year, month and day array!
+ for ( $i = $currentYear-5; $i <= $currentYear+5; $i++ )
+ $content['years'][] = $i;
+ for ( $i = 1; $i <= 12; $i++ )
+ $content['months'][] = $i;
+ for ( $i = 1; $i <= 31; $i++ )
+ $content['days'][] = $i;
+
+ // Init filter_daterange_from_year
+ if ( isset($_SESSION['filter_daterange_from_year']) )
+ $filters['filter_daterange_from_year'] = intval($_SESSION['filter_daterange_from_year']);
+ else
+ $filters['filter_daterange_from_year'] = $currentYear-1;
+ FillDateRangeArray($content['years'], "filter_daterange_from_year_list", "filter_daterange_from_year");
+
+ // Init filter_daterange_from_month
+ if ( isset($_SESSION['filter_daterange_from_month']) )
+ $filters['filter_daterange_from_month'] = intval($_SESSION['filter_daterange_from_month']);
+ else
+ $filters['filter_daterange_from_month'] = $currentMonth;
+ FillDateRangeArray($content['months'], "filter_daterange_from_month_list", "filter_daterange_from_month");
+
+ // Init filter_daterange_from_day
+ if ( isset($_SESSION['filter_daterange_from_day']) )
+ $filters['filter_daterange_from_day'] = intval($_SESSION['filter_daterange_from_day']);
+ else
+ $filters['filter_daterange_from_day'] = $currentDay;
+ FillDateRangeArray($content['days'], "filter_daterange_from_day_list", "filter_daterange_from_day");
+
+ // Init filter_daterange_to_year
+ if ( isset($_SESSION['filter_daterange_to_year']) )
+ $filters['filter_daterange_to_year'] = intval($_SESSION['filter_daterange_to_year']);
+ else
+ $filters['filter_daterange_to_year'] = $tomorrowYear;
+ FillDateRangeArray($content['years'], "filter_daterange_to_year_list", "filter_daterange_to_year");
+
+ // Init filter_daterange_to_month
+ if ( isset($_SESSION['filter_daterange_to_month']) )
+ $filters['filter_daterange_to_month'] = intval($_SESSION['filter_daterange_to_month']);
+ else
+ $filters['filter_daterange_to_month'] = $tomorrowMonth;
+ FillDateRangeArray($content['months'], "filter_daterange_to_month_list", "filter_daterange_to_month");
+
+ // Init filter_daterange_to_day
+ if ( isset($_SESSION['filter_daterange_to_day']) )
+ $filters['filter_daterange_to_day'] = intval($_SESSION['filter_daterange_to_day']);
+ else
+ $filters['filter_daterange_to_day'] = $tomorrowDay;
+ FillDateRangeArray($content['days'], "filter_daterange_to_day_list", "filter_daterange_to_day");
+
+ // --- Define LASTX Array
+
+ // Init Default DateMode from SESSION!
+ if ( isset($_SESSION['filter_lastx_default']) )
+ $filters['filter_lastx_default'] = intval($_SESSION['filter_lastx_default']);
+ else
+ $filters['filter_lastx_default'] = DATE_LASTX_24HOURS;
+
+ $content['filter_daterange_last_x_list'][0]['ID'] = DATE_LASTX_HOUR;
+ $content['filter_daterange_last_x_list'][0]['DisplayName'] = $content['LN_DATE_LASTX_HOUR'];
+ if ( $filters['filter_lastx_default'] == DATE_LASTX_HOUR ) { $content['filter_daterange_last_x_list'][0]['selected'] = "selected"; } else { $content['filter_daterange_last_x_list'][0]['selected'] = ""; }
+
+ $content['filter_daterange_last_x_list'][1]['ID'] = DATE_LASTX_12HOURS;
+ $content['filter_daterange_last_x_list'][1]['DisplayName'] = $content['LN_DATE_LASTX_12HOURS'];
+ if ( $filters['filter_lastx_default'] == DATE_LASTX_12HOURS ) { $content['filter_daterange_last_x_list'][1]['selected'] = "selected"; } else { $content['filter_daterange_last_x_list'][1]['selected'] = ""; }
+
+ $content['filter_daterange_last_x_list'][2]['ID'] = DATE_LASTX_24HOURS;
+ $content['filter_daterange_last_x_list'][2]['DisplayName'] = $content['LN_DATE_LASTX_24HOURS'];
+ if ( $filters['filter_lastx_default'] == DATE_LASTX_24HOURS ) { $content['filter_daterange_last_x_list'][2]['selected'] = "selected"; } else { $content['filter_daterange_last_x_list'][2]['selected'] = ""; }
+
+ $content['filter_daterange_last_x_list'][3]['ID'] = DATE_LASTX_7DAYS;
+ $content['filter_daterange_last_x_list'][3]['DisplayName'] = $content['LN_DATE_LASTX_7DAYS'];
+ if ( $filters['filter_lastx_default'] == DATE_LASTX_7DAYS ) { $content['filter_daterange_last_x_list'][3]['selected'] = "selected"; } else { $content['filter_daterange_last_x_list'][3]['selected'] = ""; }
+
+ $content['filter_daterange_last_x_list'][4]['ID'] = DATE_LASTX_31DAYS;
+ $content['filter_daterange_last_x_list'][4]['DisplayName'] = $content['LN_DATE_LASTX_31DAYS'];
+ if ( $filters['filter_lastx_default'] == DATE_LASTX_31DAYS ) { $content['filter_daterange_last_x_list'][4]['selected'] = "selected"; } else { $content['filter_daterange_last_x_list'][4]['selected'] = ""; }
+ // ---
+
+ // Init Default Syslog Facility from SESSION!
+ if ( isset($_SESSION['filter_facility']) )
+ $filters['filter_facility'] = intval($_SESSION['filter_facility']);
+ else
+ $filters['filter_facility'] = array ( SYSLOG_KERN, SYSLOG_USER, SYSLOG_MAIL, SYSLOG_DAEMON, SYSLOG_AUTH, SYSLOG_SYSLOG, SYSLOG_LPR, SYSLOG_NEWS, SYSLOG_UUCP, SYSLOG_CRON, SYSLOG_LOCAL0, SYSLOG_LOCAL1, SYSLOG_LOCAL2, SYSLOG_LOCAL3, SYSLOG_LOCAL4, SYSLOG_LOCAL5, SYSLOG_LOCAL6, SYSLOG_LOCAL7 );
+// $filters['filter_facility'] = SYSLOG_LOCAL0;
+
+ $iCount = count($content['filter_facility_list']);
+ for ( $i = 0; $i < $iCount; $i++ )
+ {
+// echo $content['filter_facility_list'][$i]["ID"] . "-" . $filters['filter_facility'] . " ";
+ if ( in_array($content['filter_facility_list'][$i]["ID"], $filters['filter_facility']) )
+ $content['filter_facility_list'][$i]["selected"] = "selected";
+ }
+
+ // Init Default Syslog Severity from SESSION!
+ if ( isset($_SESSION['filter_severity']) )
+ $filters['filter_severity'] = intval($_SESSION['filter_severity']);
+ else
+ $filters['filter_severity'] = array ( SYSLOG_EMERG, SYSLOG_ALERT, SYSLOG_CRIT, SYSLOG_ERR, SYSLOG_WARNING, SYSLOG_NOTICE, SYSLOG_INFO, SYSLOG_DEBUG );
+// $filters['filter_severity'] = SYSLOG_NOTICE;
+
+ $iCount = count($content['filter_severity_list']);
+ for ( $i = 0; $i < $iCount; $i++ )
+ {
+ if ( in_array( $content['filter_severity_list'][$i]["ID"], $filters['filter_severity']) )
+ $content['filter_severity_list'][$i]["selected"] = "selected";
+ }
+
+}
+
+function FillDateRangeArray($sourcearray, $szArrayListName, $szFilterName) // $content['years'], "filter_daterange_from_year_list", "filter_daterange_from_year")
+{
+ global $CFG, $content, $filters;
+ $iCount = count($sourcearray);
+
+ for ( $i = 0; $i < $iCount; $i++)
+ {
+ $content[$szArrayListName][$i]['value'] = $sourcearray[$i];
+ if ( $filters[$szFilterName] == $sourcearray[$i] )
+ $content[$szArrayListName][$i]['selected'] = "selected";
+ else
+ $content[$szArrayListName][$i]['selected'] = "";
+ }
+}
+
+function GetFacilityDisplayName( $nFacilityID )
+{
+ global $content;
+
+ foreach( $content['filter_facility_list'] as $myfacility )
+ {
+ if ( $myfacility['ID'] == $nFacilityID )
+ return $myfacility['DisplayName'];
+ }
+
+ // Default
+ return "Unknown Facility($nFacilityID)";
+}
+
+function GetSeverityDisplayName( $nSeverityID )
+{
+ global $content;
+
+ foreach( $content['filter_severity_list'] as $myseverity )
+ {
+ if ( $myseverity['ID'] == $nSeverityID )
+ return $myseverity['DisplayName'];
+ }
+
+ // Default
+ return "Unknown Severity($nSeverityID)";
+}
+
+function GetMessageTypeDisplayName( $nMsgTypeID )
+{
+ global $content;
+
+ foreach( $content['filter_messagetype_list'] as $mymsgtype )
+ {
+ if ( $mymsgtype['ID'] == $nMsgTypeID )
+ return $mymsgtype['DisplayName'];
+ }
+
+ // Default
+ return "Unknown MessageType($nMsgTypeID)";
+}
+
+
+function GetTimeStampFromTimeString($szTimeString)
+{
+ //Sample: 2008-4-1T00:00:00
+ if ( preg_match("/([0-9]{4,4})-([0-9]{1,2})-([0-9]{1,2})T([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})$/", $szTimeString, $out) )
+ {
+ // return new timestamp
+ return mktime($out[4], $out[5], $out[6], $out[2], $out[3], $out[1]);
+ }
+ else
+ {
+ OutputDebugMessage("Unparseable Time in GetTimeStampFromTimeString - '" . $szTimeString . "'");
+ return $szTimeString;
+ }
+}
+
+?>
diff --git a/src/include/functions_frontendhelpers.php b/src/include/functions_frontendhelpers.php
index e790e96..f93c5ec 100644
--- a/src/include/functions_frontendhelpers.php
+++ b/src/include/functions_frontendhelpers.php
@@ -1,162 +1,162 @@
- www.phplogcon.org <- *
- * ----------------------------------------------------------------- *
- * Helperfunctions for the web frontend *
- * *
- * -> *
- * *
- * All directives are explained within this file *
- *
- * Copyright (C) 2008 Adiscon GmbH.
- *
- * This file is part of phpLogCon.
- *
- * PhpLogCon is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhpLogCon is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpLogCon. If not, see .
- *
- * A copy of the GPL can be found in the file "COPYING" in this
- * distribution.
- *********************************************************************
-*/
-
-// --- Avoid directly accessing this file!
-if ( !defined('IN_PHPLOGCON') )
-{
- die('Hacking attempt');
- exit;
-}
-// ---
-
-function InitFrontEndDefaults()
-{
- // To create the current URL
- CreateCurrentUrl();
-
- // --- BEGIN Main Info Area
-
-
-
- // --- END Main Info Area
-
- // Check if install file still exists
- InstallFileReminder();
-}
-
-function InstallFileReminder()
-{
- global $content;
-
- if ( is_file($content['BASEPATH'] . "install.php") )
- {
- // No Servers - display warning!
- $content['error_installfilereminder'] = "true";
- }
-}
-
-function CreateCurrentUrl()
-{
- global $content;
- $content['CURRENTURL'] = $_SERVER['PHP_SELF']; // . "?" . $_SERVER['QUERY_STRING']
-
- // Init additional_url helper variable
- $content['additional_url'] = "";
- $content['additional_url_uidonly'] = "";
- $content['additional_url_sortingonly'] = "";
-
- // Now the query string:
- if ( isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0 )
- {
- // Append ?
- $content['CURRENTURL'] .= "?";
-
- $queries = explode ("&", $_SERVER['QUERY_STRING']);
- $counter = 0;
- for ( $i = 0; $i < count($queries); $i++ )
- {
- // Some properties need to be filtered out.
- if ( strpos($queries[$i], "direction") === false )
- {
- $tmpvars = explode ("=", $queries[$i]);
- if ( isset($tmpvars[1]) ) // Only if value param is set!
- {
- // For forms!
- $content['HIDDENVARS'][$counter]['varname'] = $tmpvars[0];
- $content['HIDDENVARS'][$counter]['varvalue'] = $tmpvars[1];
-
- if ( strlen($tmpvars[1]) > 0 )
- {
- // Append For URL's
- if ( $tmpvars[0] == "uid" )
- {
- // only add once
- if ( strlen($content['additional_url_uidonly']) <= 0 )
- $content['additional_url_uidonly'] .= "&" . $tmpvars[0] . "=" . $tmpvars[1];
- }
- else if ( $tmpvars[0] == "sorting" )
- {
- // only add once
- if ( strlen($content['additional_url_sortingonly']) <= 0 )
- $content['additional_url_sortingonly'] .= "&" . $tmpvars[0] . "=" . $tmpvars[1];
- }
- else
- $content['additional_url'] .= "&" . $tmpvars[0] . "=" . $tmpvars[1];
- }
-
- $counter++;
- }
- }
- }
- }
-
- // done
-}
-
-function GetFormatedDate($evttimearray)
-{
- global $content, $CFG;
-
- if ( !is_array($evttimearray) )
- return $evttimearray;
-
- if (
- ( isset($CFG['ViewUseTodayYesterday']) && $CFG['ViewUseTodayYesterday'] == 1 )
- &&
- ( date('m', $evttimearray[EVTIME_TIMESTAMP]) == date('m') && date('Y', $evttimearray[EVTIME_TIMESTAMP]) == date('Y') )
- )
- {
- if ( date('d', $evttimearray[EVTIME_TIMESTAMP]) == date('d') )
- return "Today " . date("H:i:s", $evttimearray[EVTIME_TIMESTAMP] );
- else if ( date('d', $evttimearray[EVTIME_TIMESTAMP] + 86400) == date('d') )
- return "Yesterday " . date("H:i:s", $evttimearray[EVTIME_TIMESTAMP] );
- }
-
- // Reach return normal format!
- return $szDateFormatted = date("Y-m-d H:i:s", $evttimearray[EVTIME_TIMESTAMP] );
-}
-
-function OutputDebugMessage($szDbg)
-{
- global $CFG;
-
- if ( $CFG['MiscShowDebugMsg'] == 1 )
- {
- print("
");
- print("
Debugmessage:
");
- print("
" . $szDbg . "
");
- print("
");
- }
-}
-
+ www.phplogcon.org <- *
+ * ----------------------------------------------------------------- *
+ * Helperfunctions for the web frontend *
+ * *
+ * -> *
+ * *
+ * All directives are explained within this file *
+ *
+ * Copyright (C) 2008 Adiscon GmbH.
+ *
+ * This file is part of phpLogCon.
+ *
+ * PhpLogCon is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * PhpLogCon is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpLogCon. If not, see .
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this
+ * distribution.
+ *********************************************************************
+*/
+
+// --- Avoid directly accessing this file!
+if ( !defined('IN_PHPLOGCON') )
+{
+ die('Hacking attempt');
+ exit;
+}
+// ---
+
+function InitFrontEndDefaults()
+{
+ // To create the current URL
+ CreateCurrentUrl();
+
+ // --- BEGIN Main Info Area
+
+
+
+ // --- END Main Info Area
+
+ // Check if install file still exists
+ InstallFileReminder();
+}
+
+function InstallFileReminder()
+{
+ global $content;
+
+ if ( is_file($content['BASEPATH'] . "install.php") )
+ {
+ // No Servers - display warning!
+ $content['error_installfilereminder'] = "true";
+ }
+}
+
+function CreateCurrentUrl()
+{
+ global $content;
+ $content['CURRENTURL'] = $_SERVER['PHP_SELF']; // . "?" . $_SERVER['QUERY_STRING']
+
+ // Init additional_url helper variable
+ $content['additional_url'] = "";
+ $content['additional_url_uidonly'] = "";
+ $content['additional_url_sortingonly'] = "";
+
+ // Now the query string:
+ if ( isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0 )
+ {
+ // Append ?
+ $content['CURRENTURL'] .= "?";
+
+ $queries = explode ("&", $_SERVER['QUERY_STRING']);
+ $counter = 0;
+ for ( $i = 0; $i < count($queries); $i++ )
+ {
+ // Some properties need to be filtered out.
+ if ( strpos($queries[$i], "direction") === false )
+ {
+ $tmpvars = explode ("=", $queries[$i]);
+ if ( isset($tmpvars[1]) ) // Only if value param is set!
+ {
+ // For forms!
+ $content['HIDDENVARS'][$counter]['varname'] = $tmpvars[0];
+ $content['HIDDENVARS'][$counter]['varvalue'] = $tmpvars[1];
+
+ if ( strlen($tmpvars[1]) > 0 )
+ {
+ // Append For URL's
+ if ( $tmpvars[0] == "uid" )
+ {
+ // only add once
+ if ( strlen($content['additional_url_uidonly']) <= 0 )
+ $content['additional_url_uidonly'] .= "&" . $tmpvars[0] . "=" . $tmpvars[1];
+ }
+ else if ( $tmpvars[0] == "sorting" )
+ {
+ // only add once
+ if ( strlen($content['additional_url_sortingonly']) <= 0 )
+ $content['additional_url_sortingonly'] .= "&" . $tmpvars[0] . "=" . $tmpvars[1];
+ }
+ else
+ $content['additional_url'] .= "&" . $tmpvars[0] . "=" . $tmpvars[1];
+ }
+
+ $counter++;
+ }
+ }
+ }
+ }
+
+ // done
+}
+
+function GetFormatedDate($evttimearray)
+{
+ global $content, $CFG;
+
+ if ( !is_array($evttimearray) )
+ return $evttimearray;
+
+ if (
+ ( isset($CFG['ViewUseTodayYesterday']) && $CFG['ViewUseTodayYesterday'] == 1 )
+ &&
+ ( date('m', $evttimearray[EVTIME_TIMESTAMP]) == date('m') && date('Y', $evttimearray[EVTIME_TIMESTAMP]) == date('Y') )
+ )
+ {
+ if ( date('d', $evttimearray[EVTIME_TIMESTAMP]) == date('d') )
+ return "Today " . date("H:i:s", $evttimearray[EVTIME_TIMESTAMP] );
+ else if ( date('d', $evttimearray[EVTIME_TIMESTAMP] + 86400) == date('d') )
+ return "Yesterday " . date("H:i:s", $evttimearray[EVTIME_TIMESTAMP] );
+ }
+
+ // Reach return normal format!
+ return $szDateFormatted = date("Y-m-d H:i:s", $evttimearray[EVTIME_TIMESTAMP] );
+}
+
+function OutputDebugMessage($szDbg)
+{
+ global $CFG;
+
+ if ( $CFG['MiscShowDebugMsg'] == 1 )
+ {
+ print("
");
+ print("
Debugmessage:
");
+ print("
" . $szDbg . "
");
+ print("
");
+ }
+}
+
?>
\ No newline at end of file
diff --git a/src/include/functions_themes.php b/src/include/functions_themes.php
index 1a49b90..46990fd 100644
--- a/src/include/functions_themes.php
+++ b/src/include/functions_themes.php
@@ -1,179 +1,179 @@
- www.phplogcon.org <- *
- * ----------------------------------------------------------------- *
- * Theme specific functions *
- * *
- * -> *
- * *
- * All directives are explained within this file *
- *
- * Copyright (C) 2008 Adiscon GmbH.
- *
- * This file is part of phpLogCon.
- *
- * PhpLogCon is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * PhpLogCon is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpLogCon. If not, see .
- *
- * A copy of the GPL can be found in the file "COPYING" in this
- * distribution.
- *********************************************************************
-*/
-
-// --- Avoid directly accessing this file!
-if ( !defined('IN_PHPLOGCON') )
-{
- die('Hacking attempt');
- exit;
-}
-// ---
-
-function CreateLanguageList()
-{
- global $gl_root_path, $content;
-
- $alldirectories = list_directories( $gl_root_path . "lang/");
- for($i = 0; $i < count($alldirectories); $i++)
- {
- // --- gen_lang
- $content['LANGUAGES'][$i]['langcode'] = $alldirectories[$i];
- if ( $content['gen_lang'] == $alldirectories[$i] )
- $content['LANGUAGES'][$i]['selected'] = "selected";
- else
- $content['LANGUAGES'][$i]['selected'] = "";
- // ---
-
- // --- user_lang
- $content['USERLANG'][$i]['langcode'] = $alldirectories[$i];
- if ( $content['user_lang'] == $alldirectories[$i] )
- $content['USERLANG'][$i]['is_selected'] = "selected";
- else
- $content['USERLANG'][$i]['is_selected'] = "";
- // ---
-
- // Init Language DisplayName
- $content['USERLANG'][$i]['DisplayName'] = GetLanguageDisplayName( $alldirectories[$i] );
- }
-}
-
-function CreateThemesList()
-{
- global $gl_root_path, $content;
-
- $alldirectories = list_directories( $gl_root_path . "themes/");
- for($i = 0; $i < count($alldirectories); $i++)
- {
- // --- web_theme
- $content['STYLES'][$i]['StyleName'] = $alldirectories[$i];
- if ( $content['web_theme'] == $alldirectories[$i] )
- $content['STYLES'][$i]['selected'] = "selected";
- else
- $content['STYLES'][$i]['selected'] = "";
- // ---
-
- // --- user_theme
- $content['USERSTYLES'][$i]['StyleName'] = $alldirectories[$i];
- if ( $content['user_theme'] == $alldirectories[$i] )
- $content['USERSTYLES'][$i]['is_selected'] = "selected";
- else
- $content['USERSTYLES'][$i]['is_selected'] = "";
- // ---
- }
-}
-
-function list_directories($directory)
-{
- $result = array();
- if (! $directoryHandler = @opendir ($directory))
- DieWithFriendlyErrorMsg( "list_directories: directory \"$directory\" doesn't exist!");
-
- while (false !== ($fileName = @readdir ($directoryHandler)))
- {
- if ( is_dir( $directory . $fileName ) && ( $fileName != "." && $fileName != ".." ))
- @array_push ($result, $fileName);
- }
-
- if ( @count ($result) === 0 )
- DieWithFriendlyErrorMsg( "list_directories: no directories in \"$directory\" found!");
- else
- {
- sort ($result);
- return $result;
- }
-}
-
-function VerifyTheme( $newtheme )
-{
- global $gl_root_path;
-
- if ( is_dir( $gl_root_path . "themes/" . $newtheme ) )
- return true;
- else
- return false;
-}
-
-function InitThemeAbout( $themename )
-{
- global $content, $gl_root_path;
- $szAboutFile = $gl_root_path . "themes/" . $themename . "/about.txt";
- if ( is_file( $szAboutFile ) )
- { //Read About Info!
- $aboutfile = fopen($szAboutFile, 'r');
- if (!feof ($aboutfile))
- {
- while (!feof ($aboutfile))
- {
- $tmpline = fgets($aboutfile, 1024);
- if (!isset($content["theme_madeby"]) )
- $content["theme_madeby"] = substr( trim($tmpline), 0, 25);
- else if (!isset($content["theme_madebylink"]) )
- $content["theme_madebylink"] = substr( trim($tmpline), 0, 256);
- else
- {
- $content["theme_madebyenable"] = "true";
- break;
- }
- }
- }
- fclose($aboutfile);
- }
- else
- $content["theme_madebyenable"] = "false";
-}
-
-function GetLanguageDisplayName( $szLangID )
-{
- global $content, $gl_root_path;
- $szInfoFile = $gl_root_path . "lang/" . $szLangID . "/info.txt";
- if ( is_file( $szInfoFile ) )
- {
- //Read InfoFile!
- $infofile = fopen($szInfoFile, 'r');
- if (!feof ($infofile))
- {
- while (!feof ($infofile))
- {
- // Return max 32 characters
- $tmpline = fgets($infofile, 1024);
- return substr( trim($tmpline), 0, 32);
- }
- }
- fclose($infofile);
- }
- else // No Info, return ID as DisplayName
- return $szLangID;
-}
-
-
-?>
+ www.phplogcon.org <- *
+ * ----------------------------------------------------------------- *
+ * Theme specific functions *
+ * *
+ * -> *
+ * *
+ * All directives are explained within this file *
+ *
+ * Copyright (C) 2008 Adiscon GmbH.
+ *
+ * This file is part of phpLogCon.
+ *
+ * PhpLogCon is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * PhpLogCon is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpLogCon. If not, see .
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this
+ * distribution.
+ *********************************************************************
+*/
+
+// --- Avoid directly accessing this file!
+if ( !defined('IN_PHPLOGCON') )
+{
+ die('Hacking attempt');
+ exit;
+}
+// ---
+
+function CreateLanguageList()
+{
+ global $gl_root_path, $content;
+
+ $alldirectories = list_directories( $gl_root_path . "lang/");
+ for($i = 0; $i < count($alldirectories); $i++)
+ {
+ // --- gen_lang
+ $content['LANGUAGES'][$i]['langcode'] = $alldirectories[$i];
+ if ( $content['gen_lang'] == $alldirectories[$i] )
+ $content['LANGUAGES'][$i]['selected'] = "selected";
+ else
+ $content['LANGUAGES'][$i]['selected'] = "";
+ // ---
+
+ // --- user_lang
+ $content['USERLANG'][$i]['langcode'] = $alldirectories[$i];
+ if ( $content['user_lang'] == $alldirectories[$i] )
+ $content['USERLANG'][$i]['is_selected'] = "selected";
+ else
+ $content['USERLANG'][$i]['is_selected'] = "";
+ // ---
+
+ // Init Language DisplayName
+ $content['USERLANG'][$i]['DisplayName'] = GetLanguageDisplayName( $alldirectories[$i] );
+ }
+}
+
+function CreateThemesList()
+{
+ global $gl_root_path, $content;
+
+ $alldirectories = list_directories( $gl_root_path . "themes/");
+ for($i = 0; $i < count($alldirectories); $i++)
+ {
+ // --- web_theme
+ $content['STYLES'][$i]['StyleName'] = $alldirectories[$i];
+ if ( $content['web_theme'] == $alldirectories[$i] )
+ $content['STYLES'][$i]['selected'] = "selected";
+ else
+ $content['STYLES'][$i]['selected'] = "";
+ // ---
+
+ // --- user_theme
+ $content['USERSTYLES'][$i]['StyleName'] = $alldirectories[$i];
+ if ( $content['user_theme'] == $alldirectories[$i] )
+ $content['USERSTYLES'][$i]['is_selected'] = "selected";
+ else
+ $content['USERSTYLES'][$i]['is_selected'] = "";
+ // ---
+ }
+}
+
+function list_directories($directory)
+{
+ $result = array();
+ if (! $directoryHandler = @opendir ($directory))
+ DieWithFriendlyErrorMsg( "list_directories: directory \"$directory\" doesn't exist!");
+
+ while (false !== ($fileName = @readdir ($directoryHandler)))
+ {
+ if ( is_dir( $directory . $fileName ) && ( $fileName != "." && $fileName != ".." ))
+ @array_push ($result, $fileName);
+ }
+
+ if ( @count ($result) === 0 )
+ DieWithFriendlyErrorMsg( "list_directories: no directories in \"$directory\" found!");
+ else
+ {
+ sort ($result);
+ return $result;
+ }
+}
+
+function VerifyTheme( $newtheme )
+{
+ global $gl_root_path;
+
+ if ( is_dir( $gl_root_path . "themes/" . $newtheme ) )
+ return true;
+ else
+ return false;
+}
+
+function InitThemeAbout( $themename )
+{
+ global $content, $gl_root_path;
+ $szAboutFile = $gl_root_path . "themes/" . $themename . "/about.txt";
+ if ( is_file( $szAboutFile ) )
+ { //Read About Info!
+ $aboutfile = fopen($szAboutFile, 'r');
+ if (!feof ($aboutfile))
+ {
+ while (!feof ($aboutfile))
+ {
+ $tmpline = fgets($aboutfile, 1024);
+ if (!isset($content["theme_madeby"]) )
+ $content["theme_madeby"] = substr( trim($tmpline), 0, 25);
+ else if (!isset($content["theme_madebylink"]) )
+ $content["theme_madebylink"] = substr( trim($tmpline), 0, 256);
+ else
+ {
+ $content["theme_madebyenable"] = "true";
+ break;
+ }
+ }
+ }
+ fclose($aboutfile);
+ }
+ else
+ $content["theme_madebyenable"] = "false";
+}
+
+function GetLanguageDisplayName( $szLangID )
+{
+ global $content, $gl_root_path;
+ $szInfoFile = $gl_root_path . "lang/" . $szLangID . "/info.txt";
+ if ( is_file( $szInfoFile ) )
+ {
+ //Read InfoFile!
+ $infofile = fopen($szInfoFile, 'r');
+ if (!feof ($infofile))
+ {
+ while (!feof ($infofile))
+ {
+ // Return max 32 characters
+ $tmpline = fgets($infofile, 1024);
+ return substr( trim($tmpline), 0, 32);
+ }
+ }
+ fclose($infofile);
+ }
+ else // No Info, return ID as DisplayName
+ return $szLangID;
+}
+
+
+?>