Skip to content

Commit

Permalink
Fix navigating previous php log files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Dahan committed Sep 8, 2024
1 parent 2e6f225 commit 4704210
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions frontend/admin/local.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,14 @@ function getFile($fileName){

<?php

$fileDate = date("Y-m-d");

if(isset($_GET["date"])){
//get the query string
$date = htmlspecialchars($_GET["date"]);

if ($date == 'yesterday'){
$fileDate = date("Y-m-") . (date("d")-1);
}elseif( $date == 'before'){
$fileDate = date("Y-m-") . (date("d")-2);//make a conditional to account for single digit days!!!
}
function csvName() {
$base = htmlspecialchars($_GET["date"] ?? 'today');
if ($base == 'before') $base = '-2 days';
$fileDate = date("Y-m-d", strtotime($base));
return "tracerData" . $fileDate . ".csv";
}


//variables
$fileName = "/home/pi/solar-protocol/charge-controller/data/tracerData" . $fileDate . ".csv";
$fileName = "/home/pi/solar-protocol/charge-controller/data/" . csvName();
$rawDataArray = [];

echo "<h2>Local PV Data</h2>";
Expand Down

0 comments on commit 4704210

Please sign in to comment.