Skip to content

Commit 40bb0a3

Browse files
authored
Pi-hole web v5.20 (#2594)
2 parents 4cedc10 + a4653d0 commit 40bb0a3

32 files changed

+676
-378
lines changed

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
steps:
2323
- name: Checkout repository
24-
uses: actions/checkout@v3.4.0
24+
uses: actions/checkout@v3.5.2
2525
# Initializes the CodeQL tools for scanning.
2626
- name: Initialize CodeQL
2727
uses: github/codeql-action/init@v2

.github/workflows/codespell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
steps:
1212
-
1313
name: Checkout repository
14-
uses: actions/checkout@v3.4.0
14+
uses: actions/checkout@v3.5.2
1515
-
1616
name: Spell-Checking
1717
uses: codespell-project/actions-codespell@master

.github/workflows/editorconfig-checker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ jobs:
99
name: editorconfig-checker
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3.4.0
12+
- uses: actions/checkout@v3.5.2
1313
- uses: editorconfig-checker/action-editorconfig-checker@main
1414
- run: editorconfig-checker

.github/workflows/php-cs-fixer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
name: PHP-CS-Fixer
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v3.4.0
9+
- uses: actions/checkout@v3.5.2
1010
- name: PHP-CS-Fixer
1111
uses: docker://oskarstark/php-cs-fixer-ga
1212
with:

.github/workflows/phpstan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
build:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v3.4.0
11+
- uses: actions/checkout@v3.5.2
1212

1313
- name: Install composer
1414
uses: php-actions/composer@v6

.github/workflows/stale.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,41 @@ on:
44
schedule:
55
- cron: '0 8 * * *'
66
workflow_dispatch:
7+
issue_comment:
78

8-
jobs:
9-
stale:
9+
env:
10+
stale_label: stale
1011

12+
jobs:
13+
stale_action:
14+
if: github.event_name != 'issue_comment'
1115
runs-on: ubuntu-latest
1216
permissions:
1317
issues: write
1418

1519
steps:
16-
- uses: actions/stale@v7.0.0
20+
- uses: actions/stale@v8.0.0
1721
with:
1822
repo-token: ${{ secrets.GITHUB_TOKEN }}
1923
days-before-stale: 30
2024
days-before-close: 5
2125
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.'
22-
stale-issue-label: 'stale'
26+
stale-issue-label: $stale_label
2327
exempt-issue-labels: 'internal, Fixed In Next Release, Bug, never-stale'
2428
exempt-all-issue-assignees: true
2529
operations-per-run: 300
2630
close-issue-reason: 'not_planned'
31+
32+
remove_stale: # trigger "stale" removal immediately when stale issues are commented on
33+
if: github.event_name == 'issue_comment'
34+
permissions:
35+
contents: read # for actions/checkout
36+
issues: write # to edit issues label
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v3.4.0
41+
- name: Remove 'stale' label
42+
run: gh issue edit ${{ github.event.issue.number }} --remove-label $stale_label
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/stale_pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
pull-requests: write
1818

1919
steps:
20-
- uses: actions/stale@v7.0.0
20+
- uses: actions/stale@v8.0.0
2121
with:
2222
repo-token: ${{ secrets.GITHUB_TOKEN }}
2323
# Do not automatically mark PR/issue as stale

.github/workflows/sync-back-to-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Syncing branches
1212
steps:
1313
- name: Checkout
14-
uses: actions/checkout@v3.4.0
14+
uses: actions/checkout@v3.5.2
1515
- name: Opening pull request
1616
run: gh pr create -B devel -H master --title 'Sync master back into development' --body 'Created by Github action' --label 'internal'
1717
env:

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
steps:
2121
- name: Clone repository
22-
uses: actions/checkout@v3.4.0
22+
uses: actions/checkout@v3.5.2
2323

2424
- name: Set up Node.js
2525
uses: actions/setup-node@v3.6.0

api.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@
7171
$branches = array('core_branch' => $core_branch,
7272
'web_branch' => $web_branch,
7373
'FTL_branch' => $FTL_branch, );
74+
if (isset($versions['DOCKER_VERSION'])) {
75+
// Docker info is available only inside containers
76+
$updates['docker_update'] = $docker_update;
77+
$current['docker_current'] = $docker_current;
78+
$latest['docker_latest'] = $docker_latest;
79+
}
80+
7481
$data = array_merge($data, $updates);
7582
$data = array_merge($data, $current);
7683
$data = array_merge($data, $latest);

api_FTL.php

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,30 +64,37 @@
6464
}
6565

