converted to unix-style eol
[www-register-wizard.git] / helpers / download_helper.php
index 2a555ae..ce2dd48 100644 (file)
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');\r
-/**\r
- * CodeIgniter\r
- *\r
- * An open source application development framework for PHP 4.3.2 or newer\r
- *\r
- * @package            CodeIgniter\r
- * @author             ExpressionEngine Dev Team\r
- * @copyright  Copyright (c) 2008, EllisLab, Inc.\r
- * @license            http://codeigniter.com/user_guide/license.html\r
- * @link               http://codeigniter.com\r
- * @since              Version 1.0\r
- * @filesource\r
- */\r
-\r
-// ------------------------------------------------------------------------\r
-\r
-/**\r
- * CodeIgniter Download Helpers\r
- *\r
- * @package            CodeIgniter\r
- * @subpackage Helpers\r
- * @category   Helpers\r
- * @author             ExpressionEngine Dev Team\r
- * @link               http://codeigniter.com/user_guide/helpers/download_helper.html\r
- */\r
-\r
-// ------------------------------------------------------------------------\r
-\r
-/**\r
- * Force Download\r
- *\r
- * Generates headers that force a download to happen\r
- *\r
- * @access     public\r
- * @param      string  filename\r
- * @param      mixed   the data to be downloaded\r
- * @return     void\r
- */    \r
-if ( ! function_exists('force_download'))\r
-{\r
-       function force_download($filename = '', $data = '')\r
-       {\r
-               if ($filename == '' OR $data == '')\r
-               {\r
-                       return FALSE;\r
-               }\r
-\r
-               // Try to determine if the filename includes a file extension.\r
-               // We need it in order to set the MIME type\r
-               if (FALSE === strpos($filename, '.'))\r
-               {\r
-                       return FALSE;\r
-               }\r
-       \r
-               // Grab the file extension\r
-               $x = explode('.', $filename);\r
-               $extension = end($x);\r
-\r
-               // Load the mime types\r
-               @include(APPPATH.'config/mimes'.EXT);\r
-       \r
-               // Set a default mime if we can't find it\r
-               if ( ! isset($mimes[$extension]))\r
-               {\r
-                       $mime = 'application/octet-stream';\r
-               }\r
-               else\r
-               {\r
-                       $mime = (is_array($mimes[$extension])) ? $mimes[$extension][0] : $mimes[$extension];\r
-               }\r
-       \r
-               // Generate the server headers\r
-               if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))\r
-               {\r
-                       header('Content-Type: "'.$mime.'"');\r
-                       header('Content-Disposition: attachment; filename="'.$filename.'"');\r
-                       header('Expires: 0');\r
-                       header('Cache-Control: must-revalidate, post-check=0, pre-check=0');\r
-                       header("Content-Transfer-Encoding: binary");\r
-                       header('Pragma: public');\r
-                       header("Content-Length: ".strlen($data));\r
-               }\r
-               else\r
-               {\r
-                       header('Content-Type: "'.$mime.'"');\r
-                       header('Content-Disposition: attachment; filename="'.$filename.'"');\r
-                       header("Content-Transfer-Encoding: binary");\r
-                       header('Expires: 0');\r
-                       header('Pragma: no-cache');\r
-                       header("Content-Length: ".strlen($data));\r
-               }\r
-       \r
-               exit($data);\r
-       }\r
-}\r
-\r
-\r
-/* End of file download_helper.php */\r
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Download Helpers
+ *
+ * @package            CodeIgniter
+ * @subpackage Helpers
+ * @category   Helpers
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/helpers/download_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Force Download
+ *
+ * Generates headers that force a download to happen
+ *
+ * @access     public
+ * @param      string  filename
+ * @param      mixed   the data to be downloaded
+ * @return     void
+ */    
+if ( ! function_exists('force_download'))
+{
+       function force_download($filename = '', $data = '')
+       {
+               if ($filename == '' OR $data == '')
+               {
+                       return FALSE;
+               }
+
+               // Try to determine if the filename includes a file extension.
+               // We need it in order to set the MIME type
+               if (FALSE === strpos($filename, '.'))
+               {
+                       return FALSE;
+               }
+       
+               // Grab the file extension
+               $x = explode('.', $filename);
+               $extension = end($x);
+
+               // Load the mime types
+               @include(APPPATH.'config/mimes'.EXT);
+       
+               // Set a default mime if we can't find it
+               if ( ! isset($mimes[$extension]))
+               {
+                       $mime = 'application/octet-stream';
+               }
+               else
+               {
+                       $mime = (is_array($mimes[$extension])) ? $mimes[$extension][0] : $mimes[$extension];
+               }
+       
+               // Generate the server headers
+               if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
+               {
+                       header('Content-Type: "'.$mime.'"');
+                       header('Content-Disposition: attachment; filename="'.$filename.'"');
+                       header('Expires: 0');
+                       header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+                       header("Content-Transfer-Encoding: binary");
+                       header('Pragma: public');
+                       header("Content-Length: ".strlen($data));
+               }
+               else
+               {
+                       header('Content-Type: "'.$mime.'"');
+                       header('Content-Disposition: attachment; filename="'.$filename.'"');
+                       header("Content-Transfer-Encoding: binary");
+                       header('Expires: 0');
+                       header('Pragma: no-cache');
+                       header("Content-Length: ".strlen($data));
+               }
+       
+               exit($data);
+       }
+}
+
+
+/* End of file download_helper.php */
 /* Location: ./system/helpers/download_helper.php */
\ No newline at end of file