Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 2886957

Browse files
melangervyskocilpavel
authored andcommitted
Use 'filter_input' to GET and VALIDATE value send as GET/POST param
1 parent a6f582b commit 2886957

File tree

8 files changed

+52
-32
lines changed

8 files changed

+52
-32
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
88
- Removed unused include from 'templates/spDetail-tpl.php'
99
- Deleted useless code
1010
- Deleted 'head' and 'body' tag in tab templates
11+
- Use 'filter_input' to GET and VALIDATE value send as GET/POST param
1112

1213
#### Fixed
1314
- Fixed the syntax of CHANGELOG

templates/statistics-tpl.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,28 @@
3434

3535
$this->includeAtTemplateBase('includes/header.php');
3636

37-
if (!isset($_POST['lastDays'])) {
38-
$_POST['lastDays'] = 0;
37+
if (!isset($this->data['lastDays'])) {
38+
$this->data['lastDays'] = 0;
3939
}
4040

41-
if (!isset($_POST['tab'])) {
42-
$_POST['tab'] = 1;
41+
if (!isset($this->data['tab'])) {
42+
$this->data['tab'] = 1;
4343
}
4444

4545
?>
4646

4747
<div id="tabdiv">
4848
<ul class="tabset_tabs" width="100px">
4949
<li><a id="tab-1"
50-
href='<?php echo "summary.php?lastDays=" . $_POST['lastDays']; ?>'>
50+
href='<?php echo "summary.php?lastDays=" . $this->data['lastDays']; ?>'>
5151
<?php echo $this->t('{proxystatistics:Proxystatistics:summary}'); ?></a>
5252
</li>
5353
<li><a id="tab-2"
54-
href='<?php echo "identityProviders.php?lastDays=" . $_POST['lastDays']; ?>'>
54+
href='<?php echo "identityProviders.php?lastDays=" . $this->data['lastDays']; ?>'>
5555
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_idpsDetail}'); ?></a>
5656
</li>
5757
<li><a id="tab-3"
58-
href='<?php echo "serviceProviders.php?lastDays=" . $_POST['lastDays']; ?>'>
58+
href='<?php echo "serviceProviders.php?lastDays=" . $this->data['lastDays']; ?>'>
5959
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_spsDetail}'); ?></a>
6060
</li>
6161
</ul>

www/identityProviders.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@
1212
$session = Session::getSessionFromRequest();
1313

1414
$t = new Template($config, 'proxystatistics:identityProviders-tpl.php');
15-
$t->data['lastDays'] = $_GET['lastDays'];
15+
$t->data['lastDays'] = filter_input(
16+
INPUT_GET,
17+
'lastDays',
18+
FILTER_VALIDATE_INT,
19+
['options'=>['default'=>0,'min_range'=>0]]
20+
);
1621
$t->show();

www/idpDetail.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313

1414
$t = new Template($config, 'proxystatistics:idpDetail-tpl.php');
1515

16-
if (!isset($_POST['lastDays'])) {
17-
$_POST['lastDays'] = 0;
18-
}
19-
$t->data['lastDays'] = $_POST['lastDays'];
20-
$t->data['entityId'] = $_GET['entityId'];
16+
$t->data['lastDays'] = filter_input(
17+
INPUT_POST,
18+
'lastDays',
19+
FILTER_VALIDATE_INT,
20+
['options'=>['default'=>0,'min_range'=>0]]
21+
);
22+
$t->data['entityId'] = filter_input(INPUT_GET, 'entityId', FILTER_SANITIZE_STRING);
2123
$t->show();

www/index.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
$session = Session::getSessionFromRequest();
1313

1414
$t = new Template($config, 'proxystatistics:statistics-tpl.php');
15-
16-
if (!isset($_POST['lastDays'])) {
17-
$_POST['lastDays'] = 0;
18-
}
19-
20-
if (!isset($_POST['tab'])) {
21-
$_POST['tab'] = 1;
22-
}
23-
24-
$t->data['lastDays'] = $_POST['lastDays'];
25-
$t->data['tab'] = $_POST['tab'];
15+
$t->data['lastDays'] = filter_input(
16+
INPUT_POST,
17+
'lastDays',
18+
FILTER_VALIDATE_INT,
19+
['options'=>['default'=>0,'min_range'=>0]]
20+
);
21+
$t->data['tab'] = filter_input(
22+
INPUT_POST,
23+
'tab',
24+
FILTER_VALIDATE_INT,
25+
['options'=>['default'=>0,'min_range'=>1]]
26+
);
2627
$t->show();

www/serviceProviders.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@
1212
$session = Session::getSessionFromRequest();
1313

1414
$t = new Template($config, 'proxystatistics:serviceProviders-tpl.php');
15-
$t->data['lastDays'] = $_GET['lastDays'];
15+
$t->data['lastDays'] = filter_input(
16+
INPUT_GET,
17+
'lastDays',
18+
FILTER_VALIDATE_INT,
19+
['options'=>['default'=>0,'min_range'=>0]]
20+
);
1621
$t->show();

www/spDetail.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
$t = new Template($config, 'proxystatistics:spDetail-tpl.php');
1515

16-
if (!isset($_POST['lastDays'])) {
17-
$_POST['lastDays'] = 0;
18-
}
19-
20-
$t->data['lastDays'] = $_POST['lastDays'];
21-
$t->data['identifier'] = $_GET['identifier'];
16+
$t->data['lastDays'] = filter_input(
17+
INPUT_POST,
18+
'lastDays',
19+
FILTER_VALIDATE_INT,
20+
['options'=>['default'=>0,'min_range'=>0]]
21+
);
22+
$t->data['identifier'] = filter_input(INPUT_GET, 'identifier', FILTER_SANITIZE_STRING);
2223
$t->show();

www/summary.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@
1212
$session = Session::getSessionFromRequest();
1313

1414
$t = new Template($config, 'proxystatistics:summary-tpl.php');
15-
$t->data['lastDays'] = $_GET['lastDays'];
15+
$t->data['lastDays'] = filter_input(
16+
INPUT_GET,
17+
'lastDays',
18+
FILTER_VALIDATE_INT,
19+
['options'=>['default'=>0,'min_range'=>0]]
20+
);
1621
$t->show();

0 commit comments

Comments
 (0)