Skip to content

Commit

Permalink
Properly read KMLs from file
Browse files Browse the repository at this point in the history
This fixes ticket  #1401 - All KML files are being treated as HTTP URLs, even KMLs on disk.
  • Loading branch information
jetherton committed Sep 3, 2014
1 parent 2613255 commit cceb6f5
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions application/controllers/json.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,28 +646,31 @@ public function layer($layer_id = 0)
$layer_url = $layer->layer_url;
$layer_file = $layer->layer_file;

$content === FALSE;

if ($layer_url != '')
{
// Pull from a URL
$layer_link = $layer_url;
$layer_request = new HttpClient($layer_link);
$content = $layer_request->execute();
if ($content === FALSE)
{
throw new Kohana_Exception($layer_request->get_error_msg());
}
}
else
{
// Pull from an uploaded file
$layer_link = Kohana::config('upload.directory').'/'.$layer_file;
$content = readfile($layer_link);
if ($content === FALSE)
{
throw new Kohana_Exception("Couldn't read KML file: " . $layer_link);
}
}

$layer_request = new HttpClient($layer_link);
$content = $layer_request->execute();

if ($content === FALSE)
{
throw new Kohana_Exception($layer_request->get_error_msg());
}
else
{
echo $content;
}
echo $content;
}
else
{
Expand Down

0 comments on commit cceb6f5

Please sign in to comment.