Settings'; // add the link to the list array_unshift($links, $settings_link); } return $links; } function enqueue_WP_GPX_Maps_scripts() { $wpgpxmaps_googlemapsv3_apikey = get_option('wpgpxmaps_googlemapsv3_apikey'); wp_enqueue_script( 'jquery' ); if ($wpgpxmaps_googlemapsv3_apikey) { wp_enqueue_script( 'googlemaps', '//maps.googleapis.com/maps/api/js?key='.$wpgpxmaps_googlemapsv3_apikey, null, null); } else { wp_enqueue_script( 'googlemaps', '//maps.googleapis.com/maps/api/js', null, null); } wp_enqueue_script( 'highcharts', "//code.highcharts.com/3.0.10/highcharts.js", array('jquery'), "3.0.10", true); wp_enqueue_script( 'WP-GPX-Maps', plugins_url('/WP-GPX-Maps.js', __FILE__), array('jquery','googlemaps','highcharts'), "1.3.15"); } function print_WP_GPX_Maps_styles() { ?> ele[$i]; $_dist = (float)$points->dist[$i]; if ($uom == '1') { // Miles and feet $_dist *= 0.000621371192; $_ele *= 3.2808399; } else if ($uom == '2') { // meters / kilometers $_dist = (float)($_dist / 1000); } else if ($uom == '3') { // meters / kilometers / nautical miles $_dist = (float)($_dist / 1000 / 1.852); } else if ($uom == '4') { // meters / miles $_dist *= 0.000621371192; } else if ($uom == '5') { // meters / kilometers / nautical miles and feet $_dist = (float)($_dist / 1000 / 1.852); $_ele *= 3.2808399; } $points_graph_dist .= number_format ( $_dist , 2 , '.' , '' ).','; $points_graph_ele .= number_format ( $_ele , 2 , '.' , '' ).','; } } print_r($points); } } } function handle_WP_GPX_Maps_Shortcodes($attr, $content='') { $error = ''; $gpx = findValue($attr, "gpx", "", ""); $w = findValue($attr, "width", "wpgpxmaps_width", "100%"); $mh = findValue($attr, "mheight", "wpgpxmaps_height", "450px"); $mt = findValue($attr, "mtype", "wpgpxmaps_map_type", "HYBRID"); $gh = findValue($attr, "gheight", "wpgpxmaps_graph_height", "200px"); $showCad = findValue($attr, "showcad", "wpgpxmaps_show_cadence", false); $showHr = findValue($attr, "showhr", "wpgpxmaps_show_hr", false); $showAtemp = findValue($attr, "showatemp", "wpgpxmaps_show_atemp", false); $showW = findValue($attr, "waypoints", "wpgpxmaps_show_waypoint", false); $showEle = findValue($attr, "showele", "wpgpxmaps_show_elevation", "true"); $showSpeed = findValue($attr, "showspeed", "wpgpxmaps_show_speed", false); $showGrade = findValue($attr, "showgrade", "wpgpxmaps_show_grade", false); $zoomOnScrollWheel = findValue($attr, "zoomonscrollwheel", "wpgpxmaps_zoomonscrollwheel", false); $donotreducegpx = findValue($attr, "donotreducegpx", "wpgpxmaps_donotreducegpx", false); $pointsoffset = findValue($attr, "pointsoffset", "wpgpxmaps_pointsoffset", 10); $uom = findValue($attr, "uom", "wpgpxmaps_unit_of_measure", "0"); $uomspeed = findValue($attr, "uomspeed", "wpgpxmaps_unit_of_measure_speed", "0"); $color_map = findValue($attr, "mlinecolor", "wpgpxmaps_map_line_color", "#3366cc"); $color_graph = findValue($attr, "glinecolor", "wpgpxmaps_graph_line_color", "#3366cc"); $color_graph_speed = findValue($attr, "glinecolorspeed", "wpgpxmaps_graph_line_color_speed", "#ff0000"); $color_graph_hr = findValue($attr, "glinecolorhr", "wpgpxmaps_graph_line_color_hr", "#ff77bd"); $color_graph_atemp = findValue($attr, "glinecoloratemp", "wpgpxmaps_graph_line_color_atemp", "#ff77bd"); $color_graph_cad = findValue($attr, "glinecolorcad", "wpgpxmaps_graph_line_color_cad", "#beecff"); $color_graph_grade = findValue($attr, "glinecolorgrade", "wpgpxmaps_graph_line_color_grade", "#beecff"); $chartFrom1 = findValue($attr, "chartfrom1", "wpgpxmaps_graph_offset_from1", ""); $chartTo1 = findValue($attr, "chartto1", "wpgpxmaps_graph_offset_to1", ""); $chartFrom2 = findValue($attr, "chartfrom2", "wpgpxmaps_graph_offset_from2", ""); $chartTo2 = findValue($attr, "chartto2", "wpgpxmaps_graph_offset_to2", ""); $startIcon = findValue($attr, "starticon", "wpgpxmaps_map_start_icon", ""); $endIcon = findValue($attr, "endicon", "wpgpxmaps_map_end_icon", ""); $currentIcon = findValue($attr, "currenticon", "wpgpxmaps_map_current_icon", ""); $waypointIcon = findValue($attr, "waypointicon", "wpgpxmaps_map_waypoint_icon", ""); $ngGalleries = findValue($attr, "nggalleries", "wpgpxmaps_map_ngGalleries", ""); $ngImages = findValue($attr, "ngimages", "wpgpxmaps_map_ngImages", ""); // folgende Zeile hinzugefügt: $attachments = findValue($attr, "attachments", "wpgpxmaps_map_attachments", false); $download = findValue($attr, "download", "wpgpxmaps_download", ""); $dtoffset = findValue($attr, "dtoffset", "wpgpxmaps_dtoffset", 0); $distanceType = findValue($attr, "distanceType", "wpgpxmaps_distance_type", 0); $skipcache = findValue($attr, "skipcache", "wpgpxmaps_skipcache", ""); $summary = findValue($attr, "summary", "wpgpxmaps_summary", ""); $p_tot_len = findValue($attr, "summarytotlen", "wpgpxmaps_summary_tot_len", false); $p_max_ele = findValue($attr, "summarymaxele", "wpgpxmaps_summary_max_ele", false); $p_min_ele = findValue($attr, "summaryminele", "wpgpxmaps_summary_min_ele", false); $p_total_ele_up = findValue($attr, "summaryeleup", "wpgpxmaps_summary_total_ele_up", false); $p_total_ele_down = findValue($attr, "summaryeledown", "wpgpxmaps_summary_total_ele_down", false); $p_avg_speed = findValue($attr, "summaryavgspeed", "wpgpxmaps_summary_avg_speed", false); $p_total_time = findValue($attr, "summarytotaltime", "wpgpxmaps_summary_total_time", false); $usegpsposition = findValue($attr, "usegpsposition", "wpgpxmaps_usegpsposition", false); $currentpositioncon = findValue($attr, "currentpositioncon", "wpgpxmaps_currentpositioncon", ""); $colors_map = "\"".implode("\",\"",(explode(" ",$color_map)))."\""; $gpxurl = $gpx; // Add file modification time to cache filename to catch new uploads with same file name $mtime = sitePath() . str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, trim($gpx)); if(file_exists($mtime)) { $mtime = filemtime($mtime); } else { $mtime = 0; } $cacheFileName = "$gpx,$mtime,$w,$mh,$mt,$gh,$showEle,$showW,$showHr,$showAtemp,$showCad,$donotreducegpx,$pointsoffset,$showSpeed,$showGrade,$uomspeed,$uom,$distanceType,v1.3.9"; $cacheFileName = md5($cacheFileName); $gpxcache = gpxCacheFolderPath(); if(!(file_exists($gpxcache) && is_dir($gpxcache))) @mkdir($gpxcache,0755,true); $gpxcache.= DIRECTORY_SEPARATOR.$cacheFileName.".tmp"; // Try to load cache if (file_exists($gpxcache) && !($skipcache == true)) { try { $cache_str = file_get_contents($gpxcache); $cache_obj = unserialize($cache_str); $points_maps = $cache_obj["points_maps"]; $points_x_time = $cache_obj["points_x_time"]; $points_x_lat = $cache_obj["points_x_lat"]; $points_x_lon = $cache_obj["points_x_lon"]; $points_graph_dist = $cache_obj["points_graph_dist"]; $points_graph_ele = $cache_obj["points_graph_ele"]; $points_graph_speed = $cache_obj["points_graph_speed"]; $points_graph_hr = $cache_obj["points_graph_hr"]; $points_graph_atemp = $cache_obj["points_graph_atemp"]; $points_graph_cad = $cache_obj["points_graph_cad"]; $points_graph_grade = $cache_obj["points_graph_grade"]; $waypoints = $cache_obj["waypoints"]; $max_ele = $cache_obj["max_ele"]; $min_ele = $cache_obj["min_ele"]; $max_time = $cache_obj["max_time"]; $min_time = $cache_obj["min_time"]; $total_ele_up = $cache_obj["total_ele_up"]; $total_ele_down = $cache_obj["total_ele_down"]; $avg_speed = $cache_obj["avg_speed"]; $tot_len = $cache_obj["tot_len"]; } catch (Exception $e) { $points_maps = ''; $points_x_time = ''; $points_x_lat = ''; $points_x_lon = ''; $points_graph_dist = ''; $points_graph_ele = ''; $points_graph_speed = ''; $points_graph_hr = ''; $points_graph_atemp = ''; $points_graph_cad = ''; $points_graph_grade = ''; $waypoints= ''; $max_ele = 0; $min_ele = 0; $max_time = 0; $min_time = 0; $total_ele_up = 0; $total_ele_down = 0; $avg_speed = 0; $tot_len = 0; } } $isGpxUrl = (preg_match('/^(http(s)?\:\/\/)/', trim($gpx)) == 1); if ((!isset($points_maps) || $points_maps == '') && $gpx != '') { //if (true) { $sitePath = sitePath(); $gpx = trim($gpx); if ($isGpxUrl == true) { $gpx = downloadRemoteFile($gpx); } else { $gpx = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $gpx); $gpx = $sitePath . $gpx; } if ($gpx == '') { return "No gpx found"; } $points = getPoints( $gpx, $pointsoffset, $donotreducegpx, $distanceType); $points_maps = ''; $points_graph_dist = ''; $points_graph_ele = ''; $points_graph_speed = ''; $points_graph_hr = ''; $points_graph_atemp = ''; $points_graph_cad = ''; $points_graph_grade = ''; $waypoints = ''; $points_x_time = $points->dt; $points_x_lat = $points->lat; $points_x_lon = $points->lon; $max_ele = $points->maxEle; $min_ele = $points->minEle; $max_time = $points->maxTime; $min_time = $points->minTime; $total_ele_up = $points->totalEleUp; $total_ele_down = $points->totalEleDown; $avg_speed = $points->avgSpeed; $tot_len = $points->totalLength; if (is_array ($points_x_lat)) foreach(array_keys($points_x_lat) as $i) { $_lat = (float)$points_x_lat[$i]; $_lon = (float)$points_x_lon[$i]; if ( $_lat == 0 && $_lon == 0 ) { $points_maps .= 'null,'; $points_graph_dist .= 'null,'; $points_graph_ele .= 'null,'; if ($showSpeed == true) $points_graph_speed .= 'null,'; if ($showHr == true) $points_graph_hr .= 'null,'; if ($showAtemp == true) $points_graph_atemp .= 'null,'; if ($showCad == true) $points_graph_cad .= 'null,'; if ($showGrade == true) $points_graph_grade .= 'null,'; } else { $points_maps .= '['.number_format((float)$points_x_lat[$i], 7 , '.' , '' ).','.number_format((float)$points_x_lon[$i], 7 , '.' , '' ).'],'; $_ele = (float)$points->ele[$i]; $_dist = (float)$points->dist[$i]; if ($uom == '1') { // Miles and feet $_dist *= 0.000621371192; $_ele *= 3.2808399; } else if ($uom == '2') { // meters / kilometers $_dist = (float)($_dist / 1000); } else if ($uom == '3') { // meters / kilometers / nautical miles $_dist = (float)($_dist / 1000 / 1.852); } else if ($uom == '4') { // meters / miles $_dist *= 0.000621371192; } else if ($uom == '5') { // meters / kilometers / nautical miles and feet $_dist = (float)($_dist / 1000 / 1.852); $_ele *= 3.2808399; } $points_graph_dist .= number_format ( $_dist , 2 , '.' , '' ).','; $points_graph_ele .= number_format ( $_ele , 2 , '.' , '' ).','; if ($showSpeed == true) { $_speed = (float)$points->speed[$i]; $points_graph_speed .= convertSpeed($_speed,$uomspeed).','; } if ($showHr == true) { $points_graph_hr .= number_format ( $points->hr[$i] , 2 , '.' , '' ).','; } if ($showAtemp == true) { $points_graph_atemp .= number_format ( $points->atemp[$i] , 1 , '.' , '' ).','; } if ($showCad == true) { $points_graph_cad .= number_format ( $points->cad[$i] , 2 , '.' , '' ).','; } if ($showGrade == true) { $points_graph_grade .= number_format ( $points->grade[$i] , 2 , '.' , '' ).','; } } } if ($uom == '1') { // Miles and feet $tot_len = round($tot_len * 0.000621371192, 2)." mi"; $max_ele = round($max_ele * 3.2808399, 0)." ft"; $min_ele = round($min_ele * 3.2808399, 0)." ft"; $total_ele_up = round($total_ele_up * 3.2808399, 0)." ft"; $total_ele_down = round($total_ele_down * 3.2808399, 0)." ft"; } else if ($uom == '2') { // meters / kilometers $tot_len = round($tot_len / 1000, 2)." km"; $max_ele = round($max_ele, 0) ." m"; $min_ele = round($min_ele, 0) ." m"; $total_ele_up = round($total_ele_up, 0) ." m"; $total_ele_down = round($total_ele_down, 0) ." m"; } else if ($uom == '3') { // meters / kilometers / nautical miles $tot_len = round($tot_len / 1000/1.852, 2)." NM"; $max_ele = round($max_ele, 0) ." m"; $min_ele = round($min_ele, 0) ." m"; $total_ele_up = round($total_ele_up, 0) ." m"; $total_ele_down = round($total_ele_down, 0) ." m"; } else if ($uom == '4') { // meters / kilometers / nautical miles $tot_len = round($tot_len * 0.000621371192, 2)." mi"; $max_ele = round($max_ele, 0) ." m"; $min_ele = round($min_ele, 0) ." m"; $total_ele_up = round($total_ele_up, 0) ." m"; $total_ele_down = round($total_ele_down, 0) ." m"; } else if ($uom == '5') { // meters / kilometers / nautical miles and feet $tot_len = round($tot_len / 1000/1.852, 2)." NM"; $max_ele = round($max_ele * 3.2808399, 0)." ft"; $min_ele = round($min_ele * 3.2808399, 0)." ft"; $total_ele_up = round($total_ele_up * 3.2808399, 0)." ft"; $total_ele_down = round($total_ele_down * 3.2808399, 0)." ft"; } else { // meters / meters $tot_len = round($tot_len, 0) ." m"; $max_ele = round($max_ele, 0) ." m"; $min_ele = round($min_ele, 0) ." m"; $total_ele_up = round($total_ele_up, 0) ." m"; $total_ele_down = round($total_ele_down, 0) ." m"; } $avg_speed = convertSpeed($avg_speed,$uomspeed,true); $waypoints = '[]'; if ($showW == true) { $wpoints = getWayPoints($gpx); /* foreach ($wpoints as $p) { $waypoints .= '['.number_format ( (float)$p[0] , 7 , '.' , '' ).','.number_format ( (float)$p[1] , 7 , '.' , '' ).',\''.unescape($p[4]).'\',\''.unescape($p[5]).'\',\''.unescape($p[7]).'\'],'; } */ $waypoints = json_encode($wpoints); } if ($showEle == "false") { $points_graph_ele = ""; } $p="/(,|,null,)$/"; $points_maps = preg_replace($p, "", $points_maps); $points_graph_dist = preg_replace($p, "", $points_graph_dist); $points_graph_ele = preg_replace($p, "", $points_graph_ele); $points_graph_speed = preg_replace($p, "", $points_graph_speed); $points_graph_hr = preg_replace($p, "", $points_graph_hr); $points_graph_atemp = preg_replace($p, "", $points_graph_atemp); $points_graph_cad = preg_replace($p, "", $points_graph_cad); $points_graph_grade = preg_replace($p, "", $points_graph_grade); $waypoints = preg_replace($p, "", $waypoints); if (preg_match("/^(0,?)+$/", $points_graph_dist)) $points_graph_dist = ""; if (preg_match("/^(0,?)+$/", $points_graph_ele)) $points_graph_ele = ""; if (preg_match("/^(0,?)+$/", $points_graph_speed)) $points_graph_speed = ""; if (preg_match("/^(0,?)+$/", $points_graph_hr)) $points_graph_hr = ""; if (preg_match("/^(0,?)+$/", $points_graph_hr)) $points_graph_hr = ""; if (preg_match("/^(0,?)+$/", $points_graph_atemp)) $points_graph_atemp = ""; if (preg_match("/^(0,?)+$/", $points_graph_grade)) $points_graph_grade = ""; } $ngimgs_data = ''; if ( $ngGalleries != '' || $ngImages != '' ) { //print_r($points); $ngimgs = getNGGalleryImages($ngGalleries, $ngImages, $points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error); $ngimgs_data =''; foreach ($ngimgs as $img) { $data = $img['data']; $data = str_replace("\n","",$data); $ngimgs_data .= ''.$data.''; } } // Folgende Zeilen hinzugefügt if ($attachments == true) { $attimgs = getAttachedImages($points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error); foreach ($attimgs as $img) { $data = $img['data']; $data = str_replace("\n","",$data); $ngimgs_data .= ''.$data.''; } } if (!($skipcache == true)) { @file_put_contents($gpxcache, serialize(array( "points_maps" => $points_maps, "points_x_time" => $points_x_time, "points_x_lat" => $points_x_lat, "points_x_lon" => $points_x_lon, "points_graph_dist" => $points_graph_dist, "points_graph_ele" => $points_graph_ele, "points_graph_speed" => $points_graph_speed, "points_graph_hr" => $points_graph_hr, "points_graph_atemp" => $points_graph_atemp, "points_graph_cad" => $points_graph_cad, "points_graph_grade" => $points_graph_grade, "waypoints" => $waypoints, "max_ele" => $max_ele, "min_ele" => $min_ele, "total_ele_up" => $total_ele_up, "total_ele_down" => $total_ele_down, "avg_speed" => $avg_speed, "tot_len" => $tot_len, "max_time" => $max_time, "min_time" => $min_time ) ), LOCK_EX); @chmod($gpxcache,0755); } $hideGraph = ($gh == "0" || $gh == "0px"); global $post; $r = $post->ID."_".rand(1,5000000); $output = '