https://www.mapsmarker.com/path-error for more details'); } include( 'wp-load.php' ); //info: get callback parameters for JSONP $callback = (isset($_GET['callback']) == TRUE ) ? preg_replace( '/[^a-zA-Z0-9_]/', '', $_GET['callback']) : ''; //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 { //info: set php header to allow calls from other (sub)domains header('Access-Control-Allow-Origin: *'); global $wpdb, $locale; $table_name_markers = $wpdb->prefix.'leafletmapsmarker_markers'; $table_name_layers = $wpdb->prefix.'leafletmapsmarker_layers'; $lmm_options = get_option( 'leafletmapsmarker_options' ); $full = ( isset($_GET['full']) && ($_GET['full'] == 'yes') ) ? '1' : '0'; $full_icon_url = ( isset($_GET['full_icon_url']) && ($_GET['full_icon_url'] == 'yes') ) ? 'yes' : 'no'; //info: Google language localization (JSON API) if ($lmm_options['google_maps_language_localization'] == 'browser_setting') { $google_language = ''; } else if ($lmm_options['google_maps_language_localization'] == 'wordpress_setting') { if ( $locale != NULL ) { $google_language = "&hl=" . substr($locale, 0, 2); } else { $google_language = '&hl=en'; } } else { $google_language = "&hl=" . $lmm_options['google_maps_language_localization']; } 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); //info: not intval() cause otherwise $layer=0 when creating new layer and showing all markers with layer id = 0 $q = ''; if (($layer_prepared == 'all') || ($layer_prepared == '*')) { $q = ''; } else { $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).')'; } else { die('Error: a layer with that ID does not exist!'); } } if ($full == 0) { $sql = 'SELECT m.lat as mlat, m.lon as mlon, m.markername as mmarkername, m.icon as micon, m.popuptext as mpopuptext, m.address as maddress FROM '.$table_name_markers.' AS m '.$q; } else { $sql = 'SELECT m.id as mid, m.markername as mmarkername, m.layer as mlayer, m.icon as micon, m.createdby as mcreatedby, m.createdon as mcreatedon, m.updatedby as mupdatedby, m.updatedon as mupdatedon,m.zoom as mzoom, m.basemap as mbasemap, m.lat as mlat, m.lon as mlon, m.openpopup as mopenpopup, m.popuptext as mpopuptext, m.mapwidth as mmapwidth, m.mapwidthunit as mmapwidthunit, m.mapheight as mmapheight, m.controlbox as mcontrolbox, m.overlays_custom as moverlays_custom, m.overlays_custom2 as moverlays_custom2, m.overlays_custom3 as moverlays_custom3, m.overlays_custom4 as moverlays_custom4, m.wms as mwms, m.wms2 as mwms2, m.wms3 as mwms3, m.wms4 as mwms4, m.wms5 as mwms5, m.wms6 as mwms6, m.wms7 as mwms7, m.wms8 as mwms8, m.wms9 as mwms9, m.wms10 as mwms10, m.kml_timestamp as mkml_timestamp, m.address as maddress, l.createdby as lcreatedby, l.createdon as lcreatedon, l.updatedby as lupdatedby, l.updatedon as lupdatedon, l.name AS lname 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); $first = true; header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-type: application/json; charset=utf-8'); //info: callback for JSONP - part 1 if ($callback != NULL) { echo $callback . '('; } echo '{"type":"FeatureCollection",'.PHP_EOL; echo '"features":['.PHP_EOL; if ($layer != NULL) { //info: needed for adding new layers foreach ($markers as $marker) { if ($first) $first = false; else echo ','.PHP_EOL; echo '{'.PHP_EOL; echo '"type":"Feature",'.PHP_EOL; echo '"geometry":'.PHP_EOL; echo '{'.PHP_EOL; echo '"type":"Point",'.PHP_EOL; echo '"coordinates":[' . $marker['mlon'] . ',' . $marker['mlat'] . ']'.PHP_EOL; echo '},'.PHP_EOL; echo '"properties":'.PHP_EOL; echo '{'.PHP_EOL; if ($full == 1) { echo '"markerid":"'.$marker['mid'].'",'.PHP_EOL; } echo '"markername":"' . wp_specialchars_decode(stripslashes(esc_js(preg_replace('/[\x00-\x1F\x7F]/', '', $marker['mmarkername'])))) . '",'.PHP_EOL; if ($full == 1) { echo '"basemap":"'.$marker['mbasemap'].'",'.PHP_EOL; echo '"lat":"'.$marker['mlat'].'",'.PHP_EOL; echo '"lon":"'.$marker['mlon'].'",'.PHP_EOL; } echo '"icon":"'.$marker['micon'].'",'.PHP_EOL; if ($full_icon_url == 'yes') { $marker_full_url = ($marker['micon'] == NULL) ? LEAFLET_PLUGIN_URL . "leaflet-dist/images/marker.png" : LEAFLET_PLUGIN_ICONS_URL . "/" . $marker['micon']; echo '"iconUrl":"'.$marker_full_url.'",'.PHP_EOL; } $maddress = stripslashes(str_replace('"', '\'', preg_replace('/[\x00-\x1F\x7F]/', '', $marker['maddress']))); if ( ($full == 0) && ($lmm_options['directions_popuptext_panel'] == 'yes') ) { echo '"address":"'.$maddress.'",'.PHP_EOL; } else if ($full == 1) { echo '"address":"'.$maddress.'",'.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( '', '', '', '', '', '', '', '', '' ); //info: remove control chars & sanitize output $mpopuptext = 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']) ))))); if ($lmm_options['directions_popuptext_panel'] == 'yes') { $mpopuptext_css = ($marker['mpopuptext'] != NULL) ? "border-top:1px solid #f0f0e7;padding-top:5px;margin-top:5px;clear:both;" : ""; $mpopuptext = $mpopuptext . "'; } echo '"text":"' . $mpopuptext . '"'; if ($full == 1) { echo ','.PHP_EOL.'"zoom":"' . $marker['mzoom'] . '",'.PHP_EOL; echo '"openpopup":"' . $marker['mopenpopup'] . '",'.PHP_EOL; echo '"mapwidth":"' . $marker['mmapwidth'] . '",'.PHP_EOL; echo '"mapwidthunit":"' . $marker['mmapwidthunit'] . '",'.PHP_EOL; echo '"mapheight":"' . $marker['mmapheight'] . '",'.PHP_EOL; echo '"marker-createdby":"' . stripslashes($marker['mcreatedby']) . '",'.PHP_EOL; echo '"marker-createdon":"' . $marker['mcreatedon'] . '",'.PHP_EOL; echo '"marker-updatedby":"' . stripslashes($marker['mupdatedby']) . '",'.PHP_EOL; echo '"marker-updatedon":"' . stripslashes($marker['mupdatedon']) . '",'.PHP_EOL; echo '"layerid":"'.$marker['mlayer'].'",'.PHP_EOL; echo '"layername":"' . stripslashes(preg_replace('/[\x00-\x1F\x7F]/', '', $marker['lname'])) . '",'.PHP_EOL; echo '"layer-createdby":"' . $marker['lcreatedby'] . '",'.PHP_EOL; echo '"layer-createdon":"' . $marker['lcreatedon'] . '",'.PHP_EOL; echo '"layer-updatedby":"' . stripslashes($marker['lupdatedby']) . '",'.PHP_EOL; echo '"layer-updatedon":"' . stripslashes($marker['lupdatedon']) . '",'.PHP_EOL; echo '"controlbox":"'.$marker['mcontrolbox'].'",'.PHP_EOL; echo '"overlays_custom":"'.$marker['moverlays_custom'].'",'.PHP_EOL; echo '"overlays_custom2":"'.$marker['moverlays_custom2'].'",'.PHP_EOL; echo '"overlays_custom3":"'.$marker['moverlays_custom3'].'",'.PHP_EOL; echo '"overlays_custom4":"'.$marker['moverlays_custom4'].'",'.PHP_EOL; echo '"wms":"'.$marker['mwms'].'",'.PHP_EOL; echo '"wms2":"'.$marker['mwms2'].'",'.PHP_EOL; echo '"wms3":"'.$marker['mwms3'].'",'.PHP_EOL; echo '"wms4":"'.$marker['mwms4'].'",'.PHP_EOL; echo '"wms5":"'.$marker['mwms5'].'",'.PHP_EOL; echo '"wms6":"'.$marker['mwms6'].'",'.PHP_EOL; echo '"wms7":"'.$marker['mwms7'].'",'.PHP_EOL; echo '"wms8":"'.$marker['mwms8'].'",'.PHP_EOL; echo '"wms9":"'.$marker['mwms9'].'",'.PHP_EOL; echo '"wms10":"'.$marker['mwms10'].'",'.PHP_EOL; echo '"kml_timestamp":"'.$marker['mkml_timestamp'].'"'.PHP_EOL; } echo '}}'; } } //info: end ($layer != NULL) echo ']}'; //info: callback for JSONP - part 2 if ($callback != NULL) { echo ');'; } } elseif (isset($_GET['marker'])) { $markerid_prepared = esc_sql(strtolower($_GET['marker'])); $markerid = 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","$","%","#","-","_","'","\"","\\","(",")"), "", $markerid_prepared); if (($markerid_prepared == 'all') || ($markerid_prepared == '*')) { $q = ''; } else { $markers = explode(',', $markerid); $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('Error: a marker with that ID does not exist!'); } } //info: added left outer join to also show markers without a layer if ($full == 0) { $sql = 'SELECT m.lat as mlat, m.lon as mlon, m.markername as mmarkername, m.icon as micon, m.popuptext as mpopuptext, m.address as maddress FROM '.$table_name_markers.' AS m '.$q; } else { $sql = 'SELECT m.id as mid, m.markername as mmarkername, m.layer as mlayer, m.icon as micon, m.createdby as mcreatedby, m.createdon as mcreatedon, m.updatedby as mupdatedby, m.updatedon as mupdatedon,m.zoom as mzoom, m.basemap as mbasemap, m.lat as mlat, m.lon as mlon, m.openpopup as mopenpopup, m.popuptext as mpopuptext, m.mapwidth as mmapwidth, m.mapwidthunit as mmapwidthunit, m.mapheight as mmapheight, m.controlbox as mcontrolbox, m.overlays_custom as moverlays_custom, m.overlays_custom2 as moverlays_custom2, m.overlays_custom3 as moverlays_custom3, m.overlays_custom4 as moverlays_custom4, m.wms as mwms, m.wms2 as mwms2, m.wms3 as mwms3, m.wms4 as mwms4, m.wms5 as mwms5, m.wms6 as mwms6, m.wms7 as mwms7, m.wms8 as mwms8, m.wms9 as mwms9, m.wms10 as mwms10, m.kml_timestamp as mkml_timestamp, m.address as maddress, l.createdby as lcreatedby, l.createdon as lcreatedon, l.updatedby as lupdatedby, l.updatedon as lupdatedon, l.name AS lname 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); $first = true; header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-type: application/json; charset=utf-8'); //info: callback for JSONP - part 1 if ($callback != NULL) { echo $callback . '('; } echo '{"type":"FeatureCollection",'.PHP_EOL; echo '"features":['.PHP_EOL; foreach ($markers as $marker) { if ($first) $first = false; else echo ','.PHP_EOL; echo '{'.PHP_EOL; echo '"type":"Feature",'.PHP_EOL; echo '"geometry":'.PHP_EOL; echo '{'.PHP_EOL; echo '"type":"Point",'.PHP_EOL; echo '"coordinates":[' . $marker['mlon'] . ',' . $marker['mlat'] . ']'.PHP_EOL; echo '},'.PHP_EOL; echo '"properties":'.PHP_EOL; echo '{'.PHP_EOL; if ($full == 1) { echo '"markerid":"'.$marker['mid'].'",'.PHP_EOL; echo '"markername":"' . wp_specialchars_decode(stripslashes(esc_js(preg_replace('/[\x00-\x1F\x7F]/', '', $marker['mmarkername'])))) . '",'.PHP_EOL; echo '"basemap":"'.$marker['mbasemap'].'",'.PHP_EOL; echo '"lat":"'.$marker['mlat'].'",'.PHP_EOL; echo '"lon":"'.$marker['mlon'].'",'.PHP_EOL; } echo '"icon":"'.$marker['micon'].'",'.PHP_EOL; if ($full_icon_url == 'yes') { $marker_full_url = ($marker['micon'] == NULL) ? LEAFLET_PLUGIN_URL . "leaflet-dist/images/marker.png" : LEAFLET_PLUGIN_ICONS_URL . "/" . $marker['micon']; echo '"iconUrl":"'.$marker_full_url.'",'.PHP_EOL; } $maddress = stripslashes(str_replace('"', '\'', preg_replace('/[\x00-\x1F\x7F]/', '', $marker['maddress']))); if ( ($full == 0) && ($lmm_options['directions_popuptext_panel'] == 'yes') ) { echo '"address":"'.$maddress.'",'.PHP_EOL; } else if ($full == 1) { echo '"address":"'.$maddress.'",'.PHP_EOL; } if ($lmm_options['directions_popuptext_panel'] == 'yes') { $mpopuptext_css = ($marker['mpopuptext'] != NULL) ? "border-top:1px solid #f0f0e7;padding-top:5px;margin-top:5px;clear:both;" : ""; $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( '', '', '', '', '', '', '', '', '' ); //info: remove control chars & sanitize output $mpopuptext = 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']) ))))); $mpopuptext = $mpopuptext . "'; } echo '"text":"' . $mpopuptext . '"'; if ($full == 1) { echo ','.PHP_EOL.'"zoom":"' . $marker['mzoom'] . '",'.PHP_EOL; echo '"openpopup":"' . $marker['mopenpopup'] . '",'.PHP_EOL; echo '"mapwidth":"' . $marker['mmapwidth'] . '",'.PHP_EOL; echo '"mapwidthunit":"' . $marker['mmapwidthunit'] . '",'.PHP_EOL; echo '"mapheight":"' . $marker['mmapheight'] . '",'.PHP_EOL; echo '"marker-createdby":"' . stripslashes($marker['mcreatedby']) . '",'.PHP_EOL; echo '"marker-createdon":"' . $marker['mcreatedon'] . '",'.PHP_EOL; echo '"marker-updatedby":"' . stripslashes($marker['mupdatedby']) . '",'.PHP_EOL; echo '"marker-updatedon":"' . stripslashes($marker['mupdatedon']) . '",'.PHP_EOL; echo '"layerid":"'.$marker['mlayer'].'",'.PHP_EOL; echo '"layername":"' . stripslashes(preg_replace('/[\x00-\x1F\x7F]/', '', $marker['lname'])) . '",'.PHP_EOL; echo '"layer-createdby":"' . $marker['lcreatedby'] . '",'.PHP_EOL; echo '"layer-createdon":"' . $marker['lcreatedon'] . '",'.PHP_EOL; echo '"layer-updatedby":"' . stripslashes($marker['lupdatedby']) . '",'.PHP_EOL; echo '"layer-updatedon":"' . stripslashes($marker['lupdatedon']) . '",'.PHP_EOL; echo '"controlbox":"'.$marker['mcontrolbox'].'",'.PHP_EOL; echo '"overlays_custom":"'.$marker['moverlays_custom'].'",'.PHP_EOL; echo '"overlays_custom2":"'.$marker['moverlays_custom2'].'",'.PHP_EOL; echo '"overlays_custom3":"'.$marker['moverlays_custom3'].'",'.PHP_EOL; echo '"overlays_custom4":"'.$marker['moverlays_custom4'].'",'.PHP_EOL; echo '"wms":"'.$marker['mwms'].'",'.PHP_EOL; echo '"wms2":"'.$marker['mwms2'].'",'.PHP_EOL; echo '"wms3":"'.$marker['mwms3'].'",'.PHP_EOL; echo '"wms4":"'.$marker['mwms4'].'",'.PHP_EOL; echo '"wms5":"'.$marker['mwms5'].'",'.PHP_EOL; echo '"wms6":"'.$marker['mwms6'].'",'.PHP_EOL; echo '"wms7":"'.$marker['mwms7'].'",'.PHP_EOL; echo '"wms8":"'.$marker['mwms8'].'",'.PHP_EOL; echo '"wms9":"'.$marker['mwms9'].'",'.PHP_EOL; echo '"wms10":"'.$marker['mwms10'].'",'.PHP_EOL; echo '"kml_timestamp":"'.$marker['mkml_timestamp'].'"'.PHP_EOL; } echo '}}'; } echo ']}'; //info: callback for JSONP - part 2 if ($callback != NULL) { echo ');'; } } } //info: end plugin active check ?>