示例#1
0
 }
 $image_extensions = array('jpg', 'png', 'gif');
 $rows = array();
 while ($row = $list->fetch_assoc()) {
     $latitude = (double) $row['latitude'];
     $longitude = (double) $row['longitude'];
     $slug = strtolower(str_replace(' ', '-', $row['name']));
     $image_extension = 'jpg';
     $image_url = 'images/no-image.png';
     foreach ($image_extensions as $image_extension) {
         if (file_exists('images/' . $slug . '.' . $image_extension)) {
             $image_url = 'images/' . $slug . '.' . $image_extension;
         }
     }
     $categories_json = DecodeJSONField($row['category']);
     if ($category_controller->Accept($categories_json)) {
         $address_divvy = Divvy(array_merge(DecodeJSON($row['address'], true), array($row['postcode'])), 2);
         $address_split = array_map(function ($el) {
             return implode(', ', $el);
         }, $address_divvy);
         $rows[(int) $row['id']] = array('id' => (int) $row['id'], 'name' => $row['name'], 'latitude' => $latitude, 'longitude' => $longitude, 'distance' => DistanceBetween(array($latitude, $longitude), array($centre_latitude, $centre_longitude)), 'category' => $categories_json, 'email' => $row['email'], 'telephone' => DecodeJSONField($row['telephone']), 'address' => DecodeJSONField($row['address']), 'postcode' => $row['postcode'], 'address1' => $address_split[0], 'address2' => $address_split[1], 'website' => $row['website'], 'entry_rates' => DecodeJSONField($row['entry_rates']), 'opening_times' => DecodeJSONField($row['opening_times'], "<br>"), 'rating' => number_format((double) $row['rating'], 1, '.', ''), 'more_info' => $row['more_info'] != '' ? $row['more_info'] : 'Sorry no info', 'disabled_facilities' => $row['disabled_facilities'] != '' ? $row['disabled_facilities'] : 'Sorry no info', 'facilities' => $row['facilities'] != '' ? $row['facilities'] : 'Sorry no info', 'good_stuff' => $row['good_stuff'] != '' ? $row['good_stuff'] : 'Sorry no info', 'bad_stuff' => $row['bad_stuff'] != '' ? $row['bad_stuff'] : '', 'image_url' => $image_url);
     }
 }
 usort($rows, function ($a, $b) {
     return $a['distance'] - $b['distance'];
 });
 // limit results for normal users
 if (!$master) {
     $count = 0;
     foreach ($rows as $index => $row) {
         if ($row['distance'] >= 20) {