<?php
set_include_path(get_include_path() . PATH_SEPARATOR . './phpseclib0.3.0');
include("Net/SFTP.php");
$sftp = new Net_SFTP('172.17.30.12');
if (!$sftp->login('gis_kf', '@kerinci123'))
{
die("Cannot connect");
}
$path = "/GIS/UAV/Multicopter/$_GET[bu]/$_GET[sector]/$_GET[estate]/$_GET[featno]/$_GET[rotation]/00/Elevation/Contour";
$list = $sftp->nlist($path);
if ($list === false)
{
die("Error listing directory ".$path);
}
$prefix = "Contour.zip";
$matches = preg_grep("/^$prefix.*/i", $list);
if (count($matches) != 1)
{
die("No file or more than one file matches the pattern: ".implode(",", $matches));
}
$matches = array_values($matches);
$filename = $matches[0];
$filepath = $path."/".$filename;
if (!$sftp->get($filepath, $filename))
{
die("Error downloading file ".$filepath);
}
$f="Contour.zip";
$file = ("$f");
$filetype=filetype($file);
$filename=basename($file);
header ("Content-Type: ".$filetype);
header ("Content-Length: ".filesize($file));
header ("Content-Disposition: attachment; filename=".$filename);
readfile($file);
unlink("$f");
echo "<script language='javascript'> alert ('Download Completed '); document.location='https://webgis.fiber.biz.id/webgis/index?search=gis%map%display&elevation_contour=1&estate=$_GET[sector]'; </script>";
?>