mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
f204b71707
* Remove double click handler * ~Today~ Over Last 24 Hours * Rename Top Advertisers to Top Blocked Domains * percentage should be a float instead of an integer * Define $over_time as array. Fixes #501 * Add hover/hit radius for Forward Destinations over Time graph * Add custom callback for tooltips and disable legend for Forward Destinations over Time graph * Remove legend, add tooltips and increase hit/hover radius for Query Types over Time graph. Fixes #502 * Don't hide detailed graphs on small screens any longer * 🌮 is the new :shipit: squirrel * revise wording on main page shorter text to fit in one line on smaller screens * Show warning in browser when fopen() failed * open links in new tab * open links in new tab * Update header.php * select 'Login' in Navbar when showing loginpage using the same term as it is already used to show up the loginpage (in line 565) * set the mainbox wider on smaller screens solves issue of overlapping text with loginbutton when using smaller screens * also fix overlapping loginpage on footerbar * remove border on logo * add link feedback (on hover) * sessiontimer in bold letters * use AdminLTE function to toggle dropdown-menu AdminLTE has already an implemented function to toggle the user menu. So there is no need to use an own script in footer.js Benefit: The dropdown-menu closes if you click on a blank Place * align donate-url with url in footerbar * remove function to open user menu AdminLTE has already an implemented function to toggle the user menu. So there is no need to use an own script in footer.js Benefit: The dropdown-menu closes if you click on a blank Place * Update LICENSE of the project to EUPL v1.2 * Major overhaul of update checker - checks only every 30 minutes to reduce number of GitHub API requests * Add version info to dropdown menu (top right) for viewing on small screens. Addresses #333 partially * Fix typo * footer.php: improve and clean up move animation-stylesheet to pi-hole.css (Have you noticed that there is even a text- and text-shadow animation set, but for webkit-browsers only) added <!-- Version Infos --> correct continuous hide of version info (AdminLTEs classed widths as `xs` > `sm` > `md` > `lg`) display Donate-text alwas in one line (do not wrap in between when version info string gets very long) * pi-hole.css: pasted animation stylesheet and improved the text-shadow-animation to work correctly with and without -webkit-prefix (for me this wasn't working until now) * header.php: some corrections & improvements pull dropdown-menu always to right side changed <!-- Update alerts --> to <!-- Version Infos --> (just like it is in footer) hide version infos in dropdown-menu if it gets shown in footer repaired update-urls, they also should open up in new tab & gets underlined on hover `background:none` is needed because AdminLTE adds dark bg on hover to links when using it on smallscreen (xs) * Minor change to make the dashboard's javascript compatible with escaped characters (like apostrophe) in client names * Add the same for the top domains * ... and Top Ads * Minor change to comments * footer.php: edited as discussed * header.php: edited as discussed * Update queryads.js * Update list.js * queryads.js: codacy fixes * list.js: codacy fixes * list.js: small correction * queryads.js: small correction * Be able to interpret status 5 * Sort list entries (black-/whitelist) alphabetically before creating the table * queryads.js: Update* * removed double comment and updated code to center and separate the buttons on small screens, like in my last screenshot. * list.js: update* updated code to center and separate the buttons on small screens, like in my last screenshot.
290 lines
5.8 KiB
PHP
290 lines
5.8 KiB
PHP
<?php
|
|
/* Pi-hole: A black hole for Internet advertisements
|
|
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
|
* Network-wide ad blocking via your own hardware.
|
|
*
|
|
* This file is copyright under the latest version of the EUPL.
|
|
* Please see LICENSE file for your rights under this license */
|
|
|
|
|
|
if(!isset($api))
|
|
{
|
|
die("Direct call to api_FTL.php is not allowed!");
|
|
}
|
|
|
|
$socket = connectFTL("127.0.0.1");
|
|
|
|
if (isset($_GET['type'])) {
|
|
$data["type"] = "FTL";
|
|
}
|
|
|
|
if (isset($_GET['version'])) {
|
|
$data["version"] = 3;
|
|
}
|
|
|
|
if (isset($_GET['summary']) || isset($_GET['summaryRaw']) || !count($_GET))
|
|
{
|
|
sendRequestFTL("stats");
|
|
$return = getResponseFTL();
|
|
|
|
$stats = [];
|
|
foreach($return as $line)
|
|
{
|
|
$tmp = explode(" ",$line);
|
|
|
|
if(isset($_GET['summary']))
|
|
{
|
|
if($tmp[0] !== "ads_percentage_today")
|
|
{
|
|
$stats[$tmp[0]] = number_format($tmp[1]);
|
|
}
|
|
else
|
|
{
|
|
$stats[$tmp[0]] = number_format($tmp[1], 1, '.', '');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$stats[$tmp[0]] = floatval($tmp[1]);
|
|
}
|
|
}
|
|
$data = array_merge($data,$stats);
|
|
}
|
|
|
|
if (isset($_GET['overTimeData10mins']))
|
|
{
|
|
sendRequestFTL("overTime");
|
|
$return = getResponseFTL();
|
|
|
|
$domains_over_time = array();
|
|
$ads_over_time = array();
|
|
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]);
|
|
}
|
|
$result = array('domains_over_time' => $domains_over_time,
|
|
'ads_over_time' => $ads_over_time);
|
|
$data = array_merge($data, $result);
|
|
}
|
|
|
|
if (isset($_GET['topItems']) && $auth)
|
|
{
|
|
if(is_numeric($_GET['topItems']))
|
|
{
|
|
sendRequestFTL("top-domains (".$_GET['topItems'].")");
|
|
}
|
|
else
|
|
{
|
|
sendRequestFTL("top-domains");
|
|
}
|
|
|
|
$return = getResponseFTL();
|
|
$top_queries = array();
|
|
foreach($return as $line)
|
|
{
|
|
$tmp = explode(" ",$line);
|
|
$top_queries[$tmp[2]] = intval($tmp[1]);
|
|
}
|
|
|
|
if(is_numeric($_GET['topItems']))
|
|
{
|
|
sendRequestFTL("top-ads (".$_GET['topItems'].")");
|
|
}
|
|
else
|
|
{
|
|
sendRequestFTL("top-ads");
|
|
}
|
|
|
|
$return = getResponseFTL();
|
|
$top_ads = array();
|
|
foreach($return as $line)
|
|
{
|
|
$tmp = explode(" ",$line);
|
|
$top_ads[$tmp[2]] = intval($tmp[1]);
|
|
}
|
|
|
|
$result = array('top_queries' => $top_queries,
|
|
'top_ads' => $top_ads);
|
|
|
|
$data = array_merge($data, $result);
|
|
}
|
|
|
|
if ((isset($_GET['topClients']) || isset($_GET['getQuerySources'])) && $auth)
|
|
{
|
|
|
|
if(isset($_GET['topClients']))
|
|
{
|
|
$number = $_GET['topClients'];
|
|
}
|
|
elseif(isset($_GET['getQuerySources']))
|
|
{
|
|
$number = $_GET['getQuerySources'];
|
|
}
|
|
|
|
if(is_numeric($number))
|
|
{
|
|
sendRequestFTL("top-clients (".$number.")");
|
|
}
|
|
else
|
|
{
|
|
sendRequestFTL("top-clients");
|
|
}
|
|
|
|
$return = getResponseFTL();
|
|
$top_clients = array();
|
|
foreach($return as $line)
|
|
{
|
|
$tmp = explode(" ",$line);
|
|
if(count($tmp) == 4)
|
|
{
|
|
$top_clients[$tmp[3]."|".$tmp[2]] = intval($tmp[1]);
|
|
}
|
|
else
|
|
{
|
|
$top_clients[$tmp[2]] = intval($tmp[1]);
|
|
}
|
|
}
|
|
|
|
$result = array('top_sources' => $top_clients);
|
|
$data = array_merge($data, $result);
|
|
}
|
|
|
|
if (isset($_GET['getForwardDestinations']) && $auth)
|
|
{
|
|
sendRequestFTL("forward-dest");
|
|
$return = getResponseFTL();
|
|
$forward_dest = array();
|
|
foreach($return as $line)
|
|
{
|
|
$tmp = explode(" ",$line);
|
|
if(count($tmp) == 4)
|
|
{
|
|
$forward_dest[$tmp[3]."|".$tmp[2]] = intval($tmp[1]);
|
|
}
|
|
else
|
|
{
|
|
$forward_dest[$tmp[2]] = intval($tmp[1]);
|
|
}
|
|
}
|
|
|
|
$result = array('forward_destinations' => $forward_dest);
|
|
$data = array_merge($data, $result);
|
|
}
|
|
|
|
if (isset($_GET['getQueryTypes']) && $auth)
|
|
{
|
|
sendRequestFTL("querytypes");
|
|
$return = getResponseFTL();
|
|
$querytypes = array();
|
|
foreach($return as $ret)
|
|
{
|
|
$tmp = explode(": ",$ret);
|
|
$querytypes[$tmp[0]] = intval($tmp[1]);
|
|
}
|
|
|
|
$result = array('querytypes' => $querytypes);
|
|
$data = array_merge($data, $result);
|
|
}
|
|
|
|
if (isset($_GET['getAllQueries']) && $auth)
|
|
{
|
|
if(isset($_GET['from']) && isset($_GET['until']))
|
|
{
|
|
// Get limited time interval
|
|
sendRequestFTL("getallqueries-time ".$_GET['from']." ".$_GET['until']);
|
|
}
|
|
else if(isset($_GET['domain']))
|
|
{
|
|
// Get specific domain only
|
|
sendRequestFTL("getallqueries-domain ".$_GET['domain']);
|
|
}
|
|
else if(isset($_GET['client']))
|
|
{
|
|
// Get specific client only
|
|
sendRequestFTL("getallqueries-client ".$_GET['client']);
|
|
}
|
|
else
|
|
{
|
|
// Get all queries
|
|
sendRequestFTL("getallqueries");
|
|
}
|
|
$return = getResponseFTL();
|
|
$allQueries = array();
|
|
foreach($return as $line)
|
|
{
|
|
$tmp = explode(" ",$line);
|
|
array_push($allQueries,$tmp);
|
|
}
|
|
|
|
$result = array('data' => $allQueries);
|
|
$data = array_merge($data, $result);
|
|
}
|
|
|
|
if(isset($_GET["recentBlocked"]))
|
|
{
|
|
sendRequestFTL("recentBlocked");
|
|
die(getResponseFTL()[0]);
|
|
unset($data);
|
|
}
|
|
|
|
if (isset($_GET['overTimeDataForwards']) && $auth)
|
|
{
|
|
sendRequestFTL("ForwardedoverTime");
|
|
$return = getResponseFTL();
|
|
$over_time = array();
|
|
|
|
foreach($return as $line)
|
|
{
|
|
$tmp = explode(" ",$line);
|
|
for ($i=0; $i < count($tmp)-1; $i++) {
|
|
$over_time[intval($tmp[0])][$i] = intval($tmp[$i+1]);
|
|
}
|
|
}
|
|
$result = array('over_time' => $over_time);
|
|
$data = array_merge($data, $result);
|
|
}
|
|
|
|
if (isset($_GET['getForwardDestinationNames']) && $auth)
|
|
{
|
|
sendRequestFTL("forward-names");
|
|
$return = getResponseFTL();
|
|
$forward_dest = array();
|
|
foreach($return as $line)
|
|
{
|
|
$tmp = explode(" ",$line);
|
|
if(count($tmp) == 4)
|
|
{
|
|
$forward_dest[$tmp[3]."|".$tmp[2]] = intval($tmp[1]);
|
|
}
|
|
else
|
|
{
|
|
$forward_dest[$tmp[2]] = intval($tmp[1]);
|
|
}
|
|
}
|
|
|
|
$result = array('forward_destinations' => $forward_dest);
|
|
$data = array_merge($data, $result);
|
|
}
|
|
|
|
if (isset($_GET['overTimeDataQueryTypes']) && $auth)
|
|
{
|
|
sendRequestFTL("QueryTypesoverTime");
|
|
$return = getResponseFTL();
|
|
$over_time = array();
|
|
|
|
foreach($return as $line)
|
|
{
|
|
$tmp = explode(" ",$line);
|
|
for ($i=0; $i < count($tmp)-1; $i++) {
|
|
$over_time[intval($tmp[0])][$i] = intval($tmp[$i+1]);
|
|
}
|
|
}
|
|
$result = array('over_time' => $over_time);
|
|
$data = array_merge($data, $result);
|
|
}
|
|
|
|
disconnectFTL();
|
|
?>
|