[Mapbender-commits] r2149 - branches/2.4.5/http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Feb 27 07:52:37 EST 2008


Author: astrid_emde
Date: 2008-02-27 07:52:36 -0500 (Wed, 27 Feb 2008)
New Revision: 2149

Added:
   branches/2.4.5/http/php/download.php
Log:
http://www.mapbender.org/ExportMapimage
download script forimages

Added: branches/2.4.5/http/php/download.php
===================================================================
--- branches/2.4.5/http/php/download.php	                        (rev 0)
+++ branches/2.4.5/http/php/download.php	2008-02-27 12:52:36 UTC (rev 2149)
@@ -0,0 +1,70 @@
+<?php
+#$Id$
+# http://www.mapbender.org/ExportMapimage
+#
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+ob_start();
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf"); 
+
+$download = array();
+
+ 
+
+$download["dir"]  = TMPDIR;
+$download["file"] = trim($_REQUEST["download"]);
+
+if(!(bool)$download["file"]) {
+	die("No filename given.");
+}
+
+if((int)strpos($download["file"],"..") !== 0) {
+	die("Illegal filename given.");
+}
+
+ 
+
+if(!file_exists(implode($download)) || !is_readable(implode($download))) {
+	die("An error occured.");
+	
+}
+
+$now_date = date("Ymd_His");
+
+switch(substr($download["file"],-4)) {
+	case ".png":
+		$filename = "map_export__".$now_date.".png";
+		header('Content-Type: image/png');
+		break;
+	case "jpeg":
+		$filename = "map_export__".$now_date.".jpeg";
+		header('Content-Type: image/jpeg');
+		break;
+	case ".tif";
+		$filename = "map_export__".$now_date.".tif";
+		header('Content-Type: image/tif');
+		break;
+	default:
+		die("An error occured.");
+}
+
+header("Content-Disposition: attachment; filename=\"".$filename."\"");
+
+readfile(implode($download));
+
+?>
\ No newline at end of file


Property changes on: branches/2.4.5/http/php/download.php
___________________________________________________________________
Name: svn:keywords
   + HeadURL Id LastChangedBy LastChangedDate LastChangedRevision



More information about the Mapbender_commits mailing list