* @since Kleo 1.0
*/

//var_dump(http_response_code());
get_header();
do_action(‘geodir_wrapper_open’, ‘home-page’, ‘geodir-wrapper’, ”);
?>

Select Your Sport

Select Your Activity



base_prefix . “geodir_custom_fields` WHERE admin_title = ‘” . $optionLabel . “‘ AND option_values != ” AND post_type <> ‘gd_camp_clinic’ AND post_type <> ‘gd_club_team’ AND post_type <> ‘gd_event’ AND post_type <> ‘gd_tournaments’ AND post_type <> ‘gd_ice_hockey'”;

//die($optionQuery);
$results = $wpdb->get_results($optionQuery);
$optionArray = array();

foreach($results as $row) {
$values = $row->option_values;
$valArray = explode(“,”, $values);
//die(“values:” . $values);
$optionArray = array_unique(array_merge($optionArray,$valArray), SORT_REGULAR);
}

//die(var_dump($optionArray));
$optionString = “”;
foreach($optionArray as $level)
{
$optionString .= “

0) { $pageStart = $_GET["pageStart"]; }

$strListings = ""; $strListingsOtherPages = ""; $geoJson = ""; $cache_file = "mapbox-cache/map_cache.cache"; $cache_fileListings = "mapbox-cache/map_listing_cache_" . $pageStart . ".cache"; $cache_fileListingsPaging = "mapbox-cache/map_listingpage_cache_" . $pageStart . ".cache"; $cache_levelOptions = "mapbox-cache/map_levels_cache.cache"; $cache_ageOptions = "mapbox-cache/map_ages_cache.cache"; $cache_genderOptions = "mapbox-cache/map_genders_cache.cache"; if (file_exists($cache_file)) { // Cache file is less than five minutes old. // Don't bother refreshing, just use the file as-is. $geoJson = file_get_contents($cache_file); $strListings = file_get_contents($cache_fileListings); $levelsOptionsString = file_get_contents($cache_levelOptions); $agesOptionsString = file_get_contents($cache_ageOptions); $gendersOptionsString = file_get_contents($cache_genderOptions); } else {

$geoJson = "["; $strListings = ""; global $wpdb; global $plugin_prefix; $types = array("gd_place", "gd_sled_hockey", "gd_figure_skating", "gd_curling");

$userId = $_GET["userId"]; $count = $_GET["count"]; $category = $_GET["category"]; $sort = $_GET["sort"];

//do options here.

$levelsOptionsString = buildOptions("Levels"); file_put_contents($cache_levelOptions, $levelsOptionsString, LOCK_EX);

$agesOptionsString = buildOptions("Age"); file_put_contents($cache_ageOptions, $agesOptionsString, LOCK_EX);

$gendersOptionsString = buildOptions("Gender"); file_put_contents($cache_genderOptions, $gendersOptionsString, LOCK_EX); //done options

$user_fav_posts = geodir_get_user_favourites( $userId); // die(var_dump($user_fav_posts)); // if ($user_fav_posts) { $x = 1; foreach($types as $type) {

$placeQuery = "SELECT p.ID, p.post_content, d.geodir_website, d.geodir_contact, d.default_category, d.geodir_age, d.geodir_Levels, d.geodir_gender, d.geodir_beginning_date, d.geodir_ending_date FROM `" . $wpdb->base_prefix . "posts` p INNER JOIN " . $plugin_prefix . $type . "_detail d ON p.ID = d.post_id";

if($type <> "gd_place") { $placeQuery = str_replace("geodir_Levels", "geodir_level", $placeQuery); } //echo $placeQuery;

$placeQuery .= " ORDER BY p.post_date DESC";

/*if($sort == "new") { $placeQuery .= " ORDER BY p.post_date DESC"; } elseif($sort == "old") { $placeQuery .= " ORDER BY p.post_date ASC"; } elseif($sort == "az") { $placeQuery .= " ORDER BY p.post_title ASC"; } elseif($sort == "za") { $placeQuery .= " ORDER BY p.post_title DESC"; }*/

//die($placeQuery); //echo($placeQuery); $results = $wpdb->get_results($placeQuery);

//die(var_dump($results)); //if ($results) { // echo '

    ';

    foreach($results as $row) { if($x == $count) { break; } $x++; //echo $post_id; // $the_query->the_post(); $post_id = $row->ID; //echo $post_id; //die("post ID" . $post_id);

    $postTemp = geodir_get_post_info($post_id); global $post; $post = $postTemp; setup_postdata($post); $post_avgratings = geodir_get_post_rating($post->ID); $post_ratings = geodir_get_rating_stars($post_avgratings, $post->ID); ob_start(); geodir_comments_number($post->rating_count); $n_comments = ob_get_contents(); ob_end_clean(); do_action('uwp_before_profile_favourite_item', $post_id, $user, $post_type); $GLOBALS['hideflex'] = 'yes'; $locs = $wpdb->get_results("SELECT `post_address` , `post_city` , `post_region` , `post_zip` , `post_latitude` , `post_longitude` FROM `" . $plugin_prefix . $type . "_detail` WHERE post_id = " . $post_id); // die("SELECT `post_address` , `post_city` , `post_region` , `post_zip` , `post_latitude` , `post_longitude` FROM `" . $plugin_prefix . $postType . "_detail` WHERE post_id = " . $postId); //die(var_dump($locs)); $loc = $locs[0];

    if($loc->post_latitude == null || $loc->post_latitude == '') { continue; }

    if($x > 2) { $geoJson .= ","; } if (has_post_thumbnail()) { $thumb_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full', false )[0]; } else { if($type == "gd_place") { $thumb_url = "/wp-content/uploads/2018/06/Default-icehockey-Screen.jpg"; } else if($type == "gd_sled_hockey") { $thumb_url = "/wp-content/uploads/2018/04/9163_c0e5f1d619a24672c360715db67f7d6c.jpg"; } else if($type == "gd_figure_skating") { $thumb_url = "/wp-content/uploads/2018/07/skates-2001797_1920-1.jpg"; } else if($type == "gd_curling") { $thumb_url = "/wp-content/uploads/2018/08/9863_Curing-Image-1.jpg"; } else { $thumb_url = USERSWP_PLUGIN_URL."/public/assets/images/no_thumb.png"; }

    } $formatDate = "";

    if($row->geodir_beginning_date != "0000-00-00" && $row->geodir_beginning_date != null && ($row->geodir_ending_date == null || $row->geodir_ending_date == "0000-00-00")) { $formatDate = date("m/d/y", strtotime($row->geodir_beginning_date)) . "
    "; } else if($row->geodir_beginning_date != null && $row->geodir_ending_date != null && $row->geodir_beginning_date != "0000-00-00" && $row->geodir_ending_date != "0000-00-00") { $formatDate = date("m/d/y", strtotime($row->geodir_beginning_date)) . " - " . date("m/d/y", strtotime($row->geodir_ending_date)) . "
    "; } $strListing = "

    " . the_title('', '', false) . "

    " . $formatDate . htmlspecialchars($loc->post_address, ENT_QUOTES ) . ", " . htmlspecialchars($loc->post_city, ENT_QUOTES ) . ", " . htmlspecialchars($loc->post_region, ENT_QUOTES ) . " " . htmlspecialchars($loc->post_zip, ENT_QUOTES ) . "

     Visit Website

    Phone: {$row->geodir_contact}

    ";

    if($x - 1 < $pageCount * ($pageStart + 1) && $x - 1 >= ($pageCount * ($pageStart))) {

    $strListings .= $strListing; } else { $strListingsOtherPages .= $strListing;

    if($x % $pageCount == 0 && ($x - 1) > 0) { $cache_fileListingsPage = "mapbox-cache/map_listing_cache_" . floor(($x - 1) / $pageCount) . ".cache"; file_put_contents($cache_fileListingsPage, $strListingsOtherPages, LOCK_EX); $strListingsOtherPages = ""; }

    }

    $geoJson .= "{"; $geoJson .= "type: 'Feature',"; $geoJson .= "geometry: {"; $geoJson .= "type: 'Point',"; $geoJson .= "coordinates:[" . $loc->post_longitude . ", " . $loc->post_latitude . "]"; $geoJson .= "},"; $geoJson .= "properties: {"; $geoJson .= "title: '" . the_title('', '', false) . "',"; $geoJson .= "description: '" . htmlspecialchars($loc->post_address, ENT_QUOTES ) . ", " . htmlspecialchars($loc->post_city, ENT_QUOTES ) . " " . htmlspecialchars($loc->post_region, ENT_QUOTES ) . " " . htmlspecialchars($loc->post_zip, ENT_QUOTES ) . "',"; $geoJson .= "content: '" . preg_replace('/[^[:print:]]/', '', htmlspecialchars(str_replace(array("\n", "\r", "
"), ' ', $row->post_content), ENT_QUOTES )) . "',"; $geoJson .= "link: '" . get_the_permalink() . "',"; $geoJson .= "state: '" . $loc->post_region . "',"; $geoJson .= "image: '" . $thumb_url . "',"; $geoJson .= "website: '" . $row->geodir_website . "',"; $geoJson .= "cat: '" . mapCategory($row->default_category) . "',"; $geoJson .= "phone: '" . $row->geodir_contact . "',"; $geoJson .= "age: '" . $row->geodir_age . "',"; $geoJson .= "gender: '" . $row->geodir_gender . "',"; $geoJson .= "levels: '" . $row->geodir_Levels . "',"; $geoJson .= "begindate: '" . $row->geodir_beginning_date . "',"; $geoJson .= "enddate: '" . $row->geodir_ending_date . "',"; $geoJson .= "formatDate: '" . $formatDate . "',"; $geoJson .= "type: '" . $type . "'"; $geoJson .= "}"; $geoJson .= "}";

    } } // } $geoJson .= "]";

    //write out paging here. for($z = 0; $z < ceil($x / $pageCount); $z++){ $dispCount = 8; $endDispCount = $dispCount; $startDispCount = 0; $numPages = ceil($x / $pageCount); $curPage = $z; if($curPage <= ( $dispCount / 2)) { $startDispCount = $curPage; $endDispCount = $dispCount - $startDispCount; } else if($curPage > 0 && ($numPages - $curPage) <= ($dispCount / 2)) { //alert("doing page " + curPage + " number pages " + numPages + disp Count); $endDispCount = $numPages - $curPage - 1; $startDispCount = $dispCount - $endDispCount; } else if ($z > 0 && curPage >= 0) { $startDispCount = ($dispCount / 2); $endDispCount = ($dispCount / 2); }

    $strPaging = "";

    $prevStart = 0;

    if($z > 0) { $prevStart = ($z - 1) * $pageCount; }

    //$strPaging .= $startDispCount . "|" . $endDispCount; $strPaging .= '« Previous';

    for($y = 0; $y < ceil($x / $pageCount); $y++){ if(!(($z - $startDispCount) <= $y && $y <= ($z + $endDispCount))) { continue; } /*if($y < $z - $startDispCount) { continue; } if($y > $z + $endDispCount) { continue; }*/

    if($y == $z) { $strPaging .= '' . ($y + 1) . ''; } else { $strPaging .= '' . ($y + 1) . ''; }

    }

    $strPaging .= 'Next »';

    //die("Puting Paging: " . $strPaging); file_put_contents("mapbox-cache/map_listingpage_cache_" . $z . ".cache", $strPaging, LOCK_EX); //die("Put Paging: "); } } // echo $cache_file; file_put_contents($cache_file, $geoJson, LOCK_EX); file_put_contents($cache_fileListings, $strListings, LOCK_EX); ?>

    var geojson = ;

    USE THE MAP! ZOOM IN OR CLICK ON A STATE

    Please Wait

    FIND WHAT YOU’RE LOOKING FOR

    SEARCH V
    Select Your Sport:

Search For:

Narrow your Search:



value=” />