Skip to content

Instantly share code, notes, and snippets.

@cosmocatalano
Last active August 14, 2017 16:18
Show Gist options
  • Save cosmocatalano/45180d86bf476cee11ec to your computer and use it in GitHub Desktop.
Save cosmocatalano/45180d86bf476cee11ec to your computer and use it in GitHub Desktop.
<?php
function fix_file($source) {
$problems = array(
"/(<trkpt.*)\/>/",
"/<\/trkseg>\s*<trkseg>/"
);
$fixes = array(
"$1></trkpt>",
"",
);
$fixed_file = preg_replace($problems, $fixes, $source);
return $fixed_file;
}
$source = file_get_contents($_FILES['userfile']['tmp_name']); ;
$output = fix_file($source);
header('Content-Disposition: attachment; filename="movescount_ready.gpx"');
header('Content-type: application/gpx+xml');
echo $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment