Settings'; // add the link to the list array_unshift($links, $settings_link); } return $links; } function enqueue_WP_GPX_Maps_scripts() { ?> '.$data.''; } } if ($points_maps == '' && $gpx != '') { $sitePath = sitePath(); $gpx = trim($gpx); if (strpos($gpx, "http://") !== 0) { $gpx = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $gpx); $gpx = $sitePath . $gpx; } else { $gpx = downloadRemoteFile($gpx); } if ($gpx == '') { return "No gpx found"; } $points = getPoints( $gpx, $pointsoffset, $donotreducegpx); $points_maps = ''; $points_graph = ''; $waypoints = ''; foreach ($points as $p) { $points_maps .= '['.(float)$p[0].','.(float)$p[1].'],'; $_dist = $p[3]; $_ele = $p[2]; if ($uom == '1') { // Miles and feet $_dist *= 0.000621371192; $_ele *= 3.2808399; } else if ($uom == '2') { // meters / kilometers $_dist = $_dist/1000; } if ($showSpeed == true) { $_speed = $p[4]; // dafault m/s if ($uomspeed == '2') // miles/h { $_speed *= 2.2369362920544025; } else if ($uomspeed == '1') // km/h { $_speed *= 3.6; } $points_graph .= '['.$_dist.','.$_ele.','.$_speed.'],'; } else { $points_graph .= '['.$_dist.','.$_ele.'],'; } } if ($showW == true) { $wpoints = getWayPoints($gpx); foreach ($wpoints as $p) { $waypoints .= '['.(float)$p[0].','.(float)$p[1].',\''.unescape($p[4]).'\',\''.unescape($p[5]).'\',\''.unescape($p[7]).'\'],'; } } $p="/,$/"; $points_maps = preg_replace($p, "", $points_maps); $points_graph = preg_replace($p, "", $points_graph); $waypoints = preg_replace($p, "", $waypoints); if (preg_match("/^(\[0,0\],?)+$/", $points_graph)) { $points_graph = ""; } } @file_put_contents($gpxcache, serialize(array( "points_maps" => $points_maps, "points_graph" => $points_graph, "waypoints" => $waypoints, "ngimgs" => $ngimgs_data) ), LOCK_EX); @chmod($gpxcache,0755); $output = '
'; return $output; } function downloadRemoteFile($remoteFile) { try { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $remoteFile); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); $resp = curl_exec($ch); curl_close($ch); $tmpfname = tempnam ( '/tmp', 'gpx' ); $fp = fopen($tmpfname, "w"); fwrite($fp, $resp); fclose($fp); return $tmpfname; } catch (Exception $e) { return ''; } } function unescape($value) { $value = str_replace("'", "\'", $value); $value = str_replace(array("\n","\r"), "", $value); return $value; } function WP_GPX_Maps_install() { add_option("wpgpxmaps_width", '100%', '', 'yes'); add_option("wpgpxmaps_graph_height", '200px', '', 'yes'); add_option("wpgpxmaps_height", '450px', '', 'yes'); add_option('wpgpxmaps_map_type','HYBRID','','yes'); add_option('wpgpxmaps_show_waypoint','','','yes'); add_option('wpgpxmaps_show_speed','','','yes'); add_option('wpgpxmaps_pointsoffset','10','','yes'); add_option('wpgpxmaps_donotreducegpx','true','','yes'); add_option("wpgpxmaps_unit_of_measure", '0', '', 'yes'); add_option("wpgpxmaps_unit_of_measure_speed", '0', '', 'yes'); add_option("wpgpxmaps_graph_line_color", '#3366cc', '', 'yes'); add_option("wpgpxmaps_graph_line_color_speed", '#ff0000', '', 'yes'); add_option("wpgpxmaps_map_line_color", '#3366cc', '', 'yes'); add_option("wpgpxmaps_graph_offset_from1", '', '', 'yes'); add_option("wpgpxmaps_graph_offset_to1", '', '', 'yes'); add_option("wpgpxmaps_graph_offset_from2", '', '', 'yes'); add_option("wpgpxmaps_graph_offset_to2", '', '', 'yes'); add_option("wpgpxmaps_map_start_icon", '', '', 'yes'); add_option("wpgpxmaps_map_end_icon", '', '', 'yes'); add_option("wpgpxmaps_map_current_icon", '', '', 'yes'); add_option("wpgpxmaps_map_nggallery", '', '', 'yes'); } function WP_GPX_Maps_remove() { delete_option('wpgpxmaps_width'); delete_option('wpgpxmaps_graph_height'); delete_option('wpgpxmaps_height'); delete_option('wpgpxmaps_map_type'); delete_option('wpgpxmaps_show_waypoint'); delete_option('wpgpxmaps_show_speed'); delete_option('wpgpxmaps_pointsoffset'); delete_option('wpgpxmaps_donotreducegpx'); delete_option('wpgpxmaps_unit_of_measure'); delete_option('wpgpxmaps_unit_of_measure_speed'); delete_option('wpgpxmaps_graph_line_color'); delete_option('wpgpxmaps_map_line_color'); delete_option('wpgpxmaps_graph_line_color_speed'); delete_option('wpgpxmaps_graph_offset_from1'); delete_option('wpgpxmaps_graph_offset_to1'); delete_option('wpgpxmaps_graph_offset_from2'); delete_option('wpgpxmaps_graph_offset_to2'); delete_option('wpgpxmaps_map_start_icon'); delete_option('wpgpxmaps_map_end_icon'); delete_option('wpgpxmaps_map_current_icon'); delete_option('wpgpxmaps_map_nggallery'); } ?>