diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..176a458f --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 1eab58cf..829de9da 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,7 +1,7 @@ **In raising this issue, I confirm the following:** `{please fill the checkboxes, e.g: [X]}` - [] I have read and understood the [contributors guide](https://github.com/pi-hole/AdminLTE/blob/master/CONTRIBUTING.md). -- [] The issue I am reporting can be *replicated*. +- [] The issue I am reporting can be _replicated_. - [] The issue I am reporting isn't a duplicate (see [FAQs](https://github.com/pi-hole/pi-hole/wiki/FAQs), [closed issues](https://github.com/pi-hole/AdminLTE/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), and [open issues](https://github.com/pi-hole/AdminLTE/issues)). **How familiar are you with the the source code relevant to this issue?:** @@ -9,11 +9,12 @@ `{Replace this with a number from 1 to 10. 1 being not familiar, and 10 being very familiar}` --- -**Expected behaviour:** + +**Expected behavior:** `{A detailed description of what you expect to see}` -**Actual behaviour:** +**Actual behavior:** `{A detailed description and/or screenshots of what you do see}` @@ -29,9 +30,9 @@ `{Steps of what you have done to fix this}` -> * `{Please delete this quoted section when opening your issue}` -> * You must follow the template instructions. Failure to do so will result in your issue being closed. -> * Please [submit any feature requests here](https://discourse.pi-hole.net/c/feature-requests), so it is votable and trackable by the community. -> * Please respect that Pi-hole is developed by volunteers, who can only reply in their spare time. -> * Detail helps us understand and resolve an issue quicker, but please ensure it's relevant. -> * _This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._ +> - `{Please delete this quoted section when opening your issue}` +> - You must follow the template instructions. Failure to do so will result in your issue being closed. +> - Please [submit any feature requests here](https://discourse.pi-hole.net/c/feature-requests), so it is votable and trackable by the community. +> - Please respect that Pi-hole is developed by volunteers, who can only reply in their spare time. +> - Detail helps us understand and resolve an issue quicker, but please ensure it's relevant. +> - _This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._ diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 1be609f0..f693cda2 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -26,7 +26,7 @@ `{A detailed list of any necessary changes}` -> * `{Please delete this quoted section when opening your pull request}` -> * You must follow the template instructions. Failure to do so will result in your issue being closed. -> * Please respect that Pi-hole is developed by volunteers, who can only reply in their spare time. -> * Detail helps us understand an issue quicker, but please ensure it's relevant. +> - `{Please delete this quoted section when opening your pull request}` +> - You must follow the template instructions. Failure to do so will result in your issue being closed. +> - Please respect that Pi-hole is developed by volunteers, who can only reply in their spare time. +> - Detail helps us understand an issue quicker, but please ensure it's relevant. diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b0cca47c..2aea7823 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,14 @@ name: Tests -on: [push, pull_request] + +on: + push: + branches: + - devel + - master + pull_request: + branches: + - "**" + env: CI: true @@ -8,11 +17,6 @@ jobs: name: Node ${{ matrix.node }} runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - node: [12] - steps: - name: Clone repository uses: actions/checkout@v2 @@ -20,7 +24,7 @@ jobs: - name: Set Node.js version uses: actions/setup-node@v1 with: - node-version: ${{ matrix.node }} + node-version: "12.x" - name: Install npm dependencies run: npm ci diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2ea84399..4a308af5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,8 +6,8 @@ Please read and understand the contribution guide before creating an issue or pu ## Etiquette -- Our goal for Pi-hole is **stability before features**. This means we focus on squashing critical bugs before adding new features. Often, we can do both in tandem, but bugs will take priority over a new feature. -- Pi-hole is open source and [powered by donations](https://pi-hole.net/donate/), and as such, we give our **free time** to build, maintain, and **provide user support** for this project. It would be extremely unfair for us to suffer abuse or anger for our hard work, so please take a moment to consider that. +- Our goal for Pi-hole is **stability before features**. This means we focus on squashing critical bugs before adding new features. Often, we can do both in tandem, but bugs will take priority over a new feature. +- Pi-hole is open source and [powered by donations](https://pi-hole.net/donate/), and as such, we give our **free time** to build, maintain, and **provide user support** for this project. It would be extremely unfair for us to suffer abuse or anger for our hard work, so please take a moment to consider that. - Please be considerate towards the developers and other users when raising issues or presenting pull requests. - Respect our decision(s), and do not be upset or abusive if your submission is not used. diff --git a/README.md b/README.md index 4c3684e3..dff6425e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,14 @@

-Pi-hole

-Network-wide ad blocking via your own Linux hardware
-
-Pi-hole Web interface
+ + Pi-hole + +
+ Network-wide ad blocking via your own Linux hardware +
+
+ + Pi-hole Web interface +

Pi-hole[®](https://pi-hole.net/trademark-rules-and-brand-guidelines/)'s Web interface (based off of [AdminLTE](https://github.com/ColorlibHQ/AdminLTE)) provides a central location to manage your Pi-hole and review the statistics generated by FTLDNS[™](https://pi-hole.net/trademark-rules-and-brand-guidelines/). @@ -13,6 +19,7 @@ Pi-hole[®](https://pi-hole.net/trademark-rules-and-brand-guidelines/)'s Web int - **Insightful**: use the query log, audit log, or long-term stats to gain insight into your networks activity --- +
# Installation @@ -20,6 +27,7 @@ Pi-hole[®](https://pi-hole.net/trademark-rules-and-brand-guidelines/)'s Web int The Web interface is enabled by default when you install Pi-hole. ## Post-installation: access the Web interface and gain insight into your network's activity + There are several ways to [access the dashboard](https://discourse.pi-hole.net/t/how-do-i-access-pi-holes-dashboard-admin-interface/3168): 1. `http:///admin/` @@ -33,123 +41,140 @@ Once logged in (forgot your password?), you can view your network stats to see t - the amount of domains that were blocked - the upstream server queries were sent to - the type of queries (`A`, `AAAA`, `CNAME`, `SRV`, `TXT`, etc.) + --- ## Pi-hole is free, but powered by your support + There are many reoccurring costs involved with maintaining free, open source, and privacy respecting software; expenses which [our volunteer developers](https://github.com/orgs/pi-hole/people) pitch in to cover out-of-pocket. This is just one example of how strongly we feel about our software, as well as the importance of keeping it maintained. Make no mistake: **your support is absolutely vital to help keep us innovating!** ### Donations + Sending a donation using our links below is **extremely helpful** in offsetting a portion of our monthly expenses: -- PP Donate via PayPal
-- BTC [Bitcoin, Bitcoin Cash, Ethereum, Litecoin](https://commerce.coinbase.com/checkout/dd304d04-f324-4a77-931b-0db61c77a41b) +- PP [Donate via PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY) +- BTC [Bitcoin, Bitcoin Cash, Ethereum, Litecoin](https://commerce.coinbase.com/checkout/dd304d04-f324-4a77-931b-0db61c77a41b) ### Alternative support + If you'd rather not [donate](https://pi-hole.net/donate/) (_which is okay!_), there are other ways you can help support us: - [Patreon](https://patreon.com/pihole) _Become a patron for rewards_ -- [Digital Ocean](http://www.digitalocean.com/?refcode=344d234950e1) _affiliate link_ -- [Stickermule](https://www.stickermule.com/unlock?ref_id=6055890701&utm_medium=link&utm_source=invite) _earn a $10 credit after your first purchase_ +- [Digital Ocean](https://www.digitalocean.com/?refcode=344d234950e1) _affiliate link_ +- [Stickermule](https://www.stickermule.com/unlock?ref_id=6055890701&utm_medium=link&utm_source=invite) _earn a \$10 credit after your first purchase_ - [Pi-hole Swag Store](https://pi-hole.net/shop/) _affiliate link_ -- [Amazon](http://www.amazon.com/exec/obidos/redirect-home/pihole09-20) _affiliate link_ +- [Amazon](https://www.amazon.com/exec/obidos/redirect-home/pihole09-20) _affiliate link_ - [DNS Made Easy](https://cp.dnsmadeeasy.com/u/133706) _affiliate link_ -- [Vultr](http://www.vultr.com/?ref=7190426) _affiliate link_ - Spreading the word about our software, and how you have benefited from it ### Contributing via GitHub + We welcome _everyone_ to contribute to issue reports, suggest new features, and create pull requests. If you have something to add - anything from a typo through to a whole new feature, we're happy to check it out! Just make sure to fill out our template when submitting your request; the questions that it asks will help the volunteers quickly understand what you're aiming to achieve. ### Presentations about Pi-hole + Word-of-mouth continues to help our project grow immensely, and so we are helping make this easier for people. If you are going to be presenting Pi-hole at a conference, meetup or even a school project, [get in touch with us](https://pi-hole.net/2017/05/17/giving-a-presentation-on-pi-hole-contact-us-first-for-some-goodies-and-support/) so we can hook you up with free swag to hand out to your audience! ------ +--- ## Getting in touch with us + While we are primarily reachable on our Discourse User Forum, we can also be found on a variety of social media outlets. **Please be sure to check the FAQ's** before starting a new discussion, as we do not have the spare time to reply to every request for assistance. - +* **[Frequently Asked Questions](https://discourse.pi-hole.net/c/faqs)** +* **[Pi-hole Wiki](https://github.com/pi-hole/pi-hole/wiki)** +* **[Feature Requests](https://discourse.pi-hole.net/c/feature-requests?order=votes)** +* [Discourse User Forum](https://discourse.pi-hole.net/) +* [Reddit](https://www.reddit.com/r/pihole/) +* [Twitter](https://twitter.com/The_Pi_Hole) +* [Facebook](https://www.facebook.com/ThePiHole/) +* [Gitter](https://gitter.im/pi-hole/pi-hole) (Real-time chat) +* [YouTube](https://www.youtube.com/channel/UCT5kq9w0wSjogzJb81C9U0w) # Features ## Mobile friendly interface +

-Mobile friendly + Mobile friendly

## Password protection +

-Password protection + Password protection

## Detailed graphs and doughnut charts +

-Pie charts + Pie charts

## Top lists of domains and clients +

-Top domains/top clients + Top domains/top clients

## A filterable and sortable query log +

-Query log + Query log

## An audit log +

-Pi-hole Web interface + Pi-hole Web interface

-## Long Term Statistics to view data over user defined time ranges +## Long-term statistics to view data over user defined time ranges +

-Long-term stats + Long-term stats

## A built-in debugger +

-Debugger + Debugger

## Black and white lists +

-Blacklist -

-Whitelist + Blacklist +

+ Whitelist

## The ability to easily manage and configure Pi-hole features +

-Settings + Settings

## ... and all the main features of the Command Line Interface! +

-Tail the log -

-Query ad lists + Tail the log +

+ Query ad lists

## API -Full usage available [here](https://discourse.pi-hole.net/t/pi-hole-api/1863). can be accessed at `/admin/api.php`. With either no parameters or `/admin/api.php?summary` it returns the following JSON: -```JSON -{ + +Full usage available [here](https://discourse.pi-hole.net/t/pi-hole-api/1863). Can be accessed at `/admin/api.php`. With either no parameters or `/admin/api.php?summary` it returns the following JSON: + +```json +{ "domains_being_blocked":243038, "dns_queries_today":2385, "ads_blocked_today":414, diff --git a/api.php b/api.php index e06a43a7..318dd910 100644 --- a/api.php +++ b/api.php @@ -7,10 +7,10 @@ * Please see LICENSE file for your rights under this license */ $api = true; -header('Content-type: application/json'); -require("scripts/pi-hole/php/FTL.php"); -require("scripts/pi-hole/php/password.php"); -require("scripts/pi-hole/php/auth.php"); +require_once("scripts/pi-hole/php/FTL.php"); +require_once("scripts/pi-hole/php/password.php"); +require_once("scripts/pi-hole/php/database.php"); +require_once("scripts/pi-hole/php/auth.php"); check_cors(); $FTL_IP = "127.0.0.1"; @@ -107,29 +107,49 @@ elseif (isset($_GET['versions'])) } elseif (isset($_GET['list'])) { + if (!$auth) + die("Not authorized!"); + + if(!isset($_GET["list"])) + die("List has not been specified."); + + switch ($_GET["list"]) { + case 'black': + $_POST['type'] = ListType::blacklist; + break; + case 'regex_black': + $_POST['type'] = ListType::regex_blacklist; + break; + case 'white': + $_POST['type'] = ListType::whitelist; + break; + case 'regex_white': + $_POST['type'] = ListType::regex_whitelist; + break; + + default: + die("Invalid list [supported: black, regex_black, white, regex_white]"); + } + if (isset($_GET['add'])) { - if (!$auth) - die("Not authorized!"); - // Set POST parameters and invoke script to add domain to list $_POST['domain'] = $_GET['add']; - $_POST['list'] = $_GET['list']; - require("scripts/pi-hole/php/add.php"); + $_POST['action'] = 'add_domain'; + require("scripts/pi-hole/php/groups.php"); } elseif (isset($_GET['sub'])) { - if (!$auth) - die("Not authorized!"); - // Set POST parameters and invoke script to remove domain from list $_POST['domain'] = $_GET['sub']; - $_POST['list'] = $_GET['list']; - require("scripts/pi-hole/php/sub.php"); + $_POST['action'] = 'delete_domain_string'; + require("scripts/pi-hole/php/groups.php"); } else { - require("scripts/pi-hole/php/get.php"); + // Set POST parameters and invoke script to get all domains + $_POST['action'] = 'get_domains'; + require("scripts/pi-hole/php/groups.php"); } return; @@ -138,6 +158,7 @@ elseif (isset($_GET['list'])) // Other API functions require("api_FTL.php"); +header('Content-type: application/json'); if(isset($_GET["jsonForceObject"])) { echo json_encode($data, JSON_FORCE_OBJECT); diff --git a/api_FTL.php b/api_FTL.php index f1a882d6..85ee3f8a 100644 --- a/api_FTL.php +++ b/api_FTL.php @@ -320,7 +320,7 @@ else // UTF-8 encode domain $tmp[2] = utf8_encode($tmp[2]); // UTF-8 encode client host name - $tmp[3] = utf8_encode($tmp[3]);; + $tmp[3] = utf8_encode($tmp[3]); array_push($allQueries,$tmp); } diff --git a/api_db.php b/api_db.php index 34d0b8af..cddfb17a 100644 --- a/api_db.php +++ b/api_db.php @@ -278,7 +278,7 @@ if (isset($_GET['topAds']) && $auth) { $limit = " AND timestamp <= :until"; } - $stmt = $db->prepare('SELECT domain,count(domain) FROM queries WHERE (STATUS == 1 OR STATUS == 4)'.$limit.' GROUP by domain order by count(domain) desc limit 10'); + $stmt = $db->prepare('SELECT domain,count(domain) FROM queries WHERE (STATUS == 1 OR STATUS > 3)'.$limit.' GROUP by domain order by count(domain) desc limit 10'); $stmt->bindValue(":from", intval($_GET['from']), SQLITE3_INTEGER); $stmt->bindValue(":until", intval($_GET['until']), SQLITE3_INTEGER); $results = $stmt->execute(); @@ -410,7 +410,7 @@ if (isset($_GET['getGraphData']) && $auth) $data = array_merge($data, $result); // Count blocked queries in intervals - $stmt = $db->prepare('SELECT (timestamp/:interval)*:interval interval, COUNT(*) FROM queries WHERE (status == 1 OR status == 4 OR status == 5)'.$limit.' GROUP by interval ORDER by interval'); + $stmt = $db->prepare('SELECT (timestamp/:interval)*:interval interval, COUNT(*) FROM queries WHERE (status == 1 OR status > 3)'.$limit.' GROUP by interval ORDER by interval'); $stmt->bindValue(":from", $from, SQLITE3_INTEGER); $stmt->bindValue(":until", $until, SQLITE3_INTEGER); $stmt->bindValue(":interval", $interval, SQLITE3_INTEGER); @@ -422,6 +422,37 @@ if (isset($_GET['getGraphData']) && $auth) $data = array_merge($data, $result); } +if (isset($_GET['status'])) +{ + $results = $db->query('SELECT COUNT(*) FROM message;'); + + if(!is_bool($results)) + $result = array('message_count' => $results->fetchArray()[0]); + else + $result = array(); + + $data = array_merge($data, $result); +} + +if(isset($_GET["messages"]) && $auth) +{ + $messages = array(); + $results = $db->query('SELECT * FROM message'); + + while($results !== false && $res = $results->fetchArray(SQLITE3_ASSOC)) + { + // Convert string to to UTF-8 encoding to ensure php-json can handle it. + // Furthermore, convert special characters to HTML entities to prevent XSS attacks. + foreach ($res as $key => $value) { + if (is_string($value)) + $res[$key] = htmlspecialchars(utf8_encode($value)); + } + array_push($messages, $res); + } + + $data = array_merge($data, array('messages' => $messages)); +} + if(isset($_GET["jsonForceObject"])) { echo json_encode($data, JSON_FORCE_OBJECT); diff --git a/auditlog.php b/auditlog.php index 33ed04ac..64bf3efb 100644 --- a/auditlog.php +++ b/auditlog.php @@ -7,15 +7,14 @@ * Please see LICENSE file for your rights under this license. */ require "scripts/pi-hole/php/header.php"; ?> - - +
-
+

Allowed queries

@@ -42,7 +41,8 @@
-
+ +

Blocked queries

@@ -72,6 +72,7 @@
+ - - -
- + + + - -
- - + + - -
-
- +

+
-
- +

+
-
- +

+
-
-
- +

+

+
-