This commit is contained in:
bastianonm 2012-01-24 17:05:59 +00:00
parent b39554b2b4
commit 4d1ef1e7c3
3 changed files with 35 additions and 6 deletions

View File

@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=basti
Tags: maps, gpx, gps, graph, google maps, google chart, track, garmin
Requires at least: 2.0.0
Tested up to: 3.3
Stable tag: 1.1.2
Stable tag: 1.1.3
License: GPLv2 or later
Draws a gpx track with altitude graph
@ -34,7 +34,7 @@ Supported gpx namespace are:
1. Activate the plugin through the 'Plugins' menu in WordPress
1. Add the shortcode [sgpx gpx=">relative path to your gpx<"]
1. Add the shortcode [sgpx gpx=">relative path to your gpx<"] or [sgpx gpx=">http://somesite.com/files/yourfile.gpx<"]
== Frequently Asked Questions ==
@ -72,6 +72,8 @@ Yes!
2. Admin area
== Changelog ==
= 1.1.3 =
* Allowed gpx files from http url
= 1.1.2 =
* Improved page load time
* Added compatibility to Wordpress Multisite (WPMU)
@ -107,6 +109,7 @@ Yes!
* Initial release.
== Upgrade Notice ==
= 1.1.3 =
= 1.1.2 =
= 1.1.1 =
= 1.1.0 =

View File

@ -3,7 +3,7 @@
Plugin Name: WP-GPX-Maps
Plugin URI: http://www.darwinner.it/
Description: Draws a gpx track with altitude graph
Version: 1.1.2
Version: 1.1.3
Author: Bastianon Massimo
Author URI: http://www.pedemontanadelgrappa.it/
License: GPL
@ -86,9 +86,17 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$gpx = trim($gpx);
$gpx = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $gpx);
if (strpos($gpx, "http://") !== 0)
{
$gpx = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $gpx);
$gpx = $sitePath . $gpx;
}
else
{
$gpx = downloadRemoteFile($gpx);
print_r($gpx);
}
$gpx = $sitePath . $gpx;
$points = getPoints( $gpx, $pointsoffset, $donotreducegpx);
$points_maps = '';
@ -133,6 +141,24 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
return $output;
}
function downloadRemoteFile($remoteFile)
{
$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;
}
function unescape($value)
{
$value = str_replace("'", "\'", $value);

View File

@ -25,7 +25,7 @@
function getPoints($gpxPath,$gpxOffset = 10, $donotreducegpx)
{
$points = array();
$dist=0;