Skip to content

Commit

Permalink
Pi-hole web v5.20 (#2594)
Browse files Browse the repository at this point in the history
  • Loading branch information
PromoFaux authored May 28, 2023
2 parents 4cedc10 + a4653d0 commit 40bb0a3
Show file tree
Hide file tree
Showing 32 changed files with 676 additions and 378 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3.4.0
uses: actions/checkout@v3.5.2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
-
name: Checkout repository
uses: actions/checkout@v3.4.0
uses: actions/checkout@v3.5.2
-
name: Spell-Checking
uses: codespell-project/actions-codespell@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/editorconfig-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ jobs:
name: editorconfig-checker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.4.0
- uses: actions/checkout@v3.5.2
- uses: editorconfig-checker/action-editorconfig-checker@main
- run: editorconfig-checker
2 changes: 1 addition & 1 deletion .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.4.0
- uses: actions/checkout@v3.5.2
- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.4.0
- uses: actions/checkout@v3.5.2

- name: Install composer
uses: php-actions/composer@v6
Expand Down
26 changes: 22 additions & 4 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,41 @@ on:
schedule:
- cron: '0 8 * * *'
workflow_dispatch:
issue_comment:

jobs:
stale:
env:
stale_label: stale

jobs:
stale_action:
if: github.event_name != 'issue_comment'
runs-on: ubuntu-latest
permissions:
issues: write

steps:
- uses: actions/stale@v7.0.0
- uses: actions/stale@v8.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 30
days-before-close: 5
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.'
stale-issue-label: 'stale'
stale-issue-label: $stale_label
exempt-issue-labels: 'internal, Fixed In Next Release, Bug, never-stale'
exempt-all-issue-assignees: true
operations-per-run: 300
close-issue-reason: 'not_planned'

remove_stale: # trigger "stale" removal immediately when stale issues are commented on
if: github.event_name == 'issue_comment'
permissions:
contents: read # for actions/checkout
issues: write # to edit issues label
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.4.0
- name: Remove 'stale' label
run: gh issue edit ${{ github.event.issue.number }} --remove-label $stale_label
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/stale_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
pull-requests: write

steps:
- uses: actions/stale@v7.0.0
- uses: actions/stale@v8.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
# Do not automatically mark PR/issue as stale
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-back-to-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Syncing branches
steps:
- name: Checkout
uses: actions/checkout@v3.4.0
uses: actions/checkout@v3.5.2
- name: Opening pull request
run: gh pr create -B devel -H master --title 'Sync master back into development' --body 'Created by Github action' --label 'internal'
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: Clone repository
uses: actions/checkout@v3.4.0
uses: actions/checkout@v3.5.2

- name: Set up Node.js
uses: actions/setup-node@v3.6.0
Expand Down
7 changes: 7 additions & 0 deletions api.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@
$branches = array('core_branch' => $core_branch,
'web_branch' => $web_branch,
'FTL_branch' => $FTL_branch, );
if (isset($versions['DOCKER_VERSION'])) {
// Docker info is available only inside containers
$updates['docker_update'] = $docker_update;
$current['docker_current'] = $docker_current;
$latest['docker_latest'] = $docker_latest;
}

$data = array_merge($data, $updates);
$data = array_merge($data, $current);
$data = array_merge($data, $latest);
Expand Down
44 changes: 30 additions & 14 deletions api_FTL.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,37 @@
}

if (isset($_GET['getMaxlogage']) && $auth) {
$return = callFTLAPI('maxlogage');
if (array_key_exists('FTLnotrunning', $return)) {
$maxlogage = getMaxlogage();

if ($maxlogage < 0) {
// FTL is offline
$data = array('FTLnotrunning' => true);
} else {
// Convert seconds to hours and rounds to one decimal place.
$ret = round(intval($return[0]) / 3600, 1);
// Return 24h if value is 0, empty, null or non numeric.
$ret = $ret ?: 24;

$data = array_merge($data, array('maxlogage' => $ret));
$data = array_merge($data, array('maxlogage' => $maxlogage));
}
}

if (isset($_GET['overTimeData10mins']) && $auth) {
$maxlogage = getMaxlogage();

$return = callFTLAPI('overTime');
if (array_key_exists('FTLnotrunning', $return)) {
if (array_key_exists('FTLnotrunning', $return) || $maxlogage < 0) {
$data = array('FTLnotrunning' => true);
} else {
$domains_over_time = array();
$ads_over_time = array();

// Use current time and maxlogage to limit the time range
$time_end = time();
$time_start = $time_end - ($maxlogage * 3600);

foreach ($return as $line) {
$tmp = explode(' ', $line);
$domains_over_time[intval($tmp[0])] = intval($tmp[1]);
$ads_over_time[intval($tmp[0])] = intval($tmp[2]);
$timeslot = intval($tmp[0]);
if ($timeslot >= $time_start && $timeslot <= $time_end) {
$domains_over_time[$timeslot] = intval($tmp[1]);
$ads_over_time[$timeslot] = intval($tmp[2]);
}
}

$result = array(
Expand Down Expand Up @@ -401,16 +408,25 @@
}

if (isset($_GET['overTimeDataClients']) && $auth) {
$return = callFTLAPI('ClientsoverTime');
$maxlogage = getMaxlogage();

if (array_key_exists('FTLnotrunning', $return)) {
$return = callFTLAPI('ClientsoverTime');
if (array_key_exists('FTLnotrunning', $return) || $maxlogage < 0) {
$data = array('FTLnotrunning' => true);
} else {
$over_time = array();

// Use current time and maxlogage to limit the time range
$time_end = time();
$time_start = $time_end - ($maxlogage * 3600);

foreach ($return as $line) {
$tmp = explode(' ', $line);
for ($i = 0; $i < count($tmp) - 1; ++$i) {
$over_time[intval($tmp[0])][$i] = floatval($tmp[$i + 1]);
$timeslot = intval($tmp[0]);
if ($timeslot >= $time_start && $timeslot <= $time_end) {
$over_time[$timeslot][$i] = floatval($tmp[$i + 1]);
}
}
}
$result = array('over_time' => $over_time);
Expand Down
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 40bb0a3

Please sign in to comment.