Skip to content

Commit

Permalink
Merge pull request #87 from alexnathanson/fix/yesterday-in-admin
Browse files Browse the repository at this point in the history
Fix navigating previous php log files
  • Loading branch information
alexnathanson authored Sep 21, 2024
2 parents 415cfcd + 4704210 commit bb35fcb
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 bb35fcb

Please sign in to comment.