Skip to content

Commit

Permalink
fix ookla and sql issues (arevindh#94)
Browse files Browse the repository at this point in the history
* suppress error

* redirect stderr

* redirect both

* bypass ookla

* forgot var

* add sc

* check if file exists

* account for no table
  • Loading branch information
ipitio authored Mar 14, 2024
1 parent 91bd55e commit a6373e2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions api_speedtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function getSpeedTestData($dbSpeedtest, $durationdays = '1')
return array();
}
$db = new SQLite3($dbSpeedtest);
if (!$db) {
if (!$db || !$db->querySingle('SELECT count(*) FROM sqlite_master WHERE type="table" AND name="speedtest"')) {
return array();
}

Expand Down Expand Up @@ -265,7 +265,11 @@ function JSONServers($cmdServersJSON)

function getRemainingTime()
{
$interval_seconds = speedtestExecute("grep 'interval_seconds=' /opt/pihole/speedtestmod/schedule_check.sh | cut -d'=' -f2")['data'];
$interval_seconds = -1;

if (file_exists('/opt/pihole/speedtestmod/schedule_check.sh')) {
$interval_seconds = speedtestExecute("grep 'interval_seconds=' /opt/pihole/speedtestmod/schedule_check.sh | cut -d'=' -f2")['data'];
}

// if interval_seconds is "nan", then schedule has never been set
if (strpos($interval_seconds, 'nan') !== false) {
Expand Down Expand Up @@ -296,7 +300,7 @@ function getRemainingTime()
function getNumberOfDaysInDB($dbSpeedtest)
{
$db = new SQLite3($dbSpeedtest);
if (!$db) {
if (!$db || !$db->querySingle('SELECT count(*) FROM sqlite_master WHERE type="table" AND name="speedtest"')) {
return array('data' => 0);
}

Expand Down
Binary file added img/st-chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/st-pref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion scripts/pi-hole/php/header_authenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function getTemperature()
function getNumberOfDaysInDB($dbSpeedtest)
{
$db = new SQLite3($dbSpeedtest);
if (!$db) {
if (!$db || !$db->querySingle('SELECT count(*) FROM sqlite_master WHERE type="table" AND name="speedtest"')) {
return 0;
}

Expand Down

0 comments on commit a6373e2

Please sign in to comment.