From c5e82d49695b4af4d5eff67db8eca8b9af6f9515 Mon Sep 17 00:00:00 2001
From: Thom <thom@amsterdamtech.nl>
Date: Thu, 8 Apr 2021 16:00:28 +0000
Subject: [PATCH] Fix broken check for correct index file (#6147)

---
 server/conf/awstats_index.php.master | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/server/conf/awstats_index.php.master b/server/conf/awstats_index.php.master
index b3e694ebbf..a82de8a0ca 100644
--- a/server/conf/awstats_index.php.master
+++ b/server/conf/awstats_index.php.master
@@ -43,23 +43,17 @@ if ($handle = opendir('.'))
 arsort($awprev);
 
 $options = "";
-foreach ($awprev as $key => $value)
-{
-
-	if(file_exists($value.'/awsindex.html') && file_exists($value.'/goaindex.html')) {
-		$awstatsindex = 'awsindex.html';
-	} elseif(file_exists($value.'/awsindex.html') && !file_exists($value.'/goaindex.html')) {
-                $awstatsindex = 'awsindex.html';
-	} else {
-		$awstatsindex = 'goaindex.html';
-	}
-
+foreach ($awprev as $key => $value) {
+        // Define name for the index file
+        $awstatsindex = 'awsindex.html';
+        if(!file_exists($value.'/awsindex.html') && file_exists($value.'/goaindex.html')) {
+                $awstatsindex = 'goaindex.html';
+        }
+        // Set name for first entry in month list
 	if($key == $current) $options .= "<option selected=\"selected\" value=\"{$awstatsindex}\">{$value}</option>\n";
 	else $options .= "<option value=\"{$value}/{$awstatsindex}\">{$value}</option>\n";
 }
 
-$awstatsindex = 'awsindex.html';
-
 $html = "<!DOCTYPE html>\n<html>\n<head>\n<title>Stats</title>\n";
 $html .= "<style>\nhtml,body {margin:0px;padding:0px;width:100%;height:100%;background-color: #ccc;}\n";
 $html .= "#header\n{\nwidth:100%;margin:0px auto;\nheight:20px;\nposition:fixed;\npadding:4px;\ntext-align:center;\n}\n";
-- 
GitLab