diff --git a/src/classes/logstream.class.php b/src/classes/logstream.class.php
index 9e51670..b308764 100644
--- a/src/classes/logstream.class.php
+++ b/src/classes/logstream.class.php
@@ -175,6 +175,12 @@ abstract class LogStream {
public abstract function GetLastPageUID();
+ /**
+ * This function returns the FIRST UID for the FIRST PAGE, if availbale! Otherwise will
+ * return -1!
+ */
+ public abstract function GetFirstPageUID();
+
/**
* This function returns the current Page number, if availbale! Otherwise will
* return -1!
diff --git a/src/classes/logstreamdb.class.php b/src/classes/logstreamdb.class.php
index 1a5748b..afd2015 100644
--- a/src/classes/logstreamdb.class.php
+++ b/src/classes/logstreamdb.class.php
@@ -57,6 +57,7 @@ class LogStreamDB extends LogStream {
private $_totalRecordCount = -1;
private $_previousPageUID = -1;
private $_lastPageUID = -1;
+ private $_firstPageUID = -1;
private $_currentPageNumber = 0;
private $_SQLwhereClause = "";
@@ -335,6 +336,34 @@ class LogStreamDB extends LogStream {
return $this->_previousPageUID;
}
+ /**
+ * This function returns the FIRST UID for the FIRST PAGE!
+ * Will be done by a seperated SQL Statement.
+ */
+ public function GetFirstPageUID()
+ {
+ global $querycount, $dbmapping;
+ $szTableType = $this->_logStreamConfigObj->DBTableType;
+
+ $szSql = "SELECT MAX(" . $dbmapping[$szTableType][SYSLOG_UID] . ") FROM " . $this->_logStreamConfigObj->DBTableName . $this->_SQLwhereClause;
+ $myQuery = mysql_query($szSql, $this->_dbhandle);
+ if ($myQuery)
+ {
+ // obtain first and only row
+ $myRow = mysql_fetch_row($myQuery);
+ $this->_firstPageUID = $myRow[0];
+
+ // Free query now
+ mysql_free_result ($myQuery);
+
+ // Increment for the Footer Stats
+ $querycount++;
+ }
+
+ // Return result!
+ return $this->_firstPageUID;
+ }
+
/**
* This function returns the first UID for the last PAGE!
* Will be done by a seperated SQL Statement.
@@ -389,7 +418,7 @@ class LogStreamDB extends LogStream {
}
*/
- // finally return result!
+ // Return result!
return $this->_lastPageUID;
}
diff --git a/src/classes/logstreamdisk.class.php b/src/classes/logstreamdisk.class.php
index 99c0ab9..36d8d4f 100644
--- a/src/classes/logstreamdisk.class.php
+++ b/src/classes/logstreamdisk.class.php
@@ -466,6 +466,15 @@ class LogStreamDisk extends LogStream {
return $this->_previousPageUID;
}
+ /**
+ * This function returns the FIRST UID for the FIRST PAGE!
+ * NOT IMPLEMENTED RIGHT NOW!
+ */
+ public function GetFirstPageUID()
+ {
+ return -1;
+ }
+
/**
* This function returns the first UID for the last PAGE!
* This is not possible in this logstream, so it always returns -1!
@@ -500,16 +509,6 @@ class LogStreamDisk extends LogStream {
// Now we move for one page, we do not need to process the syslog messages!
$ret = $this->ReadNext($myuid, $tmpArray, false);
-/* OLD CODE
- if ( $ret == SUCCESS )
- {
- do
- {
- // Increment Counter
- $counter++;
- } while ( $counter < $this->_logStreamConfigObj->_pageCount && ($ret = $this->ReadNext($myuid, $tmpArray, false)) == SUCCESS );
- }
-*/
// Save the current UID as LastPage UID!
$this->_lastPageUID = $myuid;
diff --git a/src/classes/logstreampdo.class.php b/src/classes/logstreampdo.class.php
index 5f94b8a..f512739 100644
--- a/src/classes/logstreampdo.class.php
+++ b/src/classes/logstreampdo.class.php
@@ -53,6 +53,7 @@ class LogStreamPDO extends LogStream {
private $_totalRecordCount = -1;
private $_previousPageUID = -1;
private $_lastPageUID = -1;
+ private $_firstPageUID = -1;
private $_currentPageNumber = -1;
private $_SQLwhereClause = "";
@@ -363,6 +364,36 @@ echo "mowl2";
return $this->_previousPageUID;
}
+ /**
+ * This function returns the FIRST UID for the FIRST PAGE!
+ * Will be done by a seperated SQL Statement.
+ */
+ public function GetFirstPageUID()
+ {
+ global $querycount, $dbmapping;
+ $szTableType = $this->_logStreamConfigObj->DBTableType;
+
+ $szSql = "SELECT MAX(" . $dbmapping[$szTableType][SYSLOG_UID] . ") FROM " . $this->_logStreamConfigObj->DBTableName . $this->_SQLwhereClause;
+ $myQuery = $this->_dbhandle->query($szSql);
+ if ( $myQuery )
+ {
+ $myRow = $myQuery->fetchColumn();
+ $this->_firstPageUID = $myRow; // $myRow[0];
+
+ // Free query now
+ $myQuery->closeCursor();
+
+ // Increment for the Footer Stats
+ $querycount++;
+
+ }
+//echo $szSql . "
" . $this->_firstPageUID;
+//exit;
+
+ // finally return result!
+ return $this->_firstPageUID;
+ }
+
/**
* This function returns the first UID for the last PAGE!
* Will be done by a seperated SQL Statement.
diff --git a/src/details.php b/src/details.php
index a7be744..8262c33 100644
--- a/src/details.php
+++ b/src/details.php
@@ -262,7 +262,7 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['uid_current'
{
// Enable Pager in any case here!
$content['main_pagerenabled'] = true;
-
+/*
// --- Handle uid_first page button
if ( $content['uid_fromgetrequest'] == $content['uid_first'] )
$content['main_pager_first_found'] = false;
@@ -276,10 +276,19 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['uid_current'
$content['main_pager_first_found'] = false;
}
// ---
-
+*/
// --- Handle uid_last page button
// Option the last UID from the stream!
$content['uid_last'] = $stream->GetLastPageUID();
+ $content['uid_first'] = $stream->GetFirstPageUID();
+
+ // --- Handle uid_first page button
+ if ( $content['uid_current'] == $content['uid_first'] )
+ $content['main_pager_first_found'] = false;
+ else
+ $content['main_pager_first_found'] = true;
+ // ---
+
// if we found a last uid, and if it is not the current one (which means we already are on the last page ;)!
if ( $content['uid_last'] != -1 && $content['uid_last'] != $content['uid_current'])
diff --git a/src/include/functions_frontendhelpers.php b/src/include/functions_frontendhelpers.php
index 65821f9..c34716c 100644
--- a/src/include/functions_frontendhelpers.php
+++ b/src/include/functions_frontendhelpers.php
@@ -108,7 +108,11 @@ function CreateCurrentUrl()
for ( $i = 0; $i < count($queries); $i++ )
{
// Some properties need to be filtered out.
- if ( strpos($queries[$i], "direction") === false )
+ if (
+ strpos($queries[$i], "direction") === false
+ &&
+ strpos($queries[$i], "skipone") === false
+ )
{
$tmpvars = explode ("=", $queries[$i]);
if ( isset($tmpvars[1]) ) // Only if value param is set!
diff --git a/src/index.php b/src/index.php
index 361e05a..eebabf2 100644
--- a/src/index.php
+++ b/src/index.php
@@ -73,6 +73,17 @@ if ( $content['uid_current'] == UID_UNKNOWN )
else
$content['ViewEnableAutoReloadSeconds_visible'] = false;
+// Read direction parameter
+if ( isset($_GET['direction']) && $_GET['direction'] == "desc" )
+ $content['read_direction'] = EnumReadDirection::Forward;
+else
+ $content['read_direction'] = EnumReadDirection::Backward;
+
+// If direction is DESC, should we SKIP one?
+if ( isset($_GET['skipone']) && $_GET['skipone'] == "true" )
+ $content['skipone'] = true;
+else
+ $content['skipone'] = false;
// ---
@@ -87,12 +98,6 @@ $content['main_pager_previous_found'] = false;
$content['main_pager_next_found'] = false;
$content['main_pager_last_found'] = false;
-
-if ( isset($_GET['direction']) && $_GET['direction'] == "desc" )
- $content['read_direction'] = EnumReadDirection::Forward;
-else
- $content['read_direction'] = EnumReadDirection::Backward;
-
// Init Sorting variables
$content['sorting'] = "";
$content['searchstr'] = "";
@@ -244,17 +249,18 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['Sources'][$c
// --- Check if Read was successfull!
if ( $ret == SUCCESS )
{
-/* OLD CODE
// If Forward direction is used, we need to SKIP one entry!
if ( $content['read_direction'] == EnumReadDirection::Forward )
{
// Ok the current ID is our NEXT ID in this reading direction, so we save it!
$content['uid_next'] = $uID;
- // Skip this entry and move to the next
- $stream->ReadNext($uID, $logArray);
+ if ( $content['skipone'] )
+ {
+ // Skip this entry and move to the next
+ $stream->ReadNext($uID, $logArray);
+ }
}
-*/
}
else
{
@@ -569,6 +575,9 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['Sources'][$c
// Enable Pager in any case here!
$content['main_pagerenabled'] = true;
+ // temporary store the current last $uID
+ $lastUid = $uID;
+
// --- Handle uid_next page button
if ( $content['read_direction'] == EnumReadDirection::Backward )
{
@@ -610,6 +619,7 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['Sources'][$c
// --- Handle uid_last page button
// Option the last UID from the stream!
$content['uid_last'] = $stream->GetLastPageUID();
+ $content['uid_first'] = $stream->GetFirstPageUID();
// if we found a last uid, and if it is not the current one (which means we already are on the last page ;)!
if ( $content['uid_last'] != -1 && $content['uid_last'] != $content['uid_current'])
@@ -629,13 +639,18 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['Sources'][$c
$content['main_pager_next_found'] = true;
// As we went back, we need to change the currend uid to the latest read one
- $content['uid_current'] = $uID;
+ $content['uid_current'] = $lastUid;
}
// ---
// --- Handle uid_first page button
- if ( $content['uid_current'] == $content['uid_first'] )
+ if ( $content['main_pager_previous_found'] == false ||
+ $content['uid_current'] == UID_UNKNOWN ||
+ $content['uid_current'] == $content['uid_first'] )
+ {
$content['main_pager_first_found'] = false;
+ $content['main_pager_previous_found'] = false; // If there is no FIRST, there is no going back!
+ }
else
$content['main_pager_first_found'] = true;
// ---
diff --git a/src/templates/index.html b/src/templates/index.html
index 997543a..fc04c06 100644
--- a/src/templates/index.html
+++ b/src/templates/index.html
@@ -150,7 +150,7 @@