https://www.mapsmarker.com/path-error for more details'); } include( 'wp-load.php' ); //info: check if plugin is active (didnt use is_plugin_active() due to problems reported by users) function lmm_is_plugin_active( $plugin ) { $active_plugins = get_option('active_plugins'); $active_plugins = array_flip($active_plugins); if ( isset($active_plugins[$plugin]) || lmm_is_plugin_active_for_network( $plugin ) ) { return true; } } function lmm_is_plugin_active_for_network( $plugin ) { if ( !is_multisite() ) return false; $plugins = get_site_option( 'active_sitewide_plugins'); if ( isset($plugins[$plugin]) ) return true; return false; } if (!lmm_is_plugin_active('leaflet-maps-marker/leaflet-maps-marker.php') ) { echo sprintf(__('The plugin "Leaflet Maps Marker" is inactive on this site and therefore this API link is not working.

Please contact the site owner (%1s) who can activate this plugin again.','lmm'), antispambot(get_bloginfo('admin_email')) ); } else { global $wpdb, $allowedtags; $lmm_options = get_option( 'leafletmapsmarker_options' ); $table_name_markers = $wpdb->prefix.'leafletmapsmarker_markers'; $table_name_layers = $wpdb->prefix.'leafletmapsmarker_layers'; $ar_wikitude_provider_name_sanitized = strtolower(preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), wp_kses($lmm_options[ 'ar_wikitude_provider_name' ], $allowedtags))); if (isset($_GET['layer'])) { $layer_prepared = esc_sql(strtolower($_GET['layer'])); $layer = str_replace(array("b","c","d","e","f","g","h","i","j","k","m","n","o","p","q","r","s","t","u","v","w","x","y","z","$","%","#","-","_","'","\"","\\"," ","!","/","(",")"), "", $layer_prepared); if ($layer == NULL) { die(); } $maxNumberOfPois = isset($_GET['maxNumberOfPois']) ? intval($_GET['maxNumberOfPois']) : intval($lmm_options[ 'ar_wikitude_maxnumberpois' ]); if ($layer == '*' or $layer == 'all') { //info: no exact results, but better than getting no results on calling Wikitude ARML links which might confuse users $first_marker_lat = $wpdb->get_var('SELECT `lat` FROM `'.$table_name_markers.'`'); $first_marker_lon = $wpdb->get_var('SELECT `lon` FROM `'.$table_name_markers.'`'); $latUser = isset($_GET['latitude']) ? floatval($_GET['latitude']) : $first_marker_lat; $lonUser = isset($_GET['longitude']) ? floatval($_GET['longitude']) : $first_marker_lon; } else { $mlm_layers = explode(',', $layer); $mlm_checkedlayers = array(); foreach ($mlm_layers as $mlm_clayer) { if (intval($mlm_clayer) > 0) { $mlm_checkedlayers[] = intval($mlm_clayer); } } if (count($mlm_checkedlayers) > 0) { $mlm_q = 'WHERE `id` IN ('.implode(',', $mlm_checkedlayers).')'; } $layerviewlat = $wpdb->get_var('SELECT `layerviewlat` FROM `'.$table_name_layers.'` '.$mlm_q); $layerviewlon = $wpdb->get_var('SELECT `layerviewlon` FROM `'.$table_name_layers.'` '.$mlm_q); $latUser = isset($_GET['latitude']) ? floatval($_GET['latitude']) : $layerviewlat; $lonUser = isset($_GET['longitude']) ? floatval($_GET['longitude']) : $layerviewlon; } $radius = intval($lmm_options[ 'ar_wikitude_radius' ]); $distanceLLA = 0.01 * $radius / 1112; $boundingBoxLatitude1 = $latUser - $distanceLLA; $boundingBoxLatitude2 = $latUser + $distanceLLA; $boundingBoxLongitude1 = $lonUser - $distanceLLA; $boundingBoxLongitude2 = $lonUser + $distanceLLA; isset($_GET['searchterm']) ? $searchterm = esc_sql($_GET['searchterm']) : $searchterm = NULL; if ($searchterm != NULL) { $q = ''; if ($layer == '*' or $layer == 'all') { $q = "WHERE m.lat BETWEEN " . $boundingBoxLatitude1 . " AND " . $boundingBoxLatitude2 . " AND m.lon BETWEEN " . $boundingBoxLongitude1 . " AND " . $boundingBoxLongitude2 . " AND (m.markername LIKE '%" . $searchterm . "%' OR m.popuptext LIKE '%" . $searchterm . "%')"; } else { $sql_mlm_check = 'SELECT `multi_layer_map` FROM `'.$table_name_layers.'` '.$mlm_q; $sql_mlm_check_list = 'SELECT `multi_layer_map_list` FROM `'.$table_name_layers.'` '.$mlm_q; $mlm_check = $wpdb->get_var($sql_mlm_check); $mlm_check_list = $wpdb->get_row($sql_mlm_check_list, ARRAY_A); if ($mlm_check == 0) { $layers = explode(',', $layer); $checkedlayers = array(); foreach ($layers as $clayer) { if (intval($clayer) > 0) { $checkedlayers[] = intval($clayer); } } if (count($checkedlayers) > 0) { $q = "WHERE m.layer IN (".implode(",", $checkedlayers).") and m.lat BETWEEN " . $boundingBoxLatitude1 . " AND " . $boundingBoxLatitude2 . " AND m.lon BETWEEN " . $boundingBoxLongitude1 . " AND " . $boundingBoxLongitude2 . " AND (m.markername LIKE '%" . $searchterm . "%' OR m.popuptext LIKE '%" . $searchterm . "%')"; } } else if ( ($mlm_check == 1) && (!in_array('all',$mlm_check_list) ) ) { $clayer = 0; $q = "WHERE m.layer IN (".implode(",", $mlm_check_list).") and m.lat BETWEEN " . $boundingBoxLatitude1 . " AND " . $boundingBoxLatitude2 . " AND m.lon BETWEEN " . $boundingBoxLongitude1 . " AND " . $boundingBoxLongitude2 . " AND (m.markername LIKE '%" . $searchterm . "%' OR m.popuptext LIKE '%" . $searchterm . "%')"; } else if ( ($mlm_check == 1) && (in_array('all',$mlm_check_list) ) ) { $clayer = 0; $q = ''; } } $sql = 'SELECT m.id as mid, m.layer as mlayer, m.markername as mmarkername, m.icon as micon, m.lat as mlat, m.lon as mlon, m.popuptext as mpopuptext, m.address as maddress FROM `'.$table_name_markers.'` AS m INNER JOIN `'.$table_name_layers.'` AS l ON m.layer=l.id '.$q; $markers = $wpdb->get_results($sql, ARRAY_A); header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-type: text/xml; charset=utf-8'); echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; if ($layer == '*' || $layer == 'all') { if (get_bloginfo('name') != NULL) { $layername = get_bloginfo('name'); } else { $layername = __('layer','lmm') . ' ID ' . $layer; } } else if ((count($checkedlayers) > 1) || ($mlm_check == 1)) { $layername = get_bloginfo('name') . ' - ' . __('layer','lmm') . ' ID ' . $layer; } else { $layername = $wpdb->get_var($wpdb->prepare("SELECT l.name FROM `$table_name_layers` as l WHERE l.id = %d", intval($layer))); } echo ''.PHP_EOL; echo '' . __('Wikitude API powered by www.mapsmarker.com','lmm') . ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; foreach ($markers as $marker) { //info: get icon urls for each marker if ($marker['micon'] == null) { $micon_url = LEAFLET_PLUGIN_URL . 'leaflet-dist/images/marker.png'; } else { $micon_url = LEAFLET_PLUGIN_ICONS_URL . '/' . $marker['micon']; } echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; //info: remove control chars & sanitize output $sanitize_popuptext_from = array( '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(){1}\s*#si', '#(){1}\s*#si', '#\s*(){1}#si', '#\s*(){1}#si', ); $sanitize_popuptext_to = array( '', '', '', '', '', '', '', '', '' ); $popuptext_sanitized = preg_replace($sanitize_popuptext_from, $sanitize_popuptext_to, stripslashes( str_replace("\\\\","/", str_replace('"', '\'', preg_replace('/[\x00-\x1F\x7F]/', '', preg_replace( '/(\015\012)|(\015)|(\012)/','
', $marker['mpopuptext']) ))))); echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; //echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo '
'.PHP_EOL; } echo '
'; echo '
'; } else { //info: if no searchterm $q = ''; if ($layer == '*' or $layer == 'all') { $q = "WHERE m.lat BETWEEN " . $boundingBoxLatitude1 . " AND " . $boundingBoxLatitude2 . " AND m.lon BETWEEN " . $boundingBoxLongitude1 . " AND " . $boundingBoxLongitude2 . "";//info: removed limit 5000 } else { $sql_mlm_check = 'SELECT `multi_layer_map` FROM `'.$table_name_layers.'` '.$mlm_q; $sql_mlm_check_list = 'SELECT `multi_layer_map_list` FROM `'.$table_name_layers.'` '.$mlm_q; $mlm_check = $wpdb->get_var($sql_mlm_check); $mlm_check_list = $wpdb->get_row($sql_mlm_check_list, ARRAY_A); if ($mlm_check == 0) { $layers = explode(',', $layer); $checkedlayers = array(); foreach ($layers as $clayer) { if (intval($clayer) > 0) { $checkedlayers[] = intval($clayer); } } if (count($checkedlayers) > 0) { $q = "WHERE layer IN (" . implode(",", $checkedlayers) . ") and m.lat BETWEEN " . $boundingBoxLatitude1 . " AND " . $boundingBoxLatitude2 . " AND m.lon BETWEEN " . $boundingBoxLongitude1 . " AND " . $boundingBoxLongitude2 . ""; } } else if ( ($mlm_check == 1) && (!in_array('all',$mlm_check_list) ) ) { $clayer = 0; $q = "WHERE layer IN (" . implode(",", $mlm_check_list) . ") and m.lat BETWEEN " . $boundingBoxLatitude1 . " AND " . $boundingBoxLatitude2 . " AND m.lon BETWEEN " . $boundingBoxLongitude1 . " AND " . $boundingBoxLongitude2 . ""; } else if ( ($mlm_check == 1) && (in_array('all',$mlm_check_list) ) ) { $clayer = 0; $q = ''; } } $sql = 'SELECT m.id as mid, m.layer as mlayer, m.markername as mmarkername, m.icon as micon, m.lat as mlat, m.lon as mlon, m.popuptext as mpopuptext, m.address as maddress FROM `'.$table_name_markers.'` AS m INNER JOIN `'.$table_name_layers.'` AS l ON m.layer=l.id '.$q; $markers = $wpdb->get_results($sql, ARRAY_A); header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-type: text/xml; charset=utf-8'); echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; if ($layer == '*' || $layer == 'all') { if (get_bloginfo('name') != NULL) { $layername = get_bloginfo('name'); } else { $layername = __('layer','lmm') . ' ID ' . $layer; } } else if ((count($checkedlayers) > 1) || ($mlm_check == 1)) { $layername = get_bloginfo('name') . ' - ' . __('layer','lmm') . ' ID ' . $layer; } else { $layername = $wpdb->get_var($wpdb->prepare("SELECT l.name FROM `$table_name_layers` as l WHERE l.id = %d", intval($layer))); } echo ''.PHP_EOL; echo '' . __('Wikitude API powered by www.mapsmarker.com','lmm') . ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; foreach ($markers as $marker) { //info: get icon urls for each marker if ($marker['micon'] == null) { $micon_url = LEAFLET_PLUGIN_URL . 'leaflet-dist/images/marker.png'; } else { $micon_url = LEAFLET_PLUGIN_ICONS_URL . '/' . $marker['micon']; } echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; //info: remove control chars & sanitize output $sanitize_popuptext_from = array( '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(){1}\s*#si', '#(){1}\s*#si', '#\s*(){1}#si', '#\s*(){1}#si', ); $sanitize_popuptext_to = array( '', '', '', '', '', '', '', '', '' ); $popuptext_sanitized = preg_replace($sanitize_popuptext_from, $sanitize_popuptext_to, stripslashes( str_replace("\\\\","/", str_replace('"', '\'', preg_replace('/[\x00-\x1F\x7F]/', '', preg_replace( '/(\015\012)|(\015)|(\012)/','
', $marker['mpopuptext']) ))))); echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; //echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo '
'.PHP_EOL; } echo '
'; echo '
'; } } elseif (isset($_GET['marker'])) { $markerid_prepared = esc_sql(strtolower($_GET['marker'])); $markerid = str_replace(array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","$","%","#","-","_","'","\"","\\"," ","!","/","*","(",")"), "", $markerid_prepared); if ($markerid == NULL) { die(); } $markers = explode(',', $markerid); $maxNumberOfPois = isset($_GET['maxNumberOfPois']) ? intval($_GET['maxNumberOfPois']) : intval($lmm_options[ 'ar_wikitude_maxnumberpois' ]); $markerlat = $wpdb->get_var('SELECT `lat` FROM `'.$table_name_markers.'` WHERE `id` IN ('.$markerid.')'); $markerlon = $wpdb->get_var('SELECT `lon` FROM `'.$table_name_markers.'` WHERE `id` IN ('.$markerid.')'); $latUser = isset($_GET['latitude']) ? floatval($_GET['latitude']) : $markerlat; $lonUser = isset($_GET['longitude']) ? floatval($_GET['longitude']) : $markerlon; $radius = intval($lmm_options[ 'ar_wikitude_radius' ]); $distanceLLA = 0.01 * $radius / 1112; $boundingBoxLatitude1 = $latUser - $distanceLLA; $boundingBoxLatitude2 = $latUser + $distanceLLA; $boundingBoxLongitude1 = $lonUser - $distanceLLA; $boundingBoxLongitude2 = $lonUser + $distanceLLA; isset($_GET['searchterm']) ? $searchterm = esc_sql($_GET['searchterm']) : $searchterm = NULL; if ($searchterm != NULL) { $checkedmarkers = array(); foreach ($markers as $cmarker) { if (intval($cmarker) > 0) { $checkedmarkers[] = intval($cmarker); } } if (count($checkedmarkers) > 0) { $q = "WHERE m.id IN (" . implode(",", $checkedmarkers) . ") AND (m.markername LIKE '%" . $searchterm . "%' OR m.popuptext LIKE '%" . $searchterm . "%')"; } else { die(); } //info: added left outer join to also show markers without a layer $sql = 'SELECT m.icon as micon, m.popuptext as mpopuptext, m.id as mid, m.markername as mmarkername, m.lat as mlat, m.lon as mlon, m.address as maddress FROM `'.$table_name_markers.'` AS m LEFT OUTER JOIN `'.$table_name_layers.'` AS l ON m.layer=l.id '.$q; $markers = $wpdb->get_results($sql, ARRAY_A); header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-type: text/xml; charset=utf-8'); echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; foreach ($markers as $marker) { $markername = ($marker[ 'mmarkername' ] != NULL) ? $marker[ 'mmarkername' ] : __('marker','lmm') . ' ID ' . $marker['mid']; echo ''.PHP_EOL; } echo '' . __('Wikitude API powered by www.mapsmarker.com','lmm') . ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; foreach ($markers as $marker) { //info: get icon urls for each marker if ($marker['micon'] == null) { $micon_url = LEAFLET_PLUGIN_URL . 'leaflet-dist/images/marker.png'; } else { $micon_url = LEAFLET_PLUGIN_ICONS_URL . '/' . $marker['micon']; } echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; $sanitize_popuptext_from = array( '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(){1}\s*#si', '#(){1}\s*#si', '#\s*(){1}#si', '#\s*(){1}#si', ); $sanitize_popuptext_to = array( '', '', '', '', '', '', '', '', '' ); $popuptext_sanitized = preg_replace($sanitize_popuptext_from, $sanitize_popuptext_to, stripslashes(preg_replace( '/(\015\012)|(\015)|(\012)/','
', $marker['mpopuptext']))); echo ''.PHP_EOL; echo ''.PHP_EOL; foreach ($markers as $marker) { //info: get icon urls for each marker if ($marker['micon'] == null) { $micon_url = LEAFLET_PLUGIN_URL . 'leaflet-dist/images/marker.png'; } else { $micon_url = LEAFLET_PLUGIN_ICONS_URL . '/' . $marker['micon']; } echo ''.PHP_EOL; echo ''.PHP_EOL; } echo ''.PHP_EOL; //echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo '
'.PHP_EOL; } echo '
'; echo '
'; } else { //info: if no searchterm $checkedmarkers = array(); foreach ($markers as $cmarker) { if (intval($cmarker) > 0) { $checkedmarkers[] = intval($cmarker); } } if (count($checkedmarkers) > 0) { $q = "WHERE m.id IN (" . implode(",", $checkedmarkers) . ")"; } else { die(); } //info: added left outer join to also show markers without a layer $sql = 'SELECT m.icon as micon, m.popuptext as mpopuptext, m.id as mid, m.markername as mmarkername, m.lat as mlat, m.lon as mlon, m.address as maddress FROM `'.$table_name_markers.'` AS m LEFT OUTER JOIN `'.$table_name_layers.'` AS l ON m.layer=l.id '.$q; $markers = $wpdb->get_results($sql, ARRAY_A); header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-type: text/xml; charset=utf-8'); echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; foreach ($markers as $marker) { $markername = ($marker[ 'mmarkername' ] != NULL) ? $marker[ 'mmarkername' ] : __('marker','lmm') . ' ID ' . $marker['mid']; echo ''.PHP_EOL; } echo '' . __('Wikitude API powered by www.mapsmarker.com','lmm') . ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; foreach ($markers as $marker) { //info: get icon urls for each marker if ($marker['micon'] == null) { $micon_url = LEAFLET_PLUGIN_URL . 'leaflet-dist/images/marker.png'; } else { $micon_url = LEAFLET_PLUGIN_ICONS_URL . '/' . $marker['micon']; } echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; $sanitize_popuptext_from = array( '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(\s)*()*(\s)*#si', '#(){1}\s*#si', '#(){1}\s*#si', '#\s*(){1}#si', '#\s*(){1}#si', ); $sanitize_popuptext_to = array( '', '', '', '', '', '', '', '', '' ); $popuptext_sanitized = preg_replace($sanitize_popuptext_from, $sanitize_popuptext_to, stripslashes(preg_replace( '/(\015\012)|(\015)|(\012)/','
', $marker['mpopuptext']))); echo ''.PHP_EOL; echo ''.PHP_EOL; foreach ($markers as $marker) { //info: get icon urls for each marker if ($marker['micon'] == null) { $micon_url = LEAFLET_PLUGIN_URL . 'leaflet-dist/images/marker.png'; } else { $micon_url = LEAFLET_PLUGIN_ICONS_URL . '/' . $marker['micon']; } echo ''.PHP_EOL; echo ''.PHP_EOL; } echo ''.PHP_EOL; //echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo '
'.PHP_EOL; } echo '
'; echo '
'; } } } //info: end plugin active check ?>