Example #1
0
File: Http.php Project: jbzoo/utils
 /**
  * Transmit headers that force a browser to display the download file dialog.
  * Cross browser compatible. Only fires if headers have not already been sent.
  *
  * @param string $filename The name of the filename to display to browsers
  * @return boolean
  *
  * @codeCoverageIgnore
  */
 public static function download($filename)
 {
     if (!headers_sent()) {
         while (@ob_end_clean()) {
             // noop
         }
         // required for IE, otherwise Content-disposition is ignored
         if (Sys::iniGet('zlib.output_compression')) {
             Sys::iniSet('zlib.output_compression', 'Off');
         }
         Sys::setTime(0);
         // Set headers
         header('Pragma: public');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Cache-Control: private', false);
         header('Content-Disposition: attachment; filename="' . basename(str_replace('"', '', $filename)) . '";');
         header('Content-Type: application/force-download');
         header('Content-Transfer-Encoding: binary');
         header('Content-Length: ' . filesize($filename));
         // output file
         if (Sys::isFunc('fpassthru')) {
             $handle = fopen($filename, 'rb');
             fpassthru($handle);
             fclose($handle);
         } else {
             echo file_get_contents($filename);
         }
         return true;
     }
     return false;
 }
Example #2
0
File: Str.php Project: jbzoo/utils
 /**
  * Check is mbstring oeverload standard functions
  *
  * @return int
  */
 public static function isOverload()
 {
     if (self::isMBString()) {
         return (int) Sys::iniGet('mbstring.func_overload') & MB_OVERLOAD_STRING;
     }
     // @codeCoverageIgnoreStart
     return false;
     // @codeCoverageIgnoreEnd
 }