mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-26 12:51:52 +02:00
format and fix Id string
This commit is contained in:
parent
f61e52640f
commit
32b2d29415
@ -1,28 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
* phpGroupWare - phpGroupWare API - mime magic *
|
* phpGroupWare - phpGroupWare API - mime magic *
|
||||||
* http://www.phpgroupware.org *
|
* http://www.phpgroupware.org *
|
||||||
* This program is part of the GNU project, see http://www.gnu.org *
|
* This program is part of the GNU project, see http://www.gnu.org *
|
||||||
* *
|
* *
|
||||||
* Originally taken from the Horde Framework http://horde.org *
|
* Originally taken from the Horde Framework http://horde.org *
|
||||||
* *
|
* *
|
||||||
* Copyright 1999-2003 Anil Madhavapeddy <anil@recoil.org> *
|
* Copyright 1999-2003 Anil Madhavapeddy <anil@recoil.org> *
|
||||||
* Copyright 2002-2003 Michael Slusarz <slusarz@bigworm.colorado.edu> *
|
* Copyright 2002-2003 Michael Slusarz <slusarz@bigworm.colorado.edu> *
|
||||||
* Copyright 2003 Free Software Foundation, Inc. *
|
* Copyright 2003 Free Software Foundation, Inc. *
|
||||||
* *
|
* *
|
||||||
* Ported to phpGroupWare by Dave Hall - dave.hall@mbox.com.au *
|
* Ported to phpGroupWare by Dave Hall - dave.hall@mbox.com.au *
|
||||||
* Note: this class was relicensed as GPL by Dave Hall - all mods GPL *
|
* Note: this class was relicensed as GPL by Dave Hall - all mods GPL *
|
||||||
* -------------------------------------------- *
|
* -------------------------------------------- *
|
||||||
* This program is Free Software; you can redistribute it and/or *
|
* This program is Free Software; you can redistribute it and/or *
|
||||||
* modify it under the terms of the GNU General Public License as *
|
* modify it under the terms of the GNU General Public License as *
|
||||||
* published by the Free Software Foundation; either version 2 of *
|
* published by the Free Software Foundation; either version 2 of *
|
||||||
* the License, or (at your option) any later version. *
|
* the License, or (at your option) any later version. *
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
/* $id */
|
|
||||||
|
/* $Id */
|
||||||
|
|
||||||
class mime_magic
|
class mime_magic
|
||||||
{
|
{
|
||||||
|
|
||||||
//extension to mime type map
|
//extension to mime type map
|
||||||
var $mime_extension_map;
|
var $mime_extension_map;
|
||||||
|
|
||||||
@ -41,7 +41,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* Load the map values into the instance arrays
|
* Load the map values into the instance arrays
|
||||||
* @author skwashd
|
* @author skwashd
|
||||||
@ -51,12 +51,12 @@
|
|||||||
$this->mime_extension_map = $this->get_mime_ext_map();
|
$this->mime_extension_map = $this->get_mime_ext_map();
|
||||||
$this->mime_magic_file = $this->get_mime_magic_file();
|
$this->mime_magic_file = $this->get_mime_magic_file();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to convert a file extension to a MIME type
|
* Attempt to convert a file extension to a MIME type
|
||||||
*
|
*
|
||||||
* This is the simplest MIME type guessing function - rough but fast.
|
* This is the simplest MIME type guessing function - rough but fast.
|
||||||
* If the MIME type is not found then 'application/octet-stream'
|
* If the MIME type is not found then 'application/octet-stream'
|
||||||
* is returned.
|
* is returned.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
@ -84,7 +84,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to convert a filename to a MIME type, based on the
|
* Attempt to convert a filename to a MIME type, based on the
|
||||||
* global and application specific config files.
|
* global and application specific config files.
|
||||||
@ -114,7 +114,7 @@
|
|||||||
{
|
{
|
||||||
return $this->filename2mime($filename);
|
return $this->filename2mime($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to convert a MIME type to a file extension, based
|
* Attempt to convert a MIME type to a file extension, based
|
||||||
* on the global Horde and application specific config files.
|
* on the global Horde and application specific config files.
|
||||||
@ -127,7 +127,6 @@
|
|||||||
*
|
*
|
||||||
* @return string The file extension of the MIME type.
|
* @return string The file extension of the MIME type.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function mime2ext($type)
|
function mime2ext($type)
|
||||||
{
|
{
|
||||||
$key = array_search($type, $this->mime_extension_map);
|
$key = array_search($type, $this->mime_extension_map);
|
||||||
@ -204,9 +203,9 @@
|
|||||||
//nothing we can do but bail out
|
//nothing we can do but bail out
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mt_srand(time());
|
mt_srand(time());
|
||||||
$filename = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP
|
$filename = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP
|
||||||
. md5( time() + mt_rand() ) . '.tmp';
|
. md5( time() + mt_rand() ) . '.tmp';
|
||||||
|
|
||||||
$fp = @fopen($filename, 'ab');
|
$fp = @fopen($filename, 'ab');
|
||||||
@ -225,10 +224,10 @@
|
|||||||
chmod($filename, 0600); //just to be cautious
|
chmod($filename, 0600); //just to be cautious
|
||||||
|
|
||||||
$mime = $this->analyze_file($filename);
|
$mime = $this->analyze_file($filename);
|
||||||
|
|
||||||
unlink($filename);//remove the temp file
|
unlink($filename);//remove the temp file
|
||||||
|
|
||||||
return $mime;
|
return $mime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user