From 2277dc3a36a5b9f831caa436323492fe820de569 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 1 Jun 2016 12:41:10 -0400 Subject: [PATCH] Update flight data class to check for the array first errors from invalid array passed to foreach --- class_flight.php | 24 ++++++++++++++---------- style.css | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/class_flight.php b/class_flight.php index db1ec66..a7d5dd5 100644 --- a/class_flight.php +++ b/class_flight.php @@ -91,17 +91,21 @@ include_once($_SERVER['DOCUMENT_ROOT'].'/wp-config.php' ); $this->get_arr_flight_data(); $this->get_dep_flight_data(); - foreach( $this->arr_data as $key=>$value ) - { - $update_times[] = strtotime($value['msg_dtm']); - if ($row['name'] == "EXPRESS AIRLINES 1, INC.") $this->arr_data[$key]['name'] = 'Delta Airlines'; - if ($row['airline'] == "EXPRESS AIRLINES 1, INC.") $this->arr_data[$key]['airline'] = 'Delta Airlines'; + if ( isset( $this->arr_data ) && is_array( $this->arr_data ) ) { + foreach( $this->arr_data as $key=>$value ) + { + $update_times[] = strtotime($value['msg_dtm']); + if ($row['name'] == "EXPRESS AIRLINES 1, INC.") $this->arr_data[$key]['name'] = 'Delta Airlines'; + if ($row['airline'] == "EXPRESS AIRLINES 1, INC.") $this->arr_data[$key]['airline'] = 'Delta Airlines'; + } } - foreach( $this->dep_data as $key=>$value) - { - $update_times[] = strtotime($value['msg_dtm']); - if ($row['name'] == "EXPRESS AIRLINES 1, INC.") $this->dep_data[$key]['name'] = 'Delta Airlines'; - if ($row['airline'] == "EXPRESS AIRLINES 1, INC.") $this->dep_data[$key]['airline'] = 'Delta Airlines'; + if ( isset( $this->dep_data ) && is_array( $this->dep_data ) ) { + foreach( $this->dep_data as $key=>$value) + { + $update_times[] = strtotime($value['msg_dtm']); + if ($row['name'] == "EXPRESS AIRLINES 1, INC.") $this->dep_data[$key]['name'] = 'Delta Airlines'; + if ($row['airline'] == "EXPRESS AIRLINES 1, INC.") $this->dep_data[$key]['airline'] = 'Delta Airlines'; + } } rsort($update_times); // get UTC offset for current date/time diff --git a/style.css b/style.css index 7c47f4f..4a9b910 100644 --- a/style.css +++ b/style.css @@ -3,5 +3,5 @@ Theme Name: PellstonAirport Author: Gaslight Media Author URI: http://www.gaslightmedia.com Description: A theme for PellstonAirport -Version: 1.0.2 +Version: 1.0.3 */ -- 2.17.1