Skip to content

Commit cceb6f5

Browse files
committed
Properly read KMLs from file
This fixes ticket #1401 - All KML files are being treated as HTTP URLs, even KMLs on disk.
1 parent 2613255 commit cceb6f5

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

application/controllers/json.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -646,28 +646,31 @@ public function layer($layer_id = 0)
646646
$layer_url = $layer->layer_url;
647647
$layer_file = $layer->layer_file;
648648

649+
$content === FALSE;
650+
649651
if ($layer_url != '')
650652
{
651653
// Pull from a URL
652654
$layer_link = $layer_url;
655+
$layer_request = new HttpClient($layer_link);
656+
$content = $layer_request->execute();
657+
if ($content === FALSE)
658+
{
659+
throw new Kohana_Exception($layer_request->get_error_msg());
660+
}
653661
}
654662
else
655663
{
656664
// Pull from an uploaded file
657665
$layer_link = Kohana::config('upload.directory').'/'.$layer_file;
666+
$content = readfile($layer_link);
667+
if ($content === FALSE)
668+
{
669+
throw new Kohana_Exception("Couldn't read KML file: " . $layer_link);
670+
}
658671
}
659672

660-
$layer_request = new HttpClient($layer_link);
661-
$content = $layer_request->execute();
662-
663-
if ($content === FALSE)
664-
{
665-
throw new Kohana_Exception($layer_request->get_error_msg());
666-
}
667-
else
668-
{
669-
echo $content;
670-
}
673+
echo $content;
671674
}
672675
else
673676
{

0 commit comments

Comments
 (0)