Guest User

Untitled

a guest
Apr 19th, 2017
722
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 60.41 KB | None | 0 0
  1. login as: pi
  2. pi@172.16.0.26's password:
  3.  
  4. The programs included with the Debian GNU/Linux system are free software;
  5. the exact distribution terms for each program are described in the
  6. individual files in /usr/share/doc/*/copyright.
  7.  
  8. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
  9. permitted by applicable law.
  10. Last login: Wed Apr 19 17:34:37 2017 from 172.16.0.2
  11.  
  12. SSH is enabled and the default password for the 'pi' user has not been changed.
  13. This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.
  14.  
  15. pi@raspberrypi:~ $ cd /var/www/html/admin
  16. pi@raspberrypi:/var/www/html/admin $ git show
  17. commit 1355e6a42ce5706e0ddadcedf4b42fd92a633496
  18. commit 1355e6a42ce5706e0ddadcedf4b42fd92a633496
  19. commit 1355e6a42ce5706e0ddadcedf4b42fd92a633496
  20. Author: Adam Warner <PromoFaux@users.noreply.github.com>
  21. Date: Tue Mar 14 13:17:18 2017 +0000
  22.  
  23. Merge pull request #443 from pi-hole/fix/teleporter
  24.  
  25. Bugfix: Teleporter Export feature
  26.  
  27. diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
  28. new file mode 100644
  29. index 0000000..6f277b2
  30. --- /dev/null
  31. +++ b/.github/ISSUE_TEMPLATE.md
  32. @@ -0,0 +1,33 @@
  33. +**In raising this issue, I confirm the following (please check boxes, eg [X] - no spaces) Failure to fill the template will close your issue:**
  34. +
  35. +- [] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md).
  36. +- [] The issue I am reporting can be *replicated*
  37. +- [] The issue I'm reporting isn't a duplicate (see [FAQs](https://github.com/pi-hole/pi-hole/wiki/FAQs), [closed issues](https://github.com/pi-hole/pi-hole/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), and [open issues](https://github.com/pi-hole/pi-hole/issues)).
  38. +
  39. +**How familiar are you with the codebase?:**
  40. +
  41. +_{replace this text with a number from 1 to 10, with 1 being not familiar, and 10 being very familiar}_
  42. +
  43. +---
  44. +**[FEATURE REQUEST | QUESTION | OTHER]:**
  45. +
  46. +Please [submit your feature request here](https://discourse.pi-hole.net/c/feature-requests), so it is votable by the community. It's also easier for us to track.
  47. +
  48. +**[BUG | ISSUE] Expected Behaviour:**
  49. +
  50. +
  51. +**[BUG | ISSUE] Actual Behaviour:**
  52. +
  53. +
  54. +**[BUG | ISSUE] Steps to reproduce:**
  55. +
  56. +-
  57. +-
  58. +-
  59. +-
  60. +
  61. +**(Optional) Debug token generated by `pihole -d`:**
  62. +
  63. +`<token>`
  64. +
  65. +_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._
  66. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
  67. new file mode 100644
  68. index 0000000..2c39142
  69. --- /dev/null
  70. +++ b/.github/PULL_REQUEST_TEMPLATE.md
  71. @@ -0,0 +1,19 @@
  72. +**By submitting this pull request, I confirm the following (please check boxes, eg [X] - no spaces) _Failure to fill the template will close your PR_:**
  73. +
  74. +***Please submit all pull requests against the `development` branch. Failure to do so will delay or deny your request***
  75. +
  76. +- [] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md).
  77. +- [] I have checked that [another pull request](https://github.com/pi-hole/pi-hole/pulls) for this purpose does not exist.
  78. +- [] I have considered, and confirmed that this submission will be valuable to others.
  79. +- [] I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  80. +- [] I give this submission freely, and claim no ownership to its content.
  81. +
  82. +**How familiar are you with the codebase?:**
  83. +
  84. +_{replace this text with a number from 1 to 10, with 1 being not familiar, and 10 being very familiar}_
  85. +
  86. +---
  87. +_{replace this line with your pull request content}_
  88. +
  89. +
  90. +_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._
  91. diff --git a/.gitignore b/.gitignore
  92. new file mode 100644
  93. index 0000000..a4c3ecb
  94. --- /dev/null
  95. +++ b/.gitignore
  96. @@ -0,0 +1,17 @@
  97. +*.DS_Store
  98. +.idea
  99. +/nbproject/private/
  100. +/nbproject/
  101. +/node_modules/
  102. +TODO
  103. +*.zip
  104. +test.html
  105. +*.log
  106. +
  107. +# Intellij IDEA Project Files
  108. +*.iml
  109. +*.ipr
  110. +*.iws
  111. +
  112. +# vim
  113. +*.swp
  114. diff --git a/.pullapprove.yml b/.pullapprove.yml
  115. new file mode 100644
  116. index 0000000..8bd8f0a
  117. --- /dev/null
  118. +++ b/.pullapprove.yml
  119. @@ -0,0 +1,38 @@
  120. +version: 2
  121. +
  122. +always_pending:
  123. + title_regex: '(WIP|wip)'
  124. + labels:
  125. + - wip
  126. + explanation: 'This PR is a work in progress...'
  127. +
  128. +group_defaults:
  129. + reset_on_push:
  130. + enabled: true
  131. + reject_value: -2
  132. + approve_regex: '^(Approved|:shipit:|:\+1:|Engage)'
  133. + reject_regex: '^(Rejected|:-1:|Borg)'
  134. + author_approval:
  135. + auto: true
  136. +
  137. +
  138. +groups:
  139. + development:
  140. + approve_by_comment:
  141. + enabled: true
  142. + conditions:
  143. + branches:
  144. + - devel
  145. + required: 2
  146. + teams:
  147. + - approvers
  148. +
  149. + master:
  150. + approve_by_comment:
  151. + enabled: true
  152. + conditions:
  153. + branches:
  154. + - master
  155. + required: -1
  156. + teams:
  157. + - admin
  158. diff --git a/.user.php.ini b/.user.php.ini
  159. new file mode 100644
  160. index 0000000..7660f85
  161. --- /dev/null
  162. +++ b/.user.php.ini
  163. @@ -0,0 +1,2 @@
  164. +memory_limit = 256M
  165. +max_execution_time = 300
  166. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
  167. new file mode 100644
  168. index 0000000..64e702f
  169. --- /dev/null
  170. +++ b/CONTRIBUTING.md
  171. @@ -0,0 +1,9 @@
  172. +This is a basic checklist for now, We will update it in the future.
  173. +
  174. +* Fork the repo and create your new branch based on the `devel` (development) branch.
  175. +* Use 4 spaces instead of tabs
  176. +* Commit Unix line endings
  177. +* If you want, try to keep to the theme of black holes/gravity. This can add some fun to your submission.
  178. +* Submit Pull Requests to the development branch only.
  179. +* Before Submitting your Pull Request, merge `devel` with your new branch and fix any conflicts. (Make sure you don't break anything in development!)
  180. +* Be patient. We will review all submitted pull requests, but our focus is on stability.. please don't be offended if we reject your PR, or it appears we're doing nothing with it! We'll get around to it..
  181. diff --git a/LICENSE b/LICENSE
  182. new file mode 100644
  183. index 0000000..1a3787f
  184. --- /dev/null
  185. +++ b/LICENSE
  186. @@ -0,0 +1,166 @@
  187. +Copyright (C) 2017 Pi-hole, LLC (https://pi-hole.net)
  188. +Pi-hole web interface
  189. +
  190. +This software is licensed under the European Union Public License (EUPL)
  191. +The license is available in the 22 official languages of the EU. The English version is included here.
  192. +Please see https://joinup.ec.europa.eu/community/eupl/og_page/eupl for official translations of the other languages.
  193. +
  194. +This license applies to the whole project EXCEPT the files located under
  195. + - styles/vendor, and
  196. + - scripts/vendor
  197. +whose licenses are located therein.
  198. +
  199. +-------------------------------------------------------------
  200. +
  201. +European Union Public Licence
  202. +V. 1.1
  203. +
  204. +EUPL (C) the European Community 2007
  205. +
  206. +This European Union Public Licence (the "EUPL") applies to the Work or Software (as defined below) which is provided under the terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such use is covered by a right of the copyright holder of the Work).
  207. +
  208. +The Original Work is provided under the terms of this Licence when the Licensor (as defined below) has placed the following notice immediately following the copyright notice for the Original Work:
  209. +
  210. +Licensed under the EUPL V.1.1
  211. +
  212. +or has expressed by any other mean his willingness to license under the EUPL.
  213. +
  214. +1. Definitions
  215. +
  216. +In this Licence, the following terms have the following meaning:
  217. +
  218. +- The Licence: this Licence.
  219. +
  220. +- The Original Work or the Software: the software distributed and/or communicated by the Licensor under this Licence, available as Source Code and also as Executable Code as the case may be.
  221. +
  222. +- Derivative Works: the works or software that could be created by the Licensee, based upon the Original Work or modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in the country mentioned in Article 15.
  223. +
  224. +- The Work: the Original Work and/or its Derivative Works.
  225. +
  226. +- The Source Code: the human-readable form of the Work which is the most convenient for people to study and modify.
  227. +
  228. +- The Executable Code: any code which has generally been compiled and which is meant to be interpreted by a computer as a program.
  229. +
  230. +- The Licensor: the natural or legal person that distributes and/or communicates the Work under the Licence.
  231. +
  232. +- Contributor(s): any natural or legal person who modifies the Work under the Licence, or otherwise contributes to the creation of a Derivative Work.
  233. +
  234. +- The Licensee or "You": any natural or legal person who makes any usage of the Software under the terms of the Licence.
  235. +
  236. +- Distribution and/or Communication: any act of selling, giving, lending, renting, distributing, communicating, transmitting, or otherwise making available, on-line or off-line, copies of the Work or providing access to its essential functionalities at the disposal of any other natural or legal person.
  237. +
  238. +2. Scope of the rights granted by the Licence
  239. +
  240. +The Licensor hereby grants You a world-wide, royalty-free, non-exclusive, sub-licensable licence to do the following, for the duration of copyright vested in the Original Work:
  241. +
  242. +- use the Work in any circumstance and for all usage,
  243. +- reproduce the Work,
  244. +- modify the Original Work, and make Derivative Works based upon the Work,
  245. +- communicate to the public, including the right to make available or display the Work or copies thereof to the public and perform publicly, as the case may be, the Work,
  246. +- distribute the Work or copies thereof,
  247. +- lend and rent the Work or copies thereof,
  248. +- sub-license rights in the Work or copies thereof.
  249. +
  250. +Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the applicable law permits so.
  251. +
  252. +In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed by law in order to make effective the licence of the economic rights here above listed.
  253. +
  254. +The Licensor grants to the Licensee royalty-free, non exclusive usage rights to any patents held by the Licensor, to the extent necessary to make use of the rights granted on the Work under this Licence.
  255. +
  256. +3. Communication of the Source Code
  257. +
  258. +The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to distribute and/or communicate the Work.
  259. +
  260. +4. Limitations on copyright
  261. +
  262. +Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the exclusive rights of the rights owners in the Original Work or Software, of the exhaustion of those rights or of other applicable limitations thereto.
  263. +
  264. +5. Obligations of the Licensee
  265. +
  266. +The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those obligations are the following:
  267. +
  268. +Attribution right: the Licensee shall keep intact all copyright, patent or trademarks notices and all notices that refer to the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the Licence with every copy of the Work he/she distributes and/or communicates. The Licensee must cause any Derivative Work to carry prominent notices stating that the Work has been modified and the date of modification.
  269. +
  270. +Copyleft clause: If the Licensee distributes and/or communicates copies of the Original Works or Derivative Works based upon the Original Work, this Distribution and/or Communication will be done under the terms of this Licence or of a later version of this Licence unless the Original Work is expressly distributed only under this version of the Licence. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the Work or Derivative Work that alter or restrict the terms of the Licence.
  271. +
  272. +Compatibility clause: If the Licensee Distributes and/or Communicates Derivative Works or copies thereof based upon both the Original Work and another work licensed under a Compatible Licence, this Distribution and/or Communication can be done under the terms of this Compatible Licence. For the sake of this clause, "Compatible Licence" refers to the licences listed in the appendix attached to this Licence. Should the Licensee’s obligations under the Compatible Licence conflict with his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail.
  273. +
  274. +Provision of Source Code: When distributing and/or communicating copies of the Work, the Licensee will provide a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available for as long as the Licensee continues to distribute and/or communicate the Work.
  275. +
  276. +Legal Protection: This Licence does not grant permission to use the trade names, trademarks, service marks, or names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the copyright notice.
  277. +
  278. +6. Chain of Authorship
  279. +
  280. +The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or licensed to him/her and that he/she has the power and authority to grant the Licence.
  281. +
  282. +Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or licensed to him/her and that he/she has the power and authority to grant the Licence.
  283. +
  284. +Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions to the Work, under the terms of this Licence.
  285. +
  286. +7. Disclaimer of Warranty
  287. +
  288. +The Work is a work in progress, which is continuously improved by numerous contributors. It is not a finished work and may therefore contain defects or "bugs" inherent to this type of software development.
  289. +
  290. +For the above reason, the Work is provided under the Licence on an "as is" basis and without warranties of any kind concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this Licence.
  291. +
  292. +This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work.
  293. +
  294. +8. Disclaimer of Liability
  295. +
  296. +Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However, the Licensor will be liable under statutory product liability laws as far such laws apply to the Work.
  297. +
  298. +9. Additional agreements
  299. +
  300. +While distributing the Original Work or Derivative Works, You may choose to conclude an additional agreement to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or services consistent with this Licence. However, in accepting such obligations, You may act only on your own behalf and on your sole responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by the fact You have accepted any such warranty or additional liability.
  301. +
  302. +10. Acceptance of the Licence
  303. +
  304. +The provisions of this Licence can be accepted by clicking on an icon "I agree" placed under the bottom of a window displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms and conditions.
  305. +
  306. +Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution and/or Communication by You of the Work or copies thereof.
  307. +
  308. +11. Information to the public
  309. +
  310. +In case of any Distribution and/or Communication of the Work by means of electronic communication by You (for example, by offering to download the Work from a remote location) the distribution channel or media (for example, a website) must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence and the way it may be accessible, concluded, stored and reproduced by the Licensee.
  311. +
  312. +12. Termination of the Licence
  313. +
  314. +The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms of the Licence.
  315. +
  316. +Such a termination will not terminate the licences of any person who has received the Work from the Licensee under the Licence, provided such persons remain in full compliance with the Licence.
  317. +
  318. +13. Miscellaneous
  319. +
  320. +Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the Work licensed hereunder.
  321. +
  322. +If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or enforceability of the Licence as a whole. Such provision will be construed and/or reformed so as necessary to make it valid and enforceable.
  323. +
  324. +The European Commission may publish other linguistic versions and/or new versions of this Licence, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence. New versions of the Licence will be published with a unique version number.
  325. +
  326. +All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take advantage of the linguistic version of their choice.
  327. +
  328. +14. Jurisdiction
  329. +
  330. +Any litigation resulting from the interpretation of this License, arising between the European Commission, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice of the European Communities, as laid down in article 238 of the Treaty establishing the European Community.
  331. +
  332. +Any litigation arising between Parties, other than the European Commission, and resulting from the interpretation of this License, will be subject to the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business.
  333. +
  334. +15. Applicable Law
  335. +
  336. +This Licence shall be governed by the law of the European Union country where the Licensor resides or has his registered office.
  337. +
  338. +This licence shall be governed by the Belgian law if:
  339. +
  340. +- a litigation arises between the European Commission, as a Licensor, and any Licensee;
  341. +- the Licensor, other than the European Commission, has no residence or registered office inside a European Union country.
  342. +
  343. +
  344. +===
  345. +Appendix
  346. +
  347. +"Compatible Licences" according to article 5 EUPL are:
  348. +- GNU General Public License (GNU GPL) v. 2
  349. +- Open Software License (OSL) v. 2.1, v. 3.0
  350. +- Common Public License v. 1.0
  351. +- Eclipse Public License v. 1.0
  352. +- Cecill v. 2.0
  353. diff --git a/README.md b/README.md
  354. new file mode 100644
  355. index 0000000..1276987
  356. --- /dev/null
  357. +++ b/README.md
  358. @@ -0,0 +1,30 @@
  359. +Pi-hole Admin Dashboard
  360. +============
  361. +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/938b4d9e61b7487da77cf63ba05c683d)](https://www.codacy.com/app/Pi-hole/AdminLTE?utm_source=github.com&utm_medium=referral&utm_content=pi-hole/AdminLTE&utm_campaign=badger)
  362. +[![Join the chat at https://gitter.im/pi-hole/AdminLTE](https://badges.gitter.im/pi-hole/AdminLTE.svg)](https://gitter.im/pi-hole/AdminLTE?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
  363. +
  364. +[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "AdminLTE Presentation")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate")
  365. +
  366. +Using **[AdminLTE](https://almsaeedstudio.com)**, this project will create a Web interface for the ad-blocking Pi-hole: **a black hole for Internet advertisements**.
  367. +
  368. +From this interface, you will be able to see stats on how well your Pi-hole is performing. You will also be able to update the lists used to block ads.
  369. +
  370. +![Pi-hole Web interface](http://i.imgur.com/EgGZXbT.png)
  371. +
  372. +## API
  373. +A read-only API can be accessed at `/admin/api.php`. With either no parameters or `api.php?summary` it returns the following JSON:
  374. +```JSON
  375. +{
  376. + "domains_being_blocked": "136,708",
  377. + "dns_queries_today": "18,108",
  378. + "ads_blocked_today": "14,648",
  379. + "ads_percentage_today": "80.9"
  380. +}
  381. +```
  382. +
  383. +There are many more parameters, such as `summaryRaw`, `overTimeData10mins`, ` topClients` or `getQuerySources`, `getQueryTypes`, `getForwardDestinations`, and `getAllQueries`.
  384. +Together with a token it is also possible to enable and disable (also with a set timeout) blocking via the API.
  385. +
  386. +<hr>
  387. +<img src="https://assets.pi-hole.net/static/BStackLogo.png" height="80"><br>
  388. +We use BrowserStack for multi-platform multi-browser testing.
  389. diff --git a/api.php b/api.php
  390. new file mode 100644
  391. index 0000000..e8703cc
  392. --- /dev/null
  393. +++ b/api.php
  394. @@ -0,0 +1,151 @@
  395. +<?php
  396. +/* Pi-hole: A black hole for Internet advertisements
  397. +* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
  398. +* Network-wide ad blocking via your own hardware.
  399. +*
  400. +* This file is copyright under the latest version of the EUPL.
  401. +* Please see LICENSE file for your rights under this license. */
  402. +
  403. + $api = true;
  404. + require "scripts/pi-hole/php/password.php";
  405. + require "scripts/pi-hole/php/auth.php";
  406. +
  407. + check_cors();
  408. +
  409. + include('scripts/pi-hole/php/data.php');
  410. + header('Content-type: application/json');
  411. +
  412. + $data = array();
  413. +
  414. + // Non-Auth
  415. +
  416. + if (isset($_GET['type'])) {
  417. + $data["type"] = "PHP";
  418. + }
  419. +
  420. + if (isset($_GET['version'])) {
  421. + $data["version"] = 2;
  422. + }
  423. +
  424. + if (isset($_GET['summaryRaw'])) {
  425. + $data = array_merge($data, getSummaryData());
  426. + }
  427. +
  428. + if (isset($_GET['summary']) || !count($_GET)) {
  429. + $sum = getSummaryData();
  430. + $sum['ads_blocked_today'] = number_format( $sum['ads_blocked_today']);
  431. + $sum['dns_queries_today'] = number_format( $sum['dns_queries_today']);
  432. + $sum['ads_percentage_today'] = number_format( $sum['ads_percentage_today'], 1, '.', '');
  433. + $sum['domains_being_blocked'] = number_format( $sum['domains_being_blocked']);
  434. + $data = array_merge($data, $sum);
  435. + }
  436. +
  437. + if (isset($_GET['overTimeData'])) {
  438. + $data = array_merge($data, getOverTimeData());
  439. + }
  440. +
  441. + if (isset($_GET['overTimeData10mins'])) {
  442. + $data = array_merge($data, getOverTimeData10mins());
  443. + }
  444. +
  445. + // Auth Required
  446. +
  447. + if (isset($_GET['topItems']) && $auth) {
  448. + $data = array_merge($data, getTopItems($_GET['topItems']));
  449. + }
  450. +
  451. + if (isset($_GET['recentItems']) && $auth) {
  452. + if (is_numeric($_GET['recentItems'])) {
  453. + $data = array_merge($data, getRecentItems($_GET['recentItems']));
  454. + }
  455. + }
  456. +
  457. + if (isset($_GET['getQueryTypes']) && $auth) {
  458. + $data = array_merge($data, getIpvType());
  459. + }
  460. +
  461. + if (isset($_GET['getForwardDestinations']) && $auth) {
  462. + $data = array_merge($data, getForwardDestinations());
  463. + }
  464. +
  465. + if (isset($_GET['getQuerySources']) && $auth) {
  466. + $data = array_merge($data, getQuerySources());
  467. + }
  468. +
  469. + if (isset($_GET['getAllQueries']) && $auth) {
  470. + $data = array_merge($data, getAllQueries($_GET['getAllQueries']));
  471. + }
  472. +
  473. + if (isset($_GET['enable']) && $auth) {
  474. + if(isset($_GET["auth"]))
  475. + {
  476. + if($_GET["auth"] !== $pwhash)
  477. + die("Not authorized!");
  478. + }
  479. + else
  480. + {
  481. + // Skip token validation if explicit auth string is given
  482. + check_csrf($_GET['token']);
  483. + }
  484. + exec('sudo pihole enable');
  485. + $data = array_merge($data, array("status" => "enabled"));
  486. + unlink("../custom_disable_timer");
  487. + }
  488. + elseif (isset($_GET['disable']) && $auth) {
  489. + if(isset($_GET["auth"]))
  490. + {
  491. + if($_GET["auth"] !== $pwhash)
  492. + die("Not authorized!");
  493. + }
  494. + else
  495. + {
  496. + // Skip token validation if explicit auth string is given
  497. + check_csrf($_GET['token']);
  498. + }
  499. + $disable = intval($_GET['disable']);
  500. + // intval returns the integer value on success, or 0 on failure
  501. + if($disable > 0)
  502. + {
  503. + $timestamp = time();
  504. + exec("sudo pihole disable ".$disable."s");
  505. + file_put_contents("../custom_disable_timer",($timestamp+$disable)*1000);
  506. + }
  507. + else
  508. + {
  509. + exec('sudo pihole disable');
  510. + unlink("../custom_disable_timer");
  511. + }
  512. + $data = array_merge($data, array("status" => "disabled"));
  513. + }
  514. +
  515. + if (isset($_GET['getGravityDomains'])) {
  516. + $data = array_merge($data, getGravity());
  517. + }
  518. +
  519. + if (isset($_GET['tailLog']) && $auth) {
  520. + $data = array_merge($data, tailPiholeLog($_GET['tailLog']));
  521. + }
  522. +
  523. + function filterArray(&$inArray) {
  524. + $outArray = array();
  525. + foreach ($inArray as $key=>$value) {
  526. + if (is_array($value)) {
  527. + $outArray[htmlspecialchars($key)] = filterArray($value);
  528. + } else {
  529. + $outArray[htmlspecialchars($key)] = !is_numeric($value) ? htmlspecialchars($value) : $value;
  530. + }
  531. + }
  532. + return $outArray;
  533. + }
  534. +
  535. + $data = filterArray($data);
  536. +
  537. + if(isset($_GET["jsonForceObject"]))
  538. + {
  539. + echo json_encode($data, JSON_FORCE_OBJECT);
  540. + }
  541. + else
  542. + {
  543. + echo json_encode($data);
  544. + }
  545. +?>
  546. diff --git a/debug.php b/debug.php
  547. new file mode 100644
  548. index 0000000..84416cf
  549. --- /dev/null
  550. +++ b/debug.php
  551. @@ -0,0 +1,19 @@
  552. +<?php
  553. + require "scripts/pi-hole/php/header.php";
  554. +?>
  555. +<!-- Title -->
  556. +<div class="page-header">
  557. + <h1>Generate debug log</h1>
  558. +</div>
  559. +
  560. +<p><input type="checkbox" id="upload" checked> Upload debug log and provide token once finished</p>
  561. +<p>Once you click this button a debug log will be generated and can automatically be uploaded if we detect a working internet connection.</p>
  562. +<button class="btn btn-lg btn-primary btn-block" id="debugBtn">Generate debug log</button>
  563. +<pre id="output" style="width: 100%; height: 100%;" hidden="true"></pre>
  564. +
  565. +<?php
  566. + require "scripts/pi-hole/php/footer.php";
  567. +?>
  568. +
  569. +
  570. +<script src="scripts/pi-hole/js/debug.js"></script>
  571. diff --git a/gravity.php b/gravity.php
  572. new file mode 100644
  573. index 0000000..15f6e60
  574. --- /dev/null
  575. +++ b/gravity.php
  576. @@ -0,0 +1,33 @@
  577. +<!-- Pi-hole: A black hole for Internet advertisements
  578. +* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
  579. +* Network-wide ad blocking via your own hardware.
  580. +*
  581. +* This file is copyright under the latest version of the EUPL.
  582. +* Please see LICENSE file for your rights under this license. -->
  583. +<?php
  584. + require "scripts/pi-hole/php/header.php";
  585. +?>
  586. +<!-- Title -->
  587. +<div class="page-header">
  588. + <h1>Update list of ad-serving domains</h1>
  589. +</div>
  590. +
  591. +<!-- Alerts -->
  592. +<div id="alInfo" class="alert alert-info alert-dismissible fade in" role="alert" hidden="true">
  593. + <button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  594. + Updating...
  595. +</div>
  596. +<div id="alSuccess" class="alert alert-success alert-dismissible fade in" role="alert" hidden="true">
  597. + <button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  598. + Success!
  599. +</div>
  600. +
  601. +<button class="btn btn-lg btn-primary btn-block" id="gravityBtn">Update Lists</button>
  602. +<pre id="output" style="width: 100%; height: 100%;" hidden="true"></pre>
  603. +
  604. +<?php
  605. + require "scripts/pi-hole/php/footer.php";
  606. +?>
  607. +
  608. +
  609. +<script src="scripts/pi-hole/js/gravity.js"></script>
  610. diff --git a/help.php b/help.php
  611. new file mode 100644
  612. index 0000000..66818b1
  613. --- /dev/null
  614. +++ b/help.php
  615. @@ -0,0 +1,164 @@
  616. +<!-- Pi-hole: A black hole for Internet advertisements
  617. +* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
  618. +* Network-wide ad blocking via your own hardware.
  619. +*
  620. +* This file is copyright under the latest version of the EUPL.
  621. +* Please see LICENSE file for your rights under this license. -->
  622. +<?php
  623. + require "scripts/pi-hole/php/header.php";
  624. +
  625. + if(strlen($pwhash) > 0)
  626. + {
  627. + $authenticationsystem = true;
  628. + }
  629. + else
  630. + {
  631. + $authenticationsystem = false;
  632. + }
  633. +?>
  634. +
  635. +<div class="row">
  636. + <div class="col-md-12">
  637. + <h1>Help center</h1>
  638. + <h2>Header</h2>
  639. + <h4>Top left: Status display</h4>
  640. + <p>Shows different status messages:</p>
  641. + <ul>
  642. + <li>Status: Current status of the Pi-hole - Active (<i class="fa fa-circle" style="color:#7FFF00"></i>), Offline (<i class="fa fa-circle" style="color:#FF0000"></i>), or Starting (<i class="fa fa-circle" style="color:#ff9900"></i>)</li>
  643. + <li>Temp: Current CPU temperature</li>
  644. + <li>Load: load averages for the last minute, 5 minutes and 15 minutes, respectively. A load average of 1 reflects the full workload of a single processor on the system. We show a red icon if the current load exceeds the number of available processors on this machine (which is <?php echo $nproc; ?>)</li>
  645. + <li>Memory usage: Shows the percentage of memory actually blocked by applications. We show a red icon if the memory usage exceeds 75%</li>
  646. + </ul>
  647. + <h4>Top right: About</h4>
  648. + <ul>
  649. + <li>GitHub: Link to the Pi-hole repository</li>
  650. + <li>Details: Link to Jacob Salmela's blog with some more details, describing also the concept of the Pi-hole</li>
  651. + <li>Updates: Link to list of releases</li>
  652. + <li>Update notifications: If updates are available, a link will be shown here.</li>
  653. + <?php if($authenticationsystem){ ?>
  654. + <li>Session timer: Shows the time remaining until the current login session expires.</li>
  655. + <?php } ?>
  656. + </ul>
  657. + </div>
  658. +</div>
  659. +<div class="row">
  660. + <div class="col-md-12">
  661. + <h2>Dashboard</h2>
  662. + <p>On the dashboard, you can see various Pi-hole statistics:</p>
  663. + <ul>
  664. + <li>Summary: A summary of statistics showing how many total DNS queries have been blocked today, what percentage of DNS queries have been blocked, and how many domains are in the compiled ad list. This summary is updated every 10 seconds.</li>
  665. + <li>Queries over time: Graph showing DNS queries (total and blocked) over 10 minute time intervals. More information can be acquired by hovering over the lines. This graph is updated every 10 minutes.</li>
  666. + <li>Query Types: Identifies the types of processed queries:
  667. + <ul>
  668. + <li>A: address lookup (most commonly used to map hostnames to an IPv4 address of the host)</li>
  669. + <li>AAAA: address lookup (most commonly used to map hostnames to an IPv6 address of the host)</li>
  670. + <li>PTR: most common use is for implementing reverse DNS lookups</li>
  671. + <li>SRV: Service locator (often used by XMPP, SIP, and LDAP)</li>
  672. + <li>and others</li>
  673. + </ul>
  674. + </li>
  675. + <li>Forward Destinations: Shows to which upstream DNS the permitted requests have been forwarded to.</li>
  676. + <li>Top Domains: Ranking of requested sites by number of DNS lookups.</li>
  677. + <li>Top Advertisers: Ranking of requested advertisements by number of DNS lookups.</li>
  678. + <li>Top Clients: Ranking of how many DNS requests each client has made on the local network.</li>
  679. + </ul>
  680. + <?php if($authenticationsystem){ ?>
  681. + <p>Note that the login session does <em>not</em> expire on the dashboard, as the summary is updated every 10 seconds which refreshes the session.</p>
  682. + <?php } ?>
  683. + </div>
  684. +</div>
  685. +<div class="row">
  686. + <div class="col-md-12">
  687. + <h2>Query Log</h2>
  688. + <p>Shows the recent queries by parsing Pi-hole's log. It is possible to search through the whole list by using the "Search" input field. If the status is reported as "OK", then the DNS request has been permitted. Otherwise ("Pi-holed") it has been blocked. By clicking on the buttons under "Action" the corresponding domains can quickly be added to the white-/blacklist. The status of the action will be reported on this page.</p>
  689. + </div>
  690. +</div>
  691. +<div class="row">
  692. + <div class="col-md-12">
  693. + <h2>White- / Blacklist</h2>
  694. + <p>Add or remove domains (or subdomains) from the white-/blacklist. If a domain is added to e.g. the whitelist, any possible entry of the same domain will be automatically removed from the blacklist and vice versa.</p>
  695. + <p>Wildcard blacklisting is supported (entering <tt>something.de</tt> will block this domain including all subdomains like <tt>a.bb.c.999.something.de</tt>). Note that wildcard whitelisting is <em>not</em> supported.</p>
  696. + <p>You can white-/blacklist multiple entries at a time if you separate the domains by spaces.</p>
  697. + </div>
  698. +</div>
  699. +<div class="row">
  700. + <div class="col-md-12">
  701. + <h2>Disable / Enable</h2>
  702. + Disables/enables Pi-Hole blocking completely. You may have to wait a few minutes for the changes to reach all of your devices. The change will be reflected by a changed status (top left)
  703. + </div>
  704. +</div>
  705. +<div class="row">
  706. + <div class="col-md-12">
  707. + <h2>Tools &rarr; Update Lists</h2>
  708. + <p>Will download any updates from the third-party ad-serving domain lists that we source. By default, this command runs once a week via cron (Sunday at 01:59).</p>
  709. + </div>
  710. +</div>
  711. +<div class="row">
  712. + <div class="col-md-12">
  713. + <h2>Tools &rarr; Query adlists</h2>
  714. + This function is useful to find out what list a domain appears on. Since we don't control what the third-parties put on the block lists, you may find that a domain you normally visit stops working. If this is the case, you could run this command to scan for strings in the list of blocked domains and it will return the list the domain is found on. This proved useful a while back when the Mahakala list was adding <tt>apple.com</tt> and <tt>microsoft.com</tt> to their block list.</p>
  715. + </div>
  716. +</div>
  717. +<div class="row">
  718. + <div class="col-md-12">
  719. + <h2>Tools &rarr; Tail pihole.log</h2>
  720. + Live tailing of the raw Pi-hole log.</p>
  721. + </div>
  722. +</div>
  723. +<div class="row">
  724. + <div class="col-md-12">
  725. + <h2>Settings</h2>
  726. + Change settings for the Pi-Hole
  727. + <h4>Networking</h4>
  728. + Displays information about the interfaces of the Pi-Hole. No changes possible.
  729. + <h4>Pi-Hole DHCP Server</h4>
  730. + Using this setting you can enable/disable the DHCP server of the Pi-Hole. Note that you should disable any other DHCP server on your network to avoid IP addresses being used more than once. You have to give the range of IPs that DHCP will serve and the IP of the local router (gateway). If the DHCP server is active, the current leases are shown on the settings page. IPv4 DHCP will always be activated, IPv6 (stateless + statefull) can be enabled.
  731. + <h4>Upstream DNS Servers</h4>
  732. + Customize used upstream DNS servers + advanced settings for DNS servers. Note that any number of DNS servers may be enabled at a time.
  733. + <h4>Query Logging</h4>
  734. + Enabled/disable query logging on your Pi-hole + provide option to flush the log
  735. + <h4>API</h4>
  736. + Change settings which apply to the API as well as the web UI<br>
  737. + Note that Top Clients have to be given as IP addresses
  738. + <h4>Web User Interface</h4>
  739. + Other settings which affect the webUI but not the API of Pi-hole
  740. + <h4>System Administration</h4>
  741. + Apply system-wide actions like restarting of the server
  742. + </div>
  743. +</div>
  744. +<div class="row">
  745. + <div class="col-md-12">
  746. + <h2>Authentication system (currently <?php if($authenticationsystem) { ?>enabled<?php } else { ?>disabled<?php } ?>)</h2>
  747. + <p>Using the command<pre>sudo pihole -a -p pa22w0rd</pre> where <em>pa22w0rd</em> is the password to be set in this example, one can enable the authentication system of this web interface. Thereafter, a login is required for most pages (the dashboard will show a limited amount of statistics). Note that the authentication system may be disabled again, by setting an empty password using the command shown above. The Help center will show more details concerning the authentication system only if it is enabled</p>
  748. + </div>
  749. +</div>
  750. +<?php if($authenticationsystem) { ?>
  751. +<div class="row">
  752. + <div class="col-md-12">
  753. + <h2>Login / Logout</h2>
  754. + <p>Using the Login / Logout function, a user can initiate / terminate a login session. The login page will also always be shown if a user tries to access a protected page directly without having a valid login session</p>
  755. + </div>
  756. +</div>
  757. +<?php } ?>
  758. +<div class="row">
  759. + <div class="col-md-12">
  760. + <h2>Donate</h2>
  761. + Keep in mind that Pi-hole is free. If you like Pi-hole, please consider a small donation to help support its development
  762. + </div>
  763. +</div>
  764. +<div class="row">
  765. + <div class="col-md-12">
  766. + <h2>Help (this page)</h2>
  767. + Shows information about what is happening behind the scenes and what can be done with this web user interface (web UI). The Help center will show details concerning the authentication system only if it is enabled
  768. + </div>
  769. +</div>
  770. +<div class="row">
  771. + <div class="col-md-12">
  772. + <h2>Footer</h2>
  773. + Shows the currently installed Pi-hole and Web Interface version. If an update is available, this will be indicated here
  774. + </div>
  775. +</div>
  776. +
  777. +<?php
  778. + require "scripts/pi-hole/php/footer.php";
  779. +?>
  780. diff --git a/img/boxed-bg.jpg b/img/boxed-bg.jpg
  781. new file mode 100644
  782. index 0000000..e47586a
  783. Binary files /dev/null and b/img/boxed-bg.jpg differ
  784. diff --git a/img/donate.gif b/img/donate.gif
  785. new file mode 100644
  786. index 0000000..4700ced
  787. Binary files /dev/null and b/img/donate.gif differ
  788. diff --git a/img/favicon.png b/img/favicon.png
  789. new file mode 100644
  790. index 0000000..35dd8c9
  791. Binary files /dev/null and b/img/favicon.png differ
  792. diff --git a/img/logo.svg b/img/logo.svg
  793. new file mode 100644
  794. index 0000000..eeeec32
  795. --- /dev/null
  796. +++ b/img/logo.svg
  797. @@ -0,0 +1 @@
  798. +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 88.32 129.93"><defs><style>.cls-1{fill:url(#New_Gradient_Swatch_1);}.cls-2{fill:#980200;}.cls-3{fill:red;}</style><linearGradient id="New_Gradient_Swatch_1" x1="2.71" y1="20.04" x2="69.77" y2="20.04" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#12b212"/><stop offset="1" stop-color="lime"/></linearGradient></defs><title>NewVortex</title><g id="Layer_2" data-name="Layer 2"><g id="RedBerry"><path id="Leaf_Path" data-name="Leaf Path" class="cls-1" d="M36.56,39.93m0,0C20.34,38.2,4,25.94,2.71,0,27.88,0,41.34,14.9,42.64,38.51c4.76-28.32,27.07-25,27.07-25,1.06,16.05-12.12,25.78-27.07,26.59C38.44,31.25,13.28,9.54,13.28,9.54a.07.07,0,0,0-.11.08S37.45,30.77,36.56,39.93"/><path id="LeftBerry" class="cls-2" d="M44.16,129.93c-1.57-.09-16.22-.65-17.11-17.11-.72-10,7.18-17.37,7.18-27.08C32.44,61.53,0,64.53,0,85.74H0A19.94,19.94,0,0,0,5.83,99.88L30,124.06a19.94,19.94,0,0,0,14.14,5.83"/><path id="BottomBerry" class="cls-3" d="M88.32,85.75c-.09,1.57-.65,16.22-17.11,17.11-10,.72-17.38-7.18-27.08-7.18-24.21,1.79-21.21,34.22,0,34.22h0a19.94,19.94,0,0,0,14.14-5.83L82.46,99.9a19.94,19.94,0,0,0,5.83-14.14"/><path id="RightBerry" class="cls-2" d="M44.16,41.59c1.57.09,16.22.65,17.11,17.11.72,10-7.18,17.37-7.18,27.08,1.79,24.21,34.22,21.21,34.22,0h0a19.94,19.94,0,0,0-5.83-14.14L58.3,47.45a19.94,19.94,0,0,0-14.14-5.83"/><path id="TopBerry" class="cls-3" d="M.08,85.75c.09-1.57.65-16.22,17.11-17.11,10-.72,17.38,7.18,27.08,7.18C68.48,74,65.48,41.6,44.27,41.6h0a19.94,19.94,0,0,0-14.14,5.83L5.94,71.61A19.94,19.94,0,0,0,.11,85.75"/></g></g></svg>
  799. \ No newline at end of file
  800. diff --git a/index.php b/index.php
  801. new file mode 100644
  802. index 0000000..659a868
  803. --- /dev/null
  804. +++ b/index.php
  805. @@ -0,0 +1,225 @@
  806. +<!-- Pi-hole: A black hole for Internet advertisements
  807. +* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
  808. +* Network-wide ad blocking via your own hardware.
  809. +*
  810. +* This file is copyright under the latest version of the EUPL.
  811. +* Please see LICENSE file for your rights under this license. -->
  812. +<?php
  813. + $indexpage = true;
  814. + require "scripts/pi-hole/php/header.php";
  815. +?>
  816. +<!-- Small boxes (Stat box) -->
  817. +<div class="row">
  818. + <div class="col-lg-3 col-xs-12">
  819. + <!-- small box -->
  820. + <div class="small-box bg-aqua">
  821. + <div class="inner">
  822. + <h3 class="statistic" id="ads_blocked_today">---</h3>
  823. + <p>DNS Queries Blocked Today</p>
  824. + </div>
  825. + <div class="icon">
  826. + <i class="ion ion-android-hand"></i>
  827. + </div>
  828. + </div>
  829. + </div>
  830. + <!-- ./col -->
  831. + <div class="col-lg-3 col-xs-12">
  832. + <!-- small box -->
  833. + <div class="small-box bg-green">
  834. + <div class="inner">
  835. + <h3 class="statistic" id="dns_queries_today">---</h3>
  836. + <p>DNS Queries Today</p>
  837. + </div>
  838. + <div class="icon">
  839. + <i class="ion ion-earth"></i>
  840. + </div>
  841. + </div>
  842. + </div>
  843. + <!-- ./col -->
  844. + <div class="col-lg-3 col-xs-12">
  845. + <!-- small box -->
  846. + <div class="small-box bg-yellow">
  847. + <div class="inner">
  848. + <h3 class="statistic" id="ads_percentage_today">---</h3>
  849. + <p>Of Today's Queries Were Blocked</p>
  850. + </div>
  851. + <div class="icon">
  852. + <i class="ion ion-pie-graph"></i>
  853. + </div>
  854. + </div>
  855. + </div>
  856. + <!-- ./col -->
  857. + <div class="col-lg-3 col-xs-12">
  858. + <!-- small box -->
  859. + <div class="small-box bg-red">
  860. + <div class="inner">
  861. + <h3 class="statistic" id="domains_being_blocked">---</h3>
  862. + <p>Domains Being Blocked</p>
  863. + </div>
  864. + <div class="icon">
  865. + <i class="ion ion-ios-list"></i>
  866. + </div>
  867. + </div>
  868. + </div>
  869. + <!-- ./col -->
  870. +</div>
  871. +
  872. +<div class="row">
  873. + <div class="col-md-12">
  874. + <div class="box" id="queries-over-time">
  875. + <div class="box-header with-border">
  876. + <h3 class="box-title">Queries over time</h3>
  877. + </div>
  878. + <div class="box-body">
  879. + <div class="chart">
  880. + <canvas id="queryOverTimeChart" width="800" height="250"></canvas>
  881. + </div>
  882. + </div>
  883. + <div class="overlay">
  884. + <i class="fa fa-refresh fa-spin"></i>
  885. + </div>
  886. + <!-- /.box-body -->
  887. + </div>
  888. + </div>
  889. +</div>
  890. +<?php
  891. + // If the user is logged in, then we show the more detailed index page.
  892. + // Even if we would include them here anyhow, there would be nothing to
  893. + // show since the API will respect the privacy of the user if he defines
  894. + // a password
  895. + if($auth){ ?>
  896. +<div class="row">
  897. + <div class="col-md-6">
  898. + <div class="box" id="query-types">
  899. + <div class="box-header with-border">
  900. + <h3 class="box-title">Query Types</h3>
  901. + </div>
  902. + <div class="box-body">
  903. + <div class="chart">
  904. + <canvas id="queryTypeChart" width="400" height="200"></canvas>
  905. + </div>
  906. + </div>
  907. + <div class="overlay">
  908. + <i class="fa fa-refresh fa-spin"></i>
  909. + </div>
  910. + <!-- /.box-body -->
  911. + </div>
  912. + </div>
  913. + <div class="col-md-6">
  914. + <div class="box" id="forward-destinations">
  915. + <div class="box-header with-border">
  916. + <h3 class="box-title">Forward Destinations</h3>
  917. + </div>
  918. + <div class="box-body">
  919. + <div class="chart">
  920. + <canvas id="forwardDestinationChart" width="400" height="200"></canvas>
  921. + </div>
  922. + </div>
  923. + <div class="overlay">
  924. + <i class="fa fa-refresh fa-spin"></i>
  925. + </div>
  926. + <!-- /.box-body -->
  927. + </div>
  928. + </div>
  929. +</div>
  930. +
  931. +<?php
  932. +if($boxedlayout)
  933. +{
  934. + $tablelayout = "col-md-6";
  935. +}
  936. +else
  937. +{
  938. + $tablelayout = "col-md-6 col-lg-4";
  939. +}
  940. +?>
  941. +<div class="row">
  942. + <div class="<?php echo $tablelayout; ?>">
  943. + <div class="box" id="domain-frequency">
  944. + <div class="box-header with-border">
  945. + <h3 class="box-title">Top Domains</h3>
  946. + </div>
  947. + <!-- /.box-header -->
  948. + <div class="box-body">
  949. + <div class="table-responsive">
  950. + <table class="table table-bordered">
  951. + <tbody>
  952. + <tr>
  953. + <th>Domain</th>
  954. + <th>Hits</th>
  955. + <th>Frequency</th>
  956. + </tr>
  957. + </tbody>
  958. + </table>
  959. + </div>
  960. + </div>
  961. + <div class="overlay">
  962. + <i class="fa fa-refresh fa-spin"></i>
  963. + </div>
  964. + <!-- /.box-body -->
  965. + </div>
  966. + <!-- /.box -->
  967. + </div>
  968. + <!-- /.col -->
  969. + <div class="<?php echo $tablelayout; ?>">
  970. + <div class="box" id="ad-frequency">
  971. + <div class="box-header with-border">
  972. + <h3 class="box-title">Top Advertisers</h3>
  973. + </div>
  974. + <!-- /.box-header -->
  975. + <div class="box-body">
  976. + <div class="table-responsive">
  977. + <table class="table table-bordered">
  978. + <tbody>
  979. + <tr>
  980. + <th>Domain</th>
  981. + <th>Hits</th>
  982. + <th>Frequency</th>
  983. + </tr>
  984. + </tbody>
  985. + </table>
  986. + </div>
  987. + </div>
  988. + <div class="overlay">
  989. + <i class="fa fa-refresh fa-spin"></i>
  990. + </div>
  991. + <!-- /.box-body -->
  992. + </div>
  993. + <!-- /.box -->
  994. + </div>
  995. + <!-- /.col -->
  996. + <div class="<?php echo $tablelayout; ?>">
  997. + <div class="box" id="client-frequency">
  998. + <div class="box-header with-border">
  999. + <h3 class="box-title">Top Clients</h3>
  1000. + </div>
  1001. + <!-- /.box-header -->
  1002. + <div class="box-body">
  1003. + <div class="table-responsive">
  1004. + <table class="table table-bordered">
  1005. + <tbody>
  1006. + <tr>
  1007. + <th>Client</th>
  1008. + <th>Requests</th>
  1009. + <th>Frequency</th>
  1010. + </tr>
  1011. + </tbody>
  1012. + </table>
  1013. + </div>
  1014. + </div>
  1015. + <div class="overlay">
  1016. + <i class="fa fa-refresh fa-spin"></i>
  1017. + </div>
  1018. + <!-- /.box-body -->
  1019. + </div>
  1020. + <!-- /.box -->
  1021. + </div>
  1022. + <!-- /.col -->
  1023. +</div>
  1024. +<!-- /.row -->
  1025. +<?php } ?>
  1026. +<?php
  1027. + require "scripts/pi-hole/php/footer.php";
  1028. +?>
  1029. +
  1030. +<script src="scripts/pi-hole/js/index.js"></script>
  1031. diff --git a/list.php b/list.php
  1032. new file mode 100644
  1033. index 0000000..9edbdbc
  1034. --- /dev/null
  1035. +++ b/list.php
  1036. @@ -0,0 +1,79 @@
  1037. +<!-- Pi-hole: A black hole for Internet advertisements
  1038. +* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
  1039. +* Network-wide ad blocking via your own hardware.
  1040. +*
  1041. +* This file is copyright under the latest version of the EUPL.
  1042. +* Please see LICENSE file for your rights under this license. -->
  1043. +<?php
  1044. +require "scripts/pi-hole/php/header.php";
  1045. +
  1046. +$list = $_GET['l'];
  1047. +
  1048. +if($list !== "white" && $list !== "black"){
  1049. + echo "Invalid list parameter";
  1050. + require "footer.php";
  1051. + die();
  1052. +}
  1053. +
  1054. +function getFullName() {
  1055. + global $list;
  1056. + if($list == "white")
  1057. + echo "Whitelist";
  1058. + else
  1059. + echo "Blacklist";
  1060. +}
  1061. +?>
  1062. +<!-- Send list type to JS -->
  1063. +<div id="list-type" hidden><?php echo $list ?></div>
  1064. +
  1065. +<!-- Title -->
  1066. +<div class="page-header">
  1067. + <h1><?php getFullName(); ?></h1>
  1068. +</div>
  1069. +
  1070. +<!-- Domain Input -->
  1071. +<div class="form-group input-group">
  1072. + <input id="domain" type="text" class="form-control" placeholder="Add a domain (example.com or sub.example.com)">
  1073. + <span class="input-group-btn">
  1074. + <?php if($list === "black") { ?>
  1075. + <button id="btnAdd" class="btn btn-default" type="button">Add (exact)</button>
  1076. + <button id="btnAddWildcard" class="btn btn-default" type="button">Add (wildcard)</button>
  1077. + <?php }else{ ?>
  1078. + <button id="btnAdd" class="btn btn-default" type="button">Add</button>
  1079. + <?php } ?>
  1080. + <button id="btnRefresh" class="btn btn-default" type="button"><i class="fa fa-refresh"></i></button>
  1081. + </span>
  1082. +</div>
  1083. +<?php if($list === "white") { ?>
  1084. + <p>Note: Whitelisting a subdomain of a wildcard blocked domain is not possible.</p>
  1085. +<?php } ?>
  1086. +
  1087. +<!-- Alerts -->
  1088. +<div id="alInfo" class="alert alert-info alert-dismissible fade in" role="alert" hidden="true">
  1089. + <button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  1090. + Adding to the <?php getFullName(); ?>...
  1091. +</div>
  1092. +<div id="alSuccess" class="alert alert-success alert-dismissible fade in" role="alert" hidden="true">
  1093. + <button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  1094. + Success! The list will refresh.
  1095. +</div>
  1096. +<div id="alFailure" class="alert alert-danger alert-dismissible fade in" role="alert" hidden="true">
  1097. + <button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  1098. + Failure! Something went wrong.<br/><span id="err"></span>
  1099. +</div>
  1100. +
  1101. +<!-- Domain List -->
  1102. +<?php if($list === "black") { ?>
  1103. +<h3>Exact blocking</h3>
  1104. +<?php } ?>
  1105. +<ul class="list-group" id="list"></ul>
  1106. +<?php if($list === "black") { ?>
  1107. +<h3>Wildcard blocking</h3>
  1108. +<ul class="list-group" id="list-wildcard"></ul>
  1109. +<?php } ?>
  1110. +
  1111. +<?php
  1112. +require "scripts/pi-hole/php/footer.php";
  1113. +?>
  1114. +
  1115. +<script src="scripts/pi-hole/js/list.js"></script>
  1116. diff --git a/queries.php b/queries.php
  1117. new file mode 100644
  1118. index 0000000..61e2430
  1119. --- /dev/null
  1120. +++ b/queries.php
  1121. @@ -0,0 +1,119 @@
  1122. +<!-- Pi-hole: A black hole for Internet advertisements
  1123. +* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
  1124. +* Network-wide ad blocking via your own hardware.
  1125. +*
  1126. +* This file is copyright under the latest version of the EUPL.
  1127. +* Please see LICENSE file for your rights under this license. -->
  1128. +<?php
  1129. + require "scripts/pi-hole/php/header.php";
  1130. +
  1131. +// Generate CSRF token
  1132. +if(empty($_SESSION['token'])) {
  1133. + $_SESSION['token'] = base64_encode(openssl_random_pseudo_bytes(32));
  1134. +}
  1135. +$token = $_SESSION['token'];
  1136. +
  1137. +$showing = "";
  1138. +
  1139. +if(isset($setupVars["API_QUERY_LOG_SHOW"]))
  1140. +{
  1141. + if($setupVars["API_QUERY_LOG_SHOW"] === "all")
  1142. + {
  1143. + $showing = "(showing all queries)";
  1144. + }
  1145. + elseif($setupVars["API_QUERY_LOG_SHOW"] === "permittedonly")
  1146. + {
  1147. + $showing = "(showing permitted queries only)";
  1148. + }
  1149. + elseif($setupVars["API_QUERY_LOG_SHOW"] === "blockedonly")
  1150. + {
  1151. + $showing = "(showing blocked queries only)";
  1152. + }
  1153. + elseif($setupVars["API_QUERY_LOG_SHOW"] === "nothing")
  1154. + {
  1155. + $showing = "(showing no queries at all)";
  1156. + }
  1157. +}
  1158. +
  1159. +if(isset($setupVars["API_PRIVACY_MODE"]))
  1160. +{
  1161. + if($setupVars["API_PRIVACY_MODE"])
  1162. + {
  1163. + // Overwrite string from above
  1164. + $showing = "(privacy mode enabled)";
  1165. + }
  1166. +}
  1167. +?>
  1168. +<!-- Send PHP info to JS -->
  1169. +<div id="token" hidden><?php echo $token ?></div>
  1170. +
  1171. +
  1172. +<!--
  1173. +<div class="row">
  1174. + <div class="col-md-12">
  1175. + <button class="btn btn-info margin-bottom pull-right">Refresh Data</button>
  1176. + </div>
  1177. +</div>
  1178. +-->
  1179. +
  1180. +<!-- Alerts -->
  1181. +<div id="alInfo" class="alert alert-info alert-dismissible fade in" role="alert" hidden="true">
  1182. + <button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  1183. + Adding <span id="alDomain"></span> to the <span id="alList"></span>...
  1184. +</div>
  1185. +<div id="alSuccess" class="alert alert-success alert-dismissible fade in" role="alert" hidden="true">
  1186. + <button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  1187. + Success!
  1188. +</div>
  1189. +<div id="alFailure" class="alert alert-danger alert-dismissible fade in" role="alert" hidden="true">
  1190. + <button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  1191. + Failure! Something went wrong.<span id="err"></span>
  1192. +</div>
  1193. +
  1194. +<div class="row">
  1195. + <div class="col-md-12">
  1196. + <div class="box" id="recent-queries">
  1197. + <div class="box-header with-border">
  1198. + <h3 class="box-title">Recent Queries <?php echo $showing; ?></h3>
  1199. + </div>
  1200. + <!-- /.box-header -->
  1201. + <div class="box-body">
  1202. + <div class="table-responsive">
  1203. + <table id="all-queries" class="display table table-striped table-bordered" cellspacing="0" width="100%">
  1204. + <thead>
  1205. + <tr>
  1206. + <th>Time</th>
  1207. + <th>Type</th>
  1208. + <th>Domain</th>
  1209. + <th>Client</th>
  1210. + <th>Status</th>
  1211. + <th>Action</th>
  1212. + </tr>
  1213. + </thead>
  1214. + <tfoot>
  1215. + <tr>
  1216. + <th>Time</th>
  1217. + <th>Type</th>
  1218. + <th>Domain</th>
  1219. + <th>Client</th>
  1220. + <th>Status</th>
  1221. + <th>Action</th>
  1222. + </tr>
  1223. + </tfoot>
  1224. + </table>
  1225. + </div>
  1226. + </div>
  1227. + <!-- /.box-body -->
  1228. + </div>
  1229. + <!-- /.box -->
  1230. + </div>
  1231. +</div>
  1232. +<!-- /.row -->
  1233. +
  1234. +<?php
  1235. + require "scripts/pi-hole/php/footer.php";
  1236. +?>
  1237. +
  1238. +<script src="scripts/pi-hole/js/queries.js"></script>
  1239. +<script src="scripts/vendor/moment.min.js"></script>
  1240. +<script src="scripts/vendor/datetime-moment.js"></script>
  1241. diff --git a/queryads.php b/queryads.php
  1242. new file mode 100644
  1243. index 0000000..272fe34
  1244. --- /dev/null
  1245. +++ b/queryads.php
  1246. @@ -0,0 +1,31 @@
  1247. +<!-- Pi-hole: A black hole for Internet advertisements
  1248. +* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
  1249. +* Network-wide ad blocking via your own hardware.
  1250. +*
  1251. +* This file is copyright under the latest version of the EUPL.
  1252. +* Please see LICENSE file for your rights under this license. -->
  1253. +<?php
  1254. + require "scripts/pi-hole/php/header.php";
  1255. +?>
  1256. +<!-- Title -->
  1257. +<div class="page-header">
  1258. + <h1>Find Ad Domain In Lists</h1>
  1259. +</div>
  1260. +<!-- Domain Input -->
  1261. +<div class="form-group input-group">
  1262. + <input id="domain" type="text" class="form-control" placeholder="Domain to look for (example.com or sub.example.com)">
  1263. + <input id="quiet" type="hidden" value="no">
  1264. + <span class="input-group-btn">
  1265. + <button id="btnSearch" class="btn btn-default" type="button">Search partial match</button>
  1266. + <button id="btnSearchExact" class="btn btn-default" type="button">Search exact match</button>
  1267. + </span>
  1268. +</div>
  1269. +
  1270. +<pre id="output" style="width: 100%; height: 100%;" hidden="true"></pre>
  1271. +
  1272. +<?php
  1273. + require "scripts/pi-hole/php/footer.php";
  1274. +?>
  1275. +
  1276. +
  1277. +<script src="scripts/pi-hole/js/queryads.js"></script>
  1278. diff --git a/scripts/pi-hole/js/debug.js b/scripts/pi-hole/js/debug.js
  1279. new file mode 100644
  1280. index 0000000..c0db2ce
  1281. --- /dev/null
  1282. +++ b/scripts/pi-hole/js/debug.js
  1283. @@ -0,0 +1,65 @@
  1284. +// Credit: http://stackoverflow.com/a/10642418/2087442
  1285. +function httpGet(ta,theUrl)
  1286. +{
  1287. + var xmlhttp;
  1288. + if (window.XMLHttpRequest)
  1289. + {
  1290. + // code for IE7+
  1291. + xmlhttp = new XMLHttpRequest();
  1292. + }
  1293. + else
  1294. + {
  1295. + // code for IE6, IE5
  1296. + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  1297. + }
  1298. + xmlhttp.onreadystatechange=function()
  1299. + {
  1300. + if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
  1301. + {
  1302. + ta.show();
  1303. + ta.empty();
  1304. + ta.append(xmlhttp.responseText);
  1305. + }
  1306. + };
  1307. + xmlhttp.open("GET", theUrl, false);
  1308. + xmlhttp.send();
  1309. +}
  1310. +
  1311. +function eventsource() {
  1312. + var ta = $("#output");
  1313. + var upload = $( "#upload" );
  1314. + var checked = "";
  1315. +
  1316. + if(upload.prop("checked"))
  1317. + {
  1318. + checked = "upload";
  1319. + }
  1320. +
  1321. + // IE does not support EventSource - load whole content at once
  1322. + if (typeof EventSource !== "function") {
  1323. + httpGet(ta,"/admin/scripts/pi-hole/php/debug.php?IE&"+checked);
  1324. + return;
  1325. + }
  1326. +
  1327. + var host = window.location.host;
  1328. + var source = new EventSource("/admin/scripts/pi-hole/php/debug.php?"+checked);
  1329. +
  1330. + // Reset and show field
  1331. + ta.empty();
  1332. + ta.show();
  1333. +
  1334. + source.addEventListener("message", function(e) {
  1335. + ta.append(e.data);
  1336. + }, false);
  1337. +
  1338. + // Will be called when script has finished
  1339. + source.addEventListener("error", function(e) {
  1340. + source.close();
  1341. + }, false);
  1342. +}
  1343. +
  1344. +$("#debugBtn").on("click", function(){
  1345. + $("#debugBtn").attr("disabled", true);
  1346. + $("#upload").attr("disabled", true);
  1347. + eventsource();
  1348. +});
  1349. diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js
  1350. new file mode 100644
  1351. index 0000000..20866b8
  1352. --- /dev/null
  1353. +++ b/scripts/pi-hole/js/footer.js
  1354. @@ -0,0 +1,286 @@
  1355. +/* Pi-hole: A black hole for Internet advertisements
  1356. +* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
  1357. +* Network-wide ad blocking via your own hardware.
  1358. +*
  1359. +* This file is copyright under the latest version of the EUPL.
  1360. +* Please see LICENSE file for your rights under this license. */
  1361. +// User menu toggle
  1362. +$("#dropdown-menu a").on("click", function(event) {
  1363. + $(this).parent().toggleClass("open");
  1364. +});
  1365. +$("body").on("click", function(event) {
  1366. + if(!$("#dropdown-menu").is(event.target) && $("#dropdown-menu").has(event.t+$("#debugBtn").on("click", function(){
  1367. + $("#debugBtn").attr("disabled", true);
  1368. + $("#upload").attr("disabled", true);
  1369. + eventsource();
  1370. +});
  1371. diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js
  1372. new file mode 100644
  1373. index 0000000..20866b8
  1374. --- /dev/null
  1375. +++ b/scripts/pi-hole/js/footer.js
  1376. @@ -0,0 +1,286 @@
  1377. +/* Pi-hole: A black hole for Internet advertisements
  1378. +* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
  1379. +* Network-wide ad blocking via your own hardware.
  1380. +*
  1381. +* This file is copyright under the latest version of the EUPL.
  1382. +* Please see LICENSE file for your rights under this license. */
  1383. +// User menu toggle
  1384. +$("#dropdown-menu a").on("click", function(event) {
  1385. + $(this).parent().toggleClass("open");
  1386. +});
  1387. +$("body").on("click", function(event) {
  1388. + if(!$("#dropdown-menu").is(event.target) && $("#dropdown-menu").has(event.t
  1389. arget).length === 0) {
  1390. + $("#dropdown-menu").removeClass("open");
  1391. + }
  1392. +});
  1393. +
  1394. +//The following functions allow us to display time until pi-hole is enabled after disabling.
  1395. +//Works between all pages
  1396. +
  1397. +function secondsTimeSpanToHMS(s) {
  1398. + var h = Math.floor(s/3600); //Get whole hours
  1399. + s -= h*3600;
  1400. + var m = Math.floor(s/60); //Get remaining minutes
  1401. + s -= m*60;
  1402. + return h+":"+(m < 10 ? "0"+m : m)+":"+(s < 10 ? "0"+s : s); //zero padding on minutes and seconds
  1403. +}
  1404. +
  1405. +function countDown(){
  1406. + var ena = $("#enableLabel");
  1407. + var enaT = $("#enableTimer");
  1408. + var target = new Date(parseInt(enaT.html()));
  1409. + var seconds = Math.round((target.getTime() - new Date().getTime()) / 1000)
  1410. (END)
Add Comment
Please, Sign In to add comment