6666
if (isset($_GET['getMaxlogage']) && $auth) {
67-
$return = callFTLAPI('maxlogage');
68-
if (array_key_exists('FTLnotrunning', $return)) {
67+
$maxlogage = getMaxlogage();
68+
69+
if ($maxlogage < 0) {
70+
// FTL is offline
6971
$data = array('FTLnotrunning' => true);
7072
} else {
71-
// Convert seconds to hours and rounds to one decimal place.
72-
$ret = round(intval($return[0]) / 3600, 1);
73-
// Return 24h if value is 0, empty, null or non numeric.
74-
$ret = $ret ?: 24;
75-
76-
$data = array_merge($data, array('maxlogage' => $ret));
73+
$data = array_merge($data, array('maxlogage' => $maxlogage));
7774
}
7875
}
7976

8077
if (isset($_GET['overTimeData10mins']) && $auth) {
78+
$maxlogage = getMaxlogage();
79+
8180
$return = callFTLAPI('overTime');
82-
if (array_key_exists('FTLnotrunning', $return)) {
81+
if (array_key_exists('FTLnotrunning', $return) || $maxlogage < 0) {
8382
$data = array('FTLnotrunning' => true);
8483
} else {
8584
$domains_over_time = array();
8685
$ads_over_time = array();
86+
87+
// Use current time and maxlogage to limit the time range
88+
$time_end = time();
89+
$time_start = $time_end - ($maxlogage * 3600);
90+
8791
foreach ($return as $line) {
8892
$tmp = explode(' ', $line);
89-
$domains_over_time[intval($tmp[0])] = intval($tmp[1]);
90-
$ads_over_time[intval($tmp[0])] = intval($tmp[2]);
93+
$timeslot = intval($tmp[0]);
94+
if ($timeslot >= $time_start && $timeslot <= $time_end) {
95+
$domains_over_time[$timeslot] = intval($tmp[1]);
96+
$ads_over_time[$timeslot] = intval($tmp[2]);
97+
}
9198
}
9299

93100
$result = array(
@@ -401,16 +408,25 @@
401408
}
402409

403410
if (isset($_GET['overTimeDataClients']) && $auth) {
404-
$return = callFTLAPI('ClientsoverTime');
411+
$maxlogage = getMaxlogage();
405412

406-
if (array_key_exists('FTLnotrunning', $return)) {
413+
$return = callFTLAPI('ClientsoverTime');
414+
if (array_key_exists('FTLnotrunning', $return) || $maxlogage < 0) {
407415
$data = array('FTLnotrunning' => true);
408416
} else {
409417
$over_time = array();
418+
419+
// Use current time and maxlogage to limit the time range
420+
$time_end = time();
421+
$time_start = $time_end - ($maxlogage * 3600);
422+
410423
foreach ($return as $line) {
411424
$tmp = explode(' ', $line);
412425
for ($i = 0; $i < count($tmp) - 1; ++$i) {
413-
$over_time[intval($tmp[0])][$i] = floatval($tmp[$i + 1]);
426+
$timeslot = intval($tmp[0]);
427+
if ($timeslot >= $time_start && $timeslot <= $time_end) {
428+
$over_time[$timeslot][$i] = floatval($tmp[$i + 1]);
429+
}
414430
}
415431
}
416432
$result = array('over_time' => $over_time);

composer.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)