diff options
author | Simon Rettberg | 2013-11-07 17:10:43 +0100 |
---|---|---|
committer | Simon Rettberg | 2013-11-07 17:10:43 +0100 |
commit | 8ae2b52e4db45f26c32a4ad9bc65494480936cbf (patch) | |
tree | 804bcfba15cdb7ff9c22b211adaf1d096a649559 /apis | |
parent | Working on download of remote configs (diff) | |
download | slx-admin-8ae2b52e4db45f26c32a4ad9bc65494480936cbf.tar.gz slx-admin-8ae2b52e4db45f26c32a4ad9bc65494480936cbf.tar.xz slx-admin-8ae2b52e4db45f26c32a4ad9bc65494480936cbf.zip |
Make download work
Diffstat (limited to 'apis')
-rw-r--r-- | apis/download.inc.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/apis/download.inc.php b/apis/download.inc.php index 9ba0f008..4be67521 100644 --- a/apis/download.inc.php +++ b/apis/download.inc.php @@ -21,13 +21,19 @@ case 'tgz': default: die('Invalid download type'); } +@mkdir($local, 0755, true); if (file_exists($local . '/' . $file) && !isset($_REQUEST['exec'])) { - echo 'FILE EXISTS LOCALLY I SHOULD ASK FOR OVERWRITE NOW'; + echo Render::parse('download-overwrite', array('file' => $file, 'id' => $id, 'query' => $_SERVER['REQUEST_URI']));; exit(0); } -sleep(2); +$ret = Util::downloadToFile($local . '/' . $file, $remote . '/' . $file, 20, $code); +if ($ret === false || $code < 200 || $code >= 300) { + @unlink($local . '/' . $file); + echo Render::parse('download-error', array('file' => $file, 'remote' => $remote, 'code' => $code)); + exit(0); +} // No execution - just return dialog echo Render::parse('download-complete', array('file' => $file)); |