annotate php/download.php @ 26:9f67e8afa1cc default tip

add new file for new LGService UI project
author Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
date Thu, 28 Sep 2017 23:58:34 +0200
parents f17f43f0a63f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
1 <?php
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
2 /*
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
3 * proxy.php
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
4 *
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
5 * Copyright (c) 2013, Sebastian Kruse. All rights reserved.
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
6 *
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
7 * This library is free software; you can redistribute it and/or
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
10 * version 3 of the License, or (at your option) any later version.
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
11 *
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
12 * This library is distributed in the hope that it will be useful,
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
15 * Lesser General Public License for more details.
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
16 *
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
18 * License along with this library; if not, write to the Free Software
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
20 * MA 02110-1301 USA
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
21 */
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
22
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
23 if (!empty($_POST['file'])) {
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
24
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
25 $file = $_POST['file'];
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
26 $filesize = strlen($file);
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
27
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
28 $mime = array('application/octet-stream');
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
29
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
30 header('Content-Type: '.$mime);
15
f17f43f0a63f bug fixed: download error for data from LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 11
diff changeset
31 header('Content-Disposition: attachment; filename="download.kml"');
11
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
32 header('Content-Transfer-Encoding: binary');
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
33 header('Content-Length: '.sprintf('%d', $filesize));
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
34 header('Expires: 0');
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
35
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
36 // check for IE only headers
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
37 // credits to: cballou, http://stackoverflow.com/questions/2019964/php-form-download-to-zip
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
38 if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
39 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
40 header('Pragma: public');
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
41 } else {
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
42 header('Pragma: no-cache');
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
43 }
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
44
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
45 echo $file;
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
46 }
389cf726303e mode=1, and add download.php
nylin@mpiwg-berlin.mpg.de
parents:
diff changeset
47 ?>