common.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4.0 |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 2002 Active Fish Group |
  7. // +----------------------------------------------------------------------+
  8. // | Authors: Kelvin Jones <kelvin@kelvinjones.co.uk> |
  9. // +----------------------------------------------------------------------+
  10. //
  11. // $Id: common.php 1438 2006-10-29 13:26:42Z b4rt $
  12. // check to avoid multiple including of class
  13. if (!defined('vlibCommonClassLoaded')) {
  14. define('vlibCommonClassLoaded', 1);
  15. /**
  16. * vlibCommon is a class which contains generic funtions which can be used
  17. * in more than 1 class.
  18. *
  19. * @since 22/04/2002
  20. * @author Kelvin Jones <kelvin@kelvinjones.co.uk>
  21. * @package vLIB
  22. * @access private
  23. */
  24. class vlibCommon {
  25. /** FUNCTION: getMimeType
  26. * This function return a mime-type for the name of the file given.
  27. * This is based purely on the file name and is derived from the
  28. * array contained in vlibCommon/mime_types.php.
  29. *
  30. * @param string $filename name of file i.e. results.xls
  31. * @return string mime-type
  32. * @access private
  33. */
  34. function getMimeType ($filename) {
  35. if (empty($filename)) return false;
  36. // lets get the mime-type
  37. require(dirname(__FILE__).'/mime_types.php');
  38. $extarr = explode('.', $filename);
  39. $ext = array_pop($extarr);
  40. if (!empty($VLIB_MIMETYPES[$ext])) {
  41. return $VLIB_MIMETYPES[$ext];
  42. }
  43. else {
  44. return $VLIB_MIMETYPES['default'];
  45. }
  46. }
  47. } // << end class vlibCommon
  48. } // << end if(!defined())..
  49. ?>