summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2017-05-09 11:50:37 +0200
committerSimon Rettberg2017-05-09 11:50:37 +0200
commit259f4d9c62bc0ccd8c70bca1c7ab6d9bd95d9dd6 (patch)
treed44b84cd407e97104340b5dd602ba9063317b1c8
parentUpdate translations (diff)
downloadslx-admin-259f4d9c62bc0ccd8c70bca1c7ab6d9bd95d9dd6.tar.gz
slx-admin-259f4d9c62bc0ccd8c70bca1c7ab6d9bd95d9dd6.tar.xz
slx-admin-259f4d9c62bc0ccd8c70bca1c7ab6d9bd95d9dd6.zip
[locationinfo] Fix array oob access
-rw-r--r--modules-available/locationinfo/api.inc.php30
1 files changed, 16 insertions, 14 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php
index 9b698d65..c93783ec 100644
--- a/modules-available/locationinfo/api.inc.php
+++ b/modules-available/locationinfo/api.inc.php
@@ -189,26 +189,28 @@ function formatOpeningtime($openingtime)
{
$result = array();
$weekarray = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
- foreach ($weekarray as $d) {
+ foreach ($weekarray as $checkDay) {
$array = array();
foreach ($openingtime as $opt) {
- foreach ($opt['days'] as $val) {
- if ($val == $d) {
- $arr = array();
-
- $openTime = explode(':', $opt['openingtime']);
- $arr['HourOpen'] = $openTime[0];
- $arr['MinutesOpen'] = $openTime[1];
-
- $closeTime = explode(':', $opt['closingtime']);
- $arr['HourClose'] = $closeTime[0];
- $arr['MinutesClose'] = $closeTime[1];
-
+ if (!isset($opt['days']) || !is_array($opt['days']))
+ continue;
+ $openTime = explode(':', $opt['openingtime']);
+ $closeTime = explode(':', $opt['closingtime']);
+ if (count($openTime) !== 2 || count($closeTime) !== 2)
+ continue;
+ $arr = array(
+ 'HourOpen' => $openTime[0],
+ 'MinutesOpen' => $openTime[1],
+ 'HourClose' => $closeTime[0],
+ 'MinutesClose' => $closeTime[1],
+ );
+ foreach ($opt['days'] as $calDay) {
+ if ($calDay === $checkDay) {
$array[] = $arr;
}
}
if (!empty($array)) {
- $result[$d] = $array;
+ $result[$checkDay] = $array;
}
}
}