diff --git a/libraries/classes/Mime.php b/libraries/classes/Mime.php new file mode 100644 index 0000000000..c42293e397 --- /dev/null +++ b/libraries/classes/Mime.php @@ -0,0 +1,39 @@ += 2 && $test[0] == chr(0xff) && $test[1] == chr(0xd8)) { + return 'image/jpeg'; + } + if ($len >= 3 && substr($test, 0, 3) == 'GIF') { + return 'image/gif'; + } + if ($len >= 4 && mb_substr($test, 0, 4) == "\x89PNG") { + return 'image/png'; + } + return 'application/octet-stream'; + } +} diff --git a/libraries/mime.lib.php b/libraries/mime.lib.php deleted file mode 100644 index f1a7757ac0..0000000000 --- a/libraries/mime.lib.php +++ /dev/null @@ -1,30 +0,0 @@ -= 2 && $test[0] == chr(0xff) && $test[1] == chr(0xd8)) { - return 'image/jpeg'; - } - if ($len >= 3 && substr($test, 0, 3) == 'GIF') { - return 'image/gif'; - } - if ($len >= 4 && mb_substr($test, 0, 4) == "\x89PNG") { - return 'image/png'; - } - return 'application/octet-stream'; -} diff --git a/tbl_get_field.php b/tbl_get_field.php index 366dd683e5..526410eea9 100644 --- a/tbl_get_field.php +++ b/tbl_get_field.php @@ -7,6 +7,7 @@ */ use PhpMyAdmin\Core; +use PhpMyAdmin\Mime; /** * Common functions. @@ -15,7 +16,6 @@ use PhpMyAdmin\Core; // data define('PMA_BYPASS_GET_INSTANCE', 1); require_once 'libraries/common.inc.php'; -require_once 'libraries/mime.lib.php'; /* Check parameters */ PhpMyAdmin\Util::checkParameters( @@ -53,7 +53,7 @@ if ($result === false) { Core::downloadHeader( $table . '-' . $_GET['transform_key'] . '.bin', - PMA_detectMIME($result), + Mime::detect($result), strlen($result) ); echo $result; diff --git a/test/libraries/PMA_mime_test.php b/test/classes/MimeTest.php similarity index 64% rename from test/libraries/PMA_mime_test.php rename to test/classes/MimeTest.php index b49bac52be..5d0a09bd8d 100644 --- a/test/libraries/PMA_mime_test.php +++ b/test/classes/MimeTest.php @@ -1,48 +1,45 @@ assertEquals( - PMA_detectMIME($test), + Mime::detect($test), $output ); } /** - * Provider for testPMA_detectMIME + * Provider for testDetect * - * @return array data for testPMA_detectMIME + * @return array data for testDetect */ - public function providerForTestDetectMIME() + public function providerForTestDetect() { return array( array(