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;
$table_name_markers = $wpdb->prefix.'leafletmapsmarker_markers';
$table_name_layers = $wpdb->prefix.'leafletmapsmarker_layers';
$lmm_options = get_option( 'leafletmapsmarker_options' );
if ($lmm_options[ 'wms_wms_kml_support' ] == 'yes') { $wms_kml_output = '10' . $lmm_options[ 'wms_wms_kml_refreshMode' ] . '' . intval($lmm_options[ 'wms_wms_kml_refreshInterval' ]) . '' . $lmm_options[ 'wms_wms_kml_viewRefreshMode' ] . '' . intval($lmm_options[ 'wms_wms_kml_viewRefreshTime' ]) . ''; };
if ($lmm_options[ 'wms_wms2_kml_support' ] == 'yes') { $wms2_kml_output = '10' . $lmm_options[ 'wms_wms2_kml_refreshMode' ] . '' . intval($lmm_options[ 'wms_wms2_kml_refreshInterval' ]) . '' . $lmm_options[ 'wms_wms2_kml_viewRefreshMode' ] . '' . intval($lmm_options[ 'wms_wms2_kml_viewRefreshTime' ]) . ''; };
if ($lmm_options[ 'wms_wms3_kml_support' ] == 'yes') { $wms3_kml_output = '10' . $lmm_options[ 'wms_wms3_kml_refreshMode' ] . '' . intval($lmm_options[ 'wms_wms3_kml_refreshInterval' ]) . '' . $lmm_options[ 'wms_wms3_kml_viewRefreshMode' ] . '' . intval($lmm_options[ 'wms_wms3_kml_viewRefreshTime' ]) . ''; };
if ($lmm_options[ 'wms_wms4_kml_support' ] == 'yes') { $wms4_kml_output = '10' . $lmm_options[ 'wms_wms4_kml_refreshMode' ] . '' . intval($lmm_options[ 'wms_wms4_kml_refreshInterval' ]) . '' . $lmm_options[ 'wms_wms4_kml_viewRefreshMode' ] . '' . intval($lmm_options[ 'wms_wms4_kml_viewRefreshTime' ]) . ''; };
if ($lmm_options[ 'wms_wms5_kml_support' ] == 'yes') { $wms5_kml_output = '10' . $lmm_options[ 'wms_wms5_kml_refreshMode' ] . '' . intval($lmm_options[ 'wms_wms5_kml_refreshInterval' ]) . '' . $lmm_options[ 'wms_wms5_kml_viewRefreshMode' ] . '' . intval($lmm_options[ 'wms_wms5_kml_viewRefreshTime' ]) . ''; };
if ($lmm_options[ 'wms_wms6_kml_support' ] == 'yes') { $wms6_kml_output = '10' . $lmm_options[ 'wms_wms6_kml_refreshMode' ] . '' . intval($lmm_options[ 'wms_wms6_kml_refreshInterval' ]) . '' . $lmm_options[ 'wms_wms6_kml_viewRefreshMode' ] . '' . intval($lmm_options[ 'wms_wms6_kml_viewRefreshTime' ]) . ''; };
if ($lmm_options[ 'wms_wms7_kml_support' ] == 'yes') { $wms7_kml_output = '10' . $lmm_options[ 'wms_wms7_kml_refreshMode' ] . '' . intval($lmm_options[ 'wms_wms7_kml_refreshInterval' ]) . '' . $lmm_options[ 'wms_wms7_kml_viewRefreshMode' ] . '' . intval($lmm_options[ 'wms_wms7_kml_viewRefreshTime' ]) . ''; };
if ($lmm_options[ 'wms_wms8_kml_support' ] == 'yes') { $wms8_kml_output = '10' . $lmm_options[ 'wms_wms8_kml_refreshMode' ] . '' . intval($lmm_options[ 'wms_wms8_kml_refreshInterval' ]) . '' . $lmm_options[ 'wms_wms8_kml_viewRefreshMode' ] . '' . intval($lmm_options[ 'wms_wms8_kml_viewRefreshTime' ]) . ''; };
if ($lmm_options[ 'wms_wms9_kml_support' ] == 'yes') { $wms9_kml_output = '10' . $lmm_options[ 'wms_wms9_kml_refreshMode' ] . '' . intval($lmm_options[ 'wms_wms9_kml_refreshInterval' ]) . '' . $lmm_options[ 'wms_wms9_kml_viewRefreshMode' ] . '' . intval($lmm_options[ 'wms_wms9_kml_viewRefreshTime' ]) . ''; };
if ($lmm_options[ 'wms_wms10_kml_support' ] == 'yes') { $wms10_kml_output = '10' . $lmm_options[ 'wms_wms10_kml_refreshMode' ] . '' . intval($lmm_options[ 'wms_wms10_kml_refreshInterval' ]) . '' . $lmm_options[ 'wms_wms10_kml_viewRefreshMode' ] . '' . intval($lmm_options[ 'wms_wms10_kml_viewRefreshTime' ]) . ''; };
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);
$q = '';
if (($layer_prepared == 'all') || ($layer_prepared == '*')) {
$q = '';
} 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).')';
$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).')';
}
} else if ( ($mlm_check == 1) && (!in_array('all',$mlm_check_list) ) ){
$q = 'WHERE layer IN ('.implode(',', $mlm_check_list).')';
} else if ( ($mlm_check == 1) && (in_array('all',$mlm_check_list) ) ){
$q = '';
}
} else {
die('Error: a layer with that ID does not exist!');
}
}
$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.lat as mlat, m.lon as mlon, m.popuptext as mpopuptext, m.kml_timestamp as mkml_timestamp, m.address as maddress, l.createdby as lcreatedby, l.createdon as lcreatedon, l.name as lname, l.wms as lwms, l.wms2 as lwms2, l.wms3 as lwms3, l.wms4 as lwms4, l.wms5 as lwms5, l.wms6 as lwms6, l.wms7 as lwms7, l.wms8 as lwms8, l.wms9 as lwms9, l.wms10 as lwms10 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);
$sql_distinct = 'SELECT DISTINCT m.icon as micon FROM `'.$table_name_markers.'` AS m INNER JOIN `'.$table_name_layers.'` AS l ON m.layer=l.id '.$q;
$styles_distinct = $wpdb->get_results($sql_distinct, ARRAY_A);
if ($_GET['layer'] != 'all') {
$sql_wms_layer_for_kml = 'SELECT l.id as lid, l.wms as lwms, l.wms2 as lwms2, l.wms3 as lwms3, l.wms4 as lwms4, l.wms5 as lwms5, l.wms6 as lwms6, l.wms7 as lwms7, l.wms8 as lwms8, l.wms9 as lwms9, l.wms10 as lwms10 FROM `'.$table_name_layers.'` AS l '.$mlm_q;
$wmslayer_kml = $wpdb->get_results($sql_wms_layer_for_kml, ARRAY_A);
}
//info: check if layer result is not null
if (empty($markers)) {
$error_layers_not_exists = sprintf( esc_attr__('Warning: no markers are assigned to the layer with the ID %1$s or the layer does not exist!','lmm'), $layer);
echo $error_layers_not_exists;
} else {
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/vnd.google-earth.kml+xml; charset=utf-8');
header('Content-Disposition: attachment; filename="' . preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), get_bloginfo('name')) . '-layer-' . $layer . '.kml"');
echo ''.PHP_EOL;
echo ''.PHP_EOL;
echo ''.PHP_EOL;
echo 'WordPress & MapsMarker.com]]>'.PHP_EOL;
echo '1'.PHP_EOL;
foreach ($styles_distinct as $marker_icon) {
if ($marker_icon['micon'] == null) {
$micon_url = LEAFLET_PLUGIN_URL . 'leaflet-dist/images/marker.png';
$micon_name = 'default';
} else {
$micon_url = LEAFLET_PLUGIN_ICONS_URL . '/' . $marker_icon['micon'];
$micon_name = substr($marker_icon['micon'],0,-4);
}
echo ''.PHP_EOL;
}
$layername = $wpdb->get_var( $wpdb->prepare("SELECT `name` FROM `$table_name_layers` WHERE `id` = %d", intval($_GET['layer']) ) );
if ($_GET['layer'] != 'all') {
echo ''.PHP_EOL;
echo '' . htmlspecialchars($layername) . ''.PHP_EOL;
}
foreach ($markers as $marker) {
if ( isset($_GET['name']) && ($_GET['name'] == 'show') ) {
$name = stripslashes(htmlspecialchars($marker['mmarkername']));
$name_popup = '';
} else if ( isset($_GET['name']) && ($_GET['name'] == 'hide') ) {
$name = '';
$name_popup = '';
} else if ( isset($_GET['name']) && ($_GET['name'] == 'popup') ) {
$name = '';
$name_popup = '' . stripslashes(htmlspecialchars($marker['mmarkername'])) . '