改名
This commit is contained in:
+113
@@ -32,6 +32,119 @@ if (!function_exists('make')) {
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('exif_imagetype')) {
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return string
|
||||
*/
|
||||
function exif_imagetype($name)
|
||||
{
|
||||
return get_file_extension($name);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_file_extension')) {
|
||||
|
||||
function get_file_extension($filename)
|
||||
{
|
||||
$mime_types = array(
|
||||
'txt' => 'text/plain',
|
||||
'htm' => 'text/html',
|
||||
'html' => 'text/html',
|
||||
'php' => 'text/html',
|
||||
'css' => 'text/css',
|
||||
'js' => 'application/javascript',
|
||||
'json' => 'application/json',
|
||||
'xml' => 'application/xml',
|
||||
'swf' => 'application/x-shockwave-flash',
|
||||
'flv' => 'video/x-flv',
|
||||
|
||||
// images
|
||||
'png' => 'image/png',
|
||||
'jpeg' => 'image/jpeg',
|
||||
'gif' => 'image/gif',
|
||||
'bmp' => 'image/bmp',
|
||||
'ico' => 'image/vnd.microsoft.icon',
|
||||
'tiff' => 'image/tiff',
|
||||
'svg' => 'image/svg+xml',
|
||||
|
||||
// archives
|
||||
'zip' => 'application/zip',
|
||||
'rar' => 'application/x-rar-compressed',
|
||||
'exe' => 'application/x-msdownload',
|
||||
'msi' => 'application/x-msdownload',
|
||||
'cab' => 'application/vnd.ms-cab-compressed',
|
||||
|
||||
// audio/video
|
||||
'mp3' => 'audio/mpeg',
|
||||
'qt' => 'video/quicktime',
|
||||
'mov' => 'video/quicktime',
|
||||
|
||||
// adobe
|
||||
'pdf' => 'application/pdf',
|
||||
'psd' => 'image/vnd.adobe.photoshop',
|
||||
'ai' => 'application/postscript',
|
||||
'eps' => 'application/postscript',
|
||||
'ps' => 'application/postscript',
|
||||
|
||||
// ms office
|
||||
'doc' => 'application/msword',
|
||||
'rtf' => 'application/rtf',
|
||||
'xls' => 'application/vnd.ms-excel',
|
||||
'ppt' => 'application/vnd.ms-powerpoint',
|
||||
|
||||
// open office
|
||||
'odt' => 'application/vnd.oasis.opendocument.text',
|
||||
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
|
||||
);
|
||||
|
||||
$explode = explode('.', $filename);
|
||||
$ext = strtolower(array_pop($explode));
|
||||
if (array_key_exists($ext, $mime_types)) {
|
||||
return $ext;
|
||||
} elseif (function_exists('finfo_open')) {
|
||||
$fInfo = finfo_open(FILEINFO_MIME);
|
||||
$mimeType = finfo_file($fInfo, $filename);
|
||||
finfo_close($fInfo);
|
||||
$mimeType = current(explode('; ', $mimeType));
|
||||
if (($search = array_search($mimeType, $mime_types)) == false) {
|
||||
return $mimeType;
|
||||
}
|
||||
return $search;
|
||||
} else {
|
||||
return 'application/octet-stream';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('request')) {
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
function request(): \HttpServer\Http\Request
|
||||
{
|
||||
if (!Context::hasContext('request')) {
|
||||
return make('request', \HttpServer\Http\Request::class);
|
||||
}
|
||||
return Context::getContext('request');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('Input')) {
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
function Input()
|
||||
{
|
||||
return request()->params;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('storage')) {
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user