Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix(secu): sanitize host dashboard (#9406)
Browse files Browse the repository at this point in the history
* fix(secu): sanitize host dashboard

* code-review: take feedbacks into account #1

* code-review: take feedbacks into account #2
  • Loading branch information
adr-mo authored Jan 19, 2021
1 parent 402687c commit 37c2d45
Showing 1 changed file with 46 additions and 18 deletions.
64 changes: 46 additions & 18 deletions www/include/reporting/dashboard/common-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,58 @@
*/
function getPeriodToReport()
{
$period = (isset($_POST["period"])) ? $_POST["period"] : "";
$period = (isset($_GET["period"])) ? $_GET["period"] : $period;
$period_choice = (isset($_POST["period_choice"])) ? $_POST["period_choice"] : "";
$end_date = 0;
$start_date = 0;
$start_date = (isset($_POST["StartDate"])) ? $_POST["StartDate"] : "";
$start_date = (isset($_GET["start"])) ? $_GET["start"] : $start_date;
$end_date = (isset($_POST["EndDate"])) ? $_POST["EndDate"] : "";
$end_date = (isset($_GET["end"])) ? $_GET["end"] : $end_date;
$period = '';
$startDate = '';
$endDate = '';
$periodChoice = '';

if (isset($_POST['period'])) {
$period = filter_var($_POST['period'], FILTER_SANITIZE_STRING);
} elseif (isset($_GET['period'])) {
$period = filter_var($_GET['period'], FILTER_SANITIZE_STRING);
}

if (isset($_POST['period_choice'])) {
$periodChoice = filter_var($_POST['period_choice'], FILTER_SANITIZE_STRING);
}

if (isset($_POST['StartDate'])) {
$startDate = filter_var($_POST['StartDate'], FILTER_SANITIZE_STRING);
} elseif (isset($_GET['StartDate'])) {
$startDate = filter_var($_GET['StartDate'], FILTER_SANITIZE_STRING);
}

if (isset($_POST['EndDate'])) {
$endDate = filter_var($_POST['EndDate'], FILTER_SANITIZE_STRING);
} elseif (isset($_GET['EndDate'])) {
$endDate = filter_var($_GET['EndDate'], FILTER_SANITIZE_STRING);
}

$interval = array(0, 0);
if ($period_choice == "custom" && $start_date != "" && $end_date != "") {
$period = "";

if ($periodChoice == 'custom' &&
$startDate != '' &&
$endDate != ''
) {
$period = '';
}
if ($period == "" && $start_date == "" && $end_date == "") {
$period = "yesterday";

if ($period == '' &&
$startDate == '' &&
$endDate == ''
) {
$period = 'yesterday';
}
if ($period == "" && $start_date != "") {
$interval = getDateSelectCustomized($start_date, $end_date);

if ($period == '' && $startDate != '') {
$interval = getDateSelectCustomized($startDate, $endDate);
} else {
$interval = getDateSelectPredefined($period);
}
$start_date = $interval[0];
$end_date = $interval[1];
return(array($start_date, $end_date));

list($startDate, $endDate) = $interval;

return(array($startDate, $endDate));
}

/*
Expand Down

0 comments on commit 37c2d45

Please sign in to comment.