wp/wp-includes/ID3/getid3.php
author ymh <ymh.work@gmail.com>
Fri, 05 Sep 2025 18:40:08 +0200
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
permissions -rw-r--r--
Add CLAUDE.md documentation and sync WordPress core files - Add comprehensive CLAUDE.md documentation file with project architecture, development setup, database operations, WordPress CLI usage, file sync procedures, and Mercurial commands - Update WordPress core files from wordpress/ to wp/ directory - Sync latest WordPress admin interface, includes, and core functionality - Update plugins: portfolio plugin with latest BWS framework and fancybox integration - Maintain custom configuration and theme files 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/////////////////////////////////////////////////////////////////
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
/// getID3() by James Heinrich <info@getid3.org>               //
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     4
//  available at https://github.com/JamesHeinrich/getID3       //
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     5
//            or https://www.getid3.org                        //
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     6
//            or http://getid3.sourceforge.net                 //
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
//                                                             //
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
// Please see readme.txt for more information                  //
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
//                                                            ///
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
/////////////////////////////////////////////////////////////////
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
// define a constant rather than looking up every time it is needed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
if (!defined('GETID3_OS_ISWINDOWS')) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
	define('GETID3_OS_ISWINDOWS', (stripos(PHP_OS, 'WIN') === 0));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
// Get base path of getID3() - ONCE
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
if (!defined('GETID3_INCLUDEPATH')) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
	define('GETID3_INCLUDEPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    20
if (!defined('ENT_SUBSTITUTE')) { // PHP5.3 adds ENT_IGNORE, PHP5.4 adds ENT_SUBSTITUTE
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    21
	define('ENT_SUBSTITUTE', (defined('ENT_IGNORE') ? ENT_IGNORE : 8));
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    22
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    24
/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    25
https://www.getid3.org/phpBB3/viewtopic.php?t=2114
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    26
If you are running into a the problem where filenames with special characters are being handled
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    27
incorrectly by external helper programs (e.g. metaflac), notably with the special characters removed,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    28
and you are passing in the filename in UTF8 (typically via a HTML form), try uncommenting this line:
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    29
*/
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    30
//setlocale(LC_CTYPE, 'en_US.UTF-8');
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    31
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
// attempt to define temp dir as something flexible but reliable
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
$temp_dir = ini_get('upload_tmp_dir');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
if ($temp_dir && (!is_dir($temp_dir) || !is_readable($temp_dir))) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
	$temp_dir = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    37
if (!$temp_dir && function_exists('sys_get_temp_dir')) { // sys_get_temp_dir added in PHP v5.2.1
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
	// sys_get_temp_dir() may give inaccessible temp dir, e.g. with open_basedir on virtual hosts
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
	$temp_dir = sys_get_temp_dir();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    41
$temp_dir = @realpath($temp_dir); // see https://github.com/JamesHeinrich/getID3/pull/10
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
$open_basedir = ini_get('open_basedir');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
if ($open_basedir) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
	// e.g. "/var/www/vhosts/getid3.org/httpdocs/:/tmp/"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
	$temp_dir     = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $temp_dir);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
	$open_basedir = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $open_basedir);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
	if (substr($temp_dir, -1, 1) != DIRECTORY_SEPARATOR) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
		$temp_dir .= DIRECTORY_SEPARATOR;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
	$found_valid_tempdir = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
	$open_basedirs = explode(PATH_SEPARATOR, $open_basedir);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
	foreach ($open_basedirs as $basedir) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
		if (substr($basedir, -1, 1) != DIRECTORY_SEPARATOR) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
			$basedir .= DIRECTORY_SEPARATOR;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
		}
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    56
		if (strpos($temp_dir, $basedir) === 0) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
			$found_valid_tempdir = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
	if (!$found_valid_tempdir) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
		$temp_dir = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
	unset($open_basedirs, $found_valid_tempdir, $basedir);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
if (!$temp_dir) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
	$temp_dir = '*'; // invalid directory name should force tempnam() to use system default temp dir
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
// $temp_dir = '/something/else/';  // feel free to override temp dir here if it works better for your system
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    70
if (!defined('GETID3_TEMP_DIR')) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    71
	define('GETID3_TEMP_DIR', $temp_dir);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    72
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
unset($open_basedir, $temp_dir);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
// End: Defines
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
class getID3
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
{
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    80
	/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    81
	 * Settings
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    82
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    83
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    84
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    85
	 * CASE SENSITIVE! - i.e. (must be supported by iconv()). Examples:  ISO-8859-1  UTF-8  UTF-16  UTF-16BE
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    86
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    87
	 * @var string
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    88
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    89
	public $encoding        = 'UTF-8';
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    90
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    91
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    92
	 * Should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'EUC-CN' or 'CP1252'
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    93
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    94
	 * @var string
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    95
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    96
	public $encoding_id3v1  = 'ISO-8859-1';
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    97
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    98
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    99
	 * ID3v1 should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'Windows-1251' or 'KOI8-R'. If true attempt to detect these encodings, but may return incorrect values for some tags actually in ISO-8859-1 encoding
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   100
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   101
	 * @var bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   102
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   103
	public $encoding_id3v1_autodetect  = false;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   104
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   105
	/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   106
	 * Optional tag checks - disable for speed.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   107
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   109
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   110
	 * Read and process ID3v1 tags
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   111
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   112
	 * @var bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   113
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   114
	public $option_tag_id3v1         = true;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   115
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   116
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   117
	 * Read and process ID3v2 tags
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   118
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   119
	 * @var bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   120
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   121
	public $option_tag_id3v2         = true;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   122
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   123
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   124
	 * Read and process Lyrics3 tags
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   125
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   126
	 * @var bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   127
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   128
	public $option_tag_lyrics3       = true;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   129
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   130
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   131
	 * Read and process APE tags
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   132
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   133
	 * @var bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   134
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   135
	public $option_tag_apetag        = true;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   136
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   137
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   138
	 * Copy tags to root key 'tags' and encode to $this->encoding
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   139
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   140
	 * @var bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   141
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   142
	public $option_tags_process      = true;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   144
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   145
	 * Copy tags to root key 'tags_html' properly translated from various encodings to HTML entities
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   146
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   147
	 * @var bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   148
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   149
	public $option_tags_html         = true;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   150
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   151
	/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   152
	 * Optional tag/comment calculations
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   153
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   155
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   156
	 * Calculate additional info such as bitrate, channelmode etc
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   157
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   158
	 * @var bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   159
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   160
	public $option_extra_info        = true;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   161
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   162
	/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   163
	 * Optional handling of embedded attachments (e.g. images)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   164
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   165
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   166
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   167
	 * Defaults to true (ATTACHMENTS_INLINE) for backward compatibility
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   168
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   169
	 * @var bool|string
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   170
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   171
	public $option_save_attachments  = true;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   172
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   173
	/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   174
	 * Optional calculations
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   175
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   177
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   178
	 * Get MD5 sum of data part - slow
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   179
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   180
	 * @var bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   181
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   182
	public $option_md5_data          = false;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   183
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   184
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   185
	 * Use MD5 of source file if available - only FLAC and OptimFROG
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   186
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   187
	 * @var bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   188
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   189
	public $option_md5_data_source   = false;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   191
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   192
	 * Get SHA1 sum of data part - slow
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   193
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   194
	 * @var bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   195
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   196
	public $option_sha1_data         = false;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   197
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   198
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   199
	 * Check whether file is larger than 2GB and thus not supported by 32-bit PHP (null: auto-detect based on
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   200
	 * PHP_INT_MAX)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   201
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   202
	 * @var bool|null
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   203
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   204
	public $option_max_2gb_check;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   205
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   206
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   207
	 * Read buffer size in bytes
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   208
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   209
	 * @var int
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   210
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
	public $option_fread_buffer_size = 32768;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   213
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   214
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   215
	// module-specific options
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   216
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   217
	/** archive.rar
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   218
	 * if true use PHP RarArchive extension, if false (non-extension parsing not yet written in getID3)
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   219
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   220
	 * @var bool
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   221
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   222
	public $options_archive_rar_use_php_rar_extension = true;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   223
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   224
	/** archive.gzip
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   225
	 * Optional file list - disable for speed.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   226
	 * Decode gzipped files, if possible, and parse recursively (.tar.gz for example).
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   227
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   228
	 * @var bool
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   229
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   230
	public $options_archive_gzip_parse_contents = false;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   231
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   232
	/** audio.midi
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   233
	 * if false only parse most basic information, much faster for some files but may be inaccurate
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   234
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   235
	 * @var bool
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   236
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   237
	public $options_audio_midi_scanwholefile = true;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   238
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   239
	/** audio.mp3
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   240
	 * Forces getID3() to scan the file byte-by-byte and log all the valid audio frame headers - extremely slow,
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   241
	 * unrecommended, but may provide data from otherwise-unusable files.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   242
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   243
	 * @var bool
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   244
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   245
	public $options_audio_mp3_allow_bruteforce = false;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   246
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   247
	/** audio.mp3
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   248
	 * number of frames to scan to determine if MPEG-audio sequence is valid
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   249
	 * Lower this number to 5-20 for faster scanning
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   250
	 * Increase this number to 50+ for most accurate detection of valid VBR/CBR mpeg-audio streams
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   251
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   252
	 * @var int
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   253
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   254
	public $options_audio_mp3_mp3_valid_check_frames = 50;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   255
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   256
	/** audio.wavpack
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   257
	 * Avoid scanning all frames (break after finding ID_RIFF_HEADER and ID_CONFIG_BLOCK,
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   258
	 * significantly faster for very large files but other data may be missed
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   259
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   260
	 * @var bool
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   261
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   262
	public $options_audio_wavpack_quick_parsing = false;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   263
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   264
	/** audio-video.flv
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   265
	 * Break out of the loop if too many frames have been scanned; only scan this
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   266
	 * many if meta frame does not contain useful duration.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   267
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   268
	 * @var int
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   269
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   270
	public $options_audiovideo_flv_max_frames = 100000;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   271
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   272
	/** audio-video.matroska
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   273
	 * If true, do not return information about CLUSTER chunks, since there's a lot of them
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   274
	 * and they're not usually useful [default: TRUE].
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   275
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   276
	 * @var bool
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   277
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   278
	public $options_audiovideo_matroska_hide_clusters    = true;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   279
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   280
	/** audio-video.matroska
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   281
	 * True to parse the whole file, not only header [default: FALSE].
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   282
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   283
	 * @var bool
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   284
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   285
	public $options_audiovideo_matroska_parse_whole_file = false;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   286
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   287
	/** audio-video.quicktime
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   288
	 * return all parsed data from all atoms if true, otherwise just returned parsed metadata
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   289
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   290
	 * @var bool
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   291
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   292
	public $options_audiovideo_quicktime_ReturnAtomData  = false;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   293
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   294
	/** audio-video.quicktime
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   295
	 * return all parsed data from all atoms if true, otherwise just returned parsed metadata
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   296
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   297
	 * @var bool
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   298
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   299
	public $options_audiovideo_quicktime_ParseAllPossibleAtoms = false;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   300
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   301
	/** audio-video.swf
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   302
	 * return all parsed tags if true, otherwise do not return tags not parsed by getID3
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   303
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   304
	 * @var bool
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   305
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   306
	public $options_audiovideo_swf_ReturnAllTagData = false;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   307
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   308
	/** graphic.bmp
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   309
	 * return BMP palette
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   310
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   311
	 * @var bool
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   312
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   313
	public $options_graphic_bmp_ExtractPalette = false;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   314
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   315
	/** graphic.bmp
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   316
	 * return image data
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   317
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   318
	 * @var bool
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   319
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   320
	public $options_graphic_bmp_ExtractData    = false;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   321
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   322
	/** graphic.png
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   323
	 * If data chunk is larger than this do not read it completely (getID3 only needs the first
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   324
	 * few dozen bytes for parsing).
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   325
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   326
	 * @var int
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   327
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   328
	public $options_graphic_png_max_data_bytes = 10000000;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   329
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   330
	/** misc.pdf
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   331
	 * return full details of PDF Cross-Reference Table (XREF)
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   332
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   333
	 * @var bool
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   334
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   335
	public $options_misc_pdf_returnXREF = false;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   336
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   337
	/** misc.torrent
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   338
	 * Assume all .torrent files are less than 1MB and just read entire thing into memory for easy processing.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   339
	 * Override this value if you need to process files larger than 1MB
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   340
	 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   341
	 * @var int
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   342
	 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   343
	public $options_misc_torrent_max_torrent_filesize = 1048576;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   344
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   345
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   346
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
	// Public variables
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   348
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   349
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   350
	 * Filename of file being analysed.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   351
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   352
	 * @var string
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   353
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   354
	public $filename;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   355
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   356
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   357
	 * Filepointer to file being analysed.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   358
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   359
	 * @var resource
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   360
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   361
	public $fp;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   362
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   363
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   364
	 * Result array.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   365
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   366
	 * @var array
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   367
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   368
	public $info;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   369
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   370
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   371
	 * @var string
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   372
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
	public $tempdir = GETID3_TEMP_DIR;
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   374
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   375
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   376
	 * @var int
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   377
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   378
	public $memory_limit = 0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   380
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   381
	 * @var string
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   382
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
	protected $startup_error   = '';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   384
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   385
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   386
	 * @var string
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   387
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
	protected $startup_warning = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   390
	const VERSION           = '1.9.23-202310190849';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
	const FREAD_BUFFER_SIZE = 32768;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
	const ATTACHMENTS_NONE   = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
	const ATTACHMENTS_INLINE = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   396
	/**
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   397
	 * @throws getid3_exception
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   398
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
	public function __construct() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   401
		// Check for PHP version
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   402
		$required_php_version = '5.3.0';
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   403
		if (version_compare(PHP_VERSION, $required_php_version, '<')) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   404
			$this->startup_error .= 'getID3() requires PHP v'.$required_php_version.' or higher - you are running v'.PHP_VERSION."\n";
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   405
			return;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   406
		}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   407
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
		// Check memory
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   409
		$memoryLimit = ini_get('memory_limit');
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   410
		if (preg_match('#([0-9]+) ?M#i', $memoryLimit, $matches)) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
			// could be stored as "16M" rather than 16777216 for example
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   412
			$memoryLimit = $matches[1] * 1048576;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   413
		} elseif (preg_match('#([0-9]+) ?G#i', $memoryLimit, $matches)) { // The 'G' modifier is available since PHP 5.1.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
			// could be stored as "2G" rather than 2147483648 for example
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   415
			$memoryLimit = $matches[1] * 1073741824;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
		}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   417
		$this->memory_limit = $memoryLimit;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   418
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
		if ($this->memory_limit <= 0) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
			// memory limits probably disabled
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
		} elseif ($this->memory_limit <= 4194304) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   422
			$this->startup_error .= 'PHP has less than 4MB available memory and will very likely run out. Increase memory_limit in php.ini'."\n";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
		} elseif ($this->memory_limit <= 12582912) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   424
			$this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini'."\n";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
		// Check safe_mode off
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   428
		if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) { // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.safe_modeDeprecatedRemoved
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
			$this->warning('WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   432
		// phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   433
		if (($mbstring_func_overload = (int) ini_get('mbstring.func_overload')) && ($mbstring_func_overload & 0x02)) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   434
			// http://php.net/manual/en/mbstring.overload.php
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   435
			// "mbstring.func_overload in php.ini is a positive value that represents a combination of bitmasks specifying the categories of functions to be overloaded. It should be set to 1 to overload the mail() function. 2 for string functions, 4 for regular expression functions"
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   436
			// getID3 cannot run when string functions are overloaded. It doesn't matter if mail() or ereg* functions are overloaded since getID3 does not use those.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   437
			// phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   438
			$this->startup_error .= 'WARNING: php.ini contains "mbstring.func_overload = '.ini_get('mbstring.func_overload').'", getID3 cannot run with this setting (bitmask 2 (string functions) cannot be set). Recommended to disable entirely.'."\n";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   441
		// check for magic quotes in PHP < 5.4.0 (when these options were removed and getters always return false)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   442
		if (version_compare(PHP_VERSION, '5.4.0', '<')) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   443
			// Check for magic_quotes_runtime
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   444
			if (function_exists('get_magic_quotes_runtime')) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   445
				// phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_runtimeDeprecated
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   446
				if (get_magic_quotes_runtime()) { // @phpstan-ignore-line
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   447
					$this->startup_error .= 'magic_quotes_runtime must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_runtime(0) and set_magic_quotes_runtime(1).'."\n";
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   448
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
			}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   450
			// Check for magic_quotes_gpc
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   451
			if (function_exists('get_magic_quotes_gpc')) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   452
				// phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_gpcDeprecated
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   453
				if (get_magic_quotes_gpc()) { // @phpstan-ignore-line
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   454
					$this->startup_error .= 'magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).'."\n";
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   455
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
		// Load support library
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
		if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   461
			$this->startup_error .= 'getid3.lib.php is missing or corrupt'."\n";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
		if ($this->option_max_2gb_check === null) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
			$this->option_max_2gb_check = (PHP_INT_MAX <= 2147483647);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
		// Needed for Windows only:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
		// Define locations of helper applications for Shorten, VorbisComment, MetaFLAC
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   471
		//   as well as other helper functions such as head, etc
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
		// This path cannot contain spaces, but the below code will attempt to get the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
		//   8.3-equivalent path automatically
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
		// IMPORTANT: This path must include the trailing slash
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
		if (GETID3_OS_ISWINDOWS && !defined('GETID3_HELPERAPPSDIR')) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
			$helperappsdir = GETID3_INCLUDEPATH.'..'.DIRECTORY_SEPARATOR.'helperapps'; // must not have any space in this path
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
			if (!is_dir($helperappsdir)) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   480
				$this->startup_warning .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist'."\n";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
			} elseif (strpos(realpath($helperappsdir), ' ') !== false) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
				$DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
				$path_so_far = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
				foreach ($DirPieces as $key => $value) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
					if (strpos($value, ' ') !== false) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
						if (!empty($path_so_far)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
							$commandline = 'dir /x '.escapeshellarg(implode(DIRECTORY_SEPARATOR, $path_so_far));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   488
							$dir_listing = `$commandline`;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   489
							$lines = explode("\n", $dir_listing);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
							foreach ($lines as $line) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   491
								$line = trim($line);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
								if (preg_match('#^([0-9/]{10}) +([0-9:]{4,5}( [AP]M)?) +(<DIR>|[0-9,]+) +([^ ]{0,11}) +(.+)$#', $line, $matches)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
									list($dummy, $date, $time, $ampm, $filesize, $shortname, $filename) = $matches;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
									if ((strtoupper($filesize) == '<DIR>') && (strtolower($filename) == strtolower($value))) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
										$value = $shortname;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
									}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
								}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
							}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
						} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   500
							$this->startup_warning .= 'GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary. You can run "dir /x" from the commandline to see the correct 8.3-style names.'."\n";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   501
						}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
					$path_so_far[] = $value;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   504
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
				$helperappsdir = implode(DIRECTORY_SEPARATOR, $path_so_far);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
			define('GETID3_HELPERAPPSDIR', $helperappsdir.DIRECTORY_SEPARATOR);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   510
		if (!empty($this->startup_error)) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   511
			echo $this->startup_error;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   512
			throw new getid3_exception($this->startup_error);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   513
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   516
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   517
	 * @return string
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   518
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
	public function version() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
		return self::VERSION;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   523
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   524
	 * @return int
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   525
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
	public function fread_buffer_size() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
		return $this->option_fread_buffer_size;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   530
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   531
	 * @param array $optArray
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   532
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   533
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   534
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
	public function setOption($optArray) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
		if (!is_array($optArray) || empty($optArray)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
			return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
		foreach ($optArray as $opt => $val) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
			if (isset($this->$opt) === false) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
				continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   542
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   543
			$this->$opt = $val;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   548
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   549
	 * @param string   $filename
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   550
	 * @param int      $filesize
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   551
	 * @param resource $fp
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   552
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   553
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   554
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   555
	 * @throws getid3_exception
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   556
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   557
	public function openfile($filename, $filesize=null, $fp=null) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
		try {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   559
			if (!empty($this->startup_error)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
				throw new getid3_exception($this->startup_error);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
			if (!empty($this->startup_warning)) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   563
				foreach (explode("\n", $this->startup_warning) as $startup_warning) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   564
					$this->warning($startup_warning);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   565
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   567
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
			// init result array and set parameters
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
			$this->filename = $filename;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
			$this->info = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
			$this->info['GETID3_VERSION']   = $this->version();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   572
			$this->info['php_memory_limit'] = (($this->memory_limit > 0) ? $this->memory_limit : false);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   573
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
			// remote files not supported
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   575
			if (preg_match('#^(ht|f)tps?://#', $filename)) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   576
				throw new getid3_exception('Remote files are not supported - please copy the file locally first');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   577
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   578
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   579
			$filename = str_replace('/', DIRECTORY_SEPARATOR, $filename);
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   580
			//$filename = preg_replace('#(?<!gs:)('.preg_quote(DIRECTORY_SEPARATOR).'{2,})#', DIRECTORY_SEPARATOR, $filename);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   581
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   582
			// open local file
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   583
			//if (is_readable($filename) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) { // see https://www.getid3.org/phpBB3/viewtopic.php?t=1720
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   584
			if (($fp != null) && ((get_resource_type($fp) == 'file') || (get_resource_type($fp) == 'stream'))) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   585
				$this->fp = $fp;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   586
			} elseif ((is_readable($filename) || file_exists($filename)) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   587
				// great
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   588
			} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   589
				$errormessagelist = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   590
				if (!is_readable($filename)) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   591
					$errormessagelist[] = '!is_readable';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   592
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   593
				if (!is_file($filename)) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   594
					$errormessagelist[] = '!is_file';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   595
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   596
				if (!file_exists($filename)) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   597
					$errormessagelist[] = '!file_exists';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   598
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   599
				if (empty($errormessagelist)) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   600
					$errormessagelist[] = 'fopen failed';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   601
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   602
				throw new getid3_exception('Could not open "'.$filename.'" ('.implode('; ', $errormessagelist).')');
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   603
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   604
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   605
			$this->info['filesize'] = (!is_null($filesize) ? $filesize : filesize($filename));
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   606
			// set redundant parameters - might be needed in some include file
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   607
			// filenames / filepaths in getID3 are always expressed with forward slashes (unix-style) for both Windows and other to try and minimize confusion
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   608
			$filename = str_replace('\\', '/', $filename);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   609
			$this->info['filepath']     = str_replace('\\', '/', realpath(dirname($filename)));
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   610
			$this->info['filename']     = getid3_lib::mb_basename($filename);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
			$this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   612
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   613
			// set more parameters
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   614
			$this->info['avdataoffset']        = 0;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   615
			$this->info['avdataend']           = $this->info['filesize'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   616
			$this->info['fileformat']          = '';                // filled in later
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   617
			$this->info['audio']['dataformat'] = '';                // filled in later, unset if not used
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   618
			$this->info['video']['dataformat'] = '';                // filled in later, unset if not used
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   619
			$this->info['tags']                = array();           // filled in later, unset if not used
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   620
			$this->info['error']               = array();           // filled in later, unset if not used
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   621
			$this->info['warning']             = array();           // filled in later, unset if not used
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   622
			$this->info['comments']            = array();           // filled in later, unset if not used
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   623
			$this->info['encoding']            = $this->encoding;   // required by id3v2 and iso modules - can be unset at the end if desired
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   624
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   625
			// option_max_2gb_check
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   626
			if ($this->option_max_2gb_check) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   627
				// PHP (32-bit all, and 64-bit Windows) doesn't support integers larger than 2^31 (~2GB)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   628
				// filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   629
				// ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   630
				$fseek = fseek($this->fp, 0, SEEK_END);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   631
				if (($fseek < 0) || (($this->info['filesize'] != 0) && (ftell($this->fp) == 0)) ||
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   632
					($this->info['filesize'] < 0) ||
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   633
					(ftell($this->fp) < 0)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   634
						$real_filesize = getid3_lib::getFileSizeSyscall($this->info['filenamepath']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   635
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   636
						if ($real_filesize === false) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   637
							unset($this->info['filesize']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   638
							fclose($this->fp);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   639
							throw new getid3_exception('Unable to determine actual filesize. File is most likely larger than '.round(PHP_INT_MAX / 1073741824).'GB and is not supported by PHP.');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   640
						} elseif (getid3_lib::intValueSupported($real_filesize)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   641
							unset($this->info['filesize']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   642
							fclose($this->fp);
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   643
							throw new getid3_exception('PHP seems to think the file is larger than '.round(PHP_INT_MAX / 1073741824).'GB, but filesystem reports it as '.number_format($real_filesize / 1073741824, 3).'GB, please report to info@getid3.org');
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   644
						}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   645
						$this->info['filesize'] = $real_filesize;
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   646
						$this->warning('File is larger than '.round(PHP_INT_MAX / 1073741824).'GB (filesystem reports it as '.number_format($real_filesize / 1073741824, 3).'GB) and is not properly supported by PHP.');
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   647
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   648
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   649
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   650
			return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   651
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   652
		} catch (Exception $e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   653
			$this->error($e->getMessage());
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   654
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   655
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   656
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   657
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   658
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   659
	 * analyze file
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   660
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   661
	 * @param string   $filename
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   662
	 * @param int      $filesize
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   663
	 * @param string   $original_filename
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   664
	 * @param resource $fp
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   665
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   666
	 * @return array
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   667
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   668
	public function analyze($filename, $filesize=null, $original_filename='', $fp=null) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   669
		try {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   670
			if (!$this->openfile($filename, $filesize, $fp)) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   671
				return $this->info;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   672
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   673
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   674
			// Handle tags
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   675
			foreach (array('id3v2'=>'id3v2', 'id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   676
				$option_tag = 'option_tag_'.$tag_name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   677
				if ($this->$option_tag) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   678
					$this->include_module('tag.'.$tag_name);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   679
					try {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   680
						$tag_class = 'getid3_'.$tag_name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   681
						$tag = new $tag_class($this);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   682
						$tag->Analyze();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   683
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   684
					catch (getid3_exception $e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   685
						throw $e;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   686
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   687
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   688
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   689
			if (isset($this->info['id3v2']['tag_offset_start'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   690
				$this->info['avdataoffset'] = max($this->info['avdataoffset'], $this->info['id3v2']['tag_offset_end']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   691
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   692
			foreach (array('id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   693
				if (isset($this->info[$tag_key]['tag_offset_start'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   694
					$this->info['avdataend'] = min($this->info['avdataend'], $this->info[$tag_key]['tag_offset_start']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   695
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   696
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   697
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   698
			// ID3v2 detection (NOT parsing), even if ($this->option_tag_id3v2 == false) done to make fileformat easier
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   699
			if (!$this->option_tag_id3v2) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   700
				fseek($this->fp, 0);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   701
				$header = fread($this->fp, 10);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   702
				if ((substr($header, 0, 3) == 'ID3') && (strlen($header) == 10)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   703
					$this->info['id3v2']['header']        = true;
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   704
					$this->info['id3v2']['majorversion']  = ord($header[3]);
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   705
					$this->info['id3v2']['minorversion']  = ord($header[4]);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   706
					$this->info['avdataoffset']          += getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   707
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   708
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   709
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   710
			// read 32 kb file data
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   711
			fseek($this->fp, $this->info['avdataoffset']);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   712
			$formattest = fread($this->fp, 32774);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   713
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   714
			// determine format
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   715
			$determined_format = $this->GetFileFormat($formattest, ($original_filename ? $original_filename : $filename));
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   716
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   717
			// unable to determine file format
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   718
			if (!$determined_format) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   719
				fclose($this->fp);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   720
				return $this->error('unable to determine file format');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   721
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   722
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   723
			// check for illegal ID3 tags
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   724
			if (isset($determined_format['fail_id3']) && (in_array('id3v1', $this->info['tags']) || in_array('id3v2', $this->info['tags']))) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   725
				if ($determined_format['fail_id3'] === 'ERROR') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   726
					fclose($this->fp);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   727
					return $this->error('ID3 tags not allowed on this file type.');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   728
				} elseif ($determined_format['fail_id3'] === 'WARNING') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   729
					$this->warning('ID3 tags not allowed on this file type.');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   730
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   731
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   732
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   733
			// check for illegal APE tags
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   734
			if (isset($determined_format['fail_ape']) && in_array('ape', $this->info['tags'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   735
				if ($determined_format['fail_ape'] === 'ERROR') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   736
					fclose($this->fp);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   737
					return $this->error('APE tags not allowed on this file type.');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   738
				} elseif ($determined_format['fail_ape'] === 'WARNING') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   739
					$this->warning('APE tags not allowed on this file type.');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   740
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   741
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   742
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   743
			// set mime type
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   744
			$this->info['mime_type'] = $determined_format['mime_type'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   745
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   746
			// supported format signature pattern detected, but module deleted
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   747
			if (!file_exists(GETID3_INCLUDEPATH.$determined_format['include'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   748
				fclose($this->fp);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   749
				return $this->error('Format not supported, module "'.$determined_format['include'].'" was removed.');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   750
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   751
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   752
			// module requires mb_convert_encoding/iconv support
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   753
			// Check encoding/iconv support
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   754
			if (!empty($determined_format['iconv_req']) && !function_exists('mb_convert_encoding') && !function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   755
				$errormessage = 'mb_convert_encoding() or iconv() support is required for this module ('.$determined_format['include'].') for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   756
				if (GETID3_OS_ISWINDOWS) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   757
					$errormessage .= 'PHP does not have mb_convert_encoding() or iconv() support. Please enable php_mbstring.dll / php_iconv.dll in php.ini, and copy php_mbstring.dll / iconv.dll from c:/php/dlls to c:/windows/system32';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   758
				} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   759
					$errormessage .= 'PHP is not compiled with mb_convert_encoding() or iconv() support. Please recompile with the --enable-mbstring / --with-iconv switch';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   760
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   761
				return $this->error($errormessage);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   762
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   763
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   764
			// include module
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   765
			include_once(GETID3_INCLUDEPATH.$determined_format['include']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   766
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   767
			// instantiate module class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   768
			$class_name = 'getid3_'.$determined_format['module'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   769
			if (!class_exists($class_name)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   770
				return $this->error('Format not supported, module "'.$determined_format['include'].'" is corrupt.');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   771
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   772
			$class = new $class_name($this);
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   773
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   774
			// set module-specific options
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   775
			foreach (get_object_vars($this) as $getid3_object_vars_key => $getid3_object_vars_value) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   776
				if (preg_match('#^options_([^_]+)_([^_]+)_(.+)$#i', $getid3_object_vars_key, $matches)) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   777
					list($dummy, $GOVgroup, $GOVmodule, $GOVsetting) = $matches;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   778
					$GOVgroup = (($GOVgroup == 'audiovideo') ? 'audio-video' : $GOVgroup); // variable names can only contain 0-9a-z_ so standardize here
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   779
					if (($GOVgroup == $determined_format['group']) && ($GOVmodule == $determined_format['module'])) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   780
						$class->$GOVsetting = $getid3_object_vars_value;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   781
					}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   782
				}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   783
			}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   784
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   785
			$class->Analyze();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   786
			unset($class);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   787
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   788
			// close file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   789
			fclose($this->fp);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   790
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   791
			// process all tags - copy to 'tags' and convert charsets
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   792
			if ($this->option_tags_process) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   793
				$this->HandleAllTags();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   794
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   795
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   796
			// perform more calculations
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   797
			if ($this->option_extra_info) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   798
				$this->ChannelsBitratePlaytimeCalculations();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   799
				$this->CalculateCompressionRatioVideo();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   800
				$this->CalculateCompressionRatioAudio();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   801
				$this->CalculateReplayGain();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   802
				$this->ProcessAudioStreams();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   803
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   804
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   805
			// get the MD5 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   806
			if ($this->option_md5_data) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   807
				// do not calc md5_data if md5_data_source is present - set by flac only - future MPC/SV8 too
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   808
				if (!$this->option_md5_data_source || empty($this->info['md5_data_source'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   809
					$this->getHashdata('md5');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   810
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   811
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   812
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   813
			// get the SHA1 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   814
			if ($this->option_sha1_data) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   815
				$this->getHashdata('sha1');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   816
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   817
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   818
			// remove undesired keys
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   819
			$this->CleanUp();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   820
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   821
		} catch (Exception $e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   822
			$this->error('Caught exception: '.$e->getMessage());
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   823
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   824
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   825
		// return info array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   826
		return $this->info;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   827
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   828
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   829
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   830
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   831
	 * Error handling.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   832
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   833
	 * @param string $message
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   834
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   835
	 * @return array
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   836
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   837
	public function error($message) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   838
		$this->CleanUp();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   839
		if (!isset($this->info['error'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   840
			$this->info['error'] = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   841
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   842
		$this->info['error'][] = $message;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   843
		return $this->info;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   844
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   845
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   846
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   847
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   848
	 * Warning handling.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   849
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   850
	 * @param string $message
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   851
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   852
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   853
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   854
	public function warning($message) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   855
		$this->info['warning'][] = $message;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   856
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   857
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   858
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   859
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   860
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   861
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   862
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   863
	private function CleanUp() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   864
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   865
		// remove possible empty keys
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   866
		$AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams', 'bitrate');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   867
		foreach ($AVpossibleEmptyKeys as $dummy => $key) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   868
			if (empty($this->info['audio'][$key]) && isset($this->info['audio'][$key])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   869
				unset($this->info['audio'][$key]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   870
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   871
			if (empty($this->info['video'][$key]) && isset($this->info['video'][$key])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   872
				unset($this->info['video'][$key]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   873
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   874
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   875
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   876
		// remove empty root keys
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   877
		if (!empty($this->info)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   878
			foreach ($this->info as $key => $value) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   879
				if (empty($this->info[$key]) && ($this->info[$key] !== 0) && ($this->info[$key] !== '0')) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   880
					unset($this->info[$key]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   881
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   882
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   883
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   884
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   885
		// remove meaningless entries from unknown-format files
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   886
		if (empty($this->info['fileformat'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   887
			if (isset($this->info['avdataoffset'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   888
				unset($this->info['avdataoffset']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   889
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   890
			if (isset($this->info['avdataend'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   891
				unset($this->info['avdataend']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   892
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   893
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   894
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   895
		// remove possible duplicated identical entries
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   896
		if (!empty($this->info['error'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   897
			$this->info['error'] = array_values(array_unique($this->info['error']));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   898
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   899
		if (!empty($this->info['warning'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   900
			$this->info['warning'] = array_values(array_unique($this->info['warning']));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   901
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   902
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   903
		// remove "global variable" type keys
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   904
		unset($this->info['php_memory_limit']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   905
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   906
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   907
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   908
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   909
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   910
	 * Return array containing information about all supported formats.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   911
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   912
	 * @return array
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   913
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   914
	public function GetFileFormatArray() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   915
		static $format_info = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   916
		if (empty($format_info)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   917
			$format_info = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   918
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   919
				// Audio formats
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   920
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   921
				// AC-3   - audio      - Dolby AC-3 / Dolby Digital
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   922
				'ac3'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   923
							'pattern'   => '^\\x0B\\x77',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   924
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   925
							'module'    => 'ac3',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   926
							'mime_type' => 'audio/ac3',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   927
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   928
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   929
				// AAC  - audio       - Advanced Audio Coding (AAC) - ADIF format
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   930
				'adif' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   931
							'pattern'   => '^ADIF',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   932
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   933
							'module'    => 'aac',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   934
							'mime_type' => 'audio/aac',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   935
							'fail_ape'  => 'WARNING',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   936
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   937
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   938
/*
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   939
				// AA   - audio       - Audible Audiobook
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   940
				'aa'   => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   941
							'pattern'   => '^.{4}\\x57\\x90\\x75\\x36',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   942
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   943
							'module'    => 'aa',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   944
							'mime_type' => 'audio/audible',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   945
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   946
*/
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   947
				// AAC  - audio       - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   948
				'adts' => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   949
							'pattern'   => '^\\xFF[\\xF0-\\xF1\\xF8-\\xF9]',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   950
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   951
							'module'    => 'aac',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   952
							'mime_type' => 'audio/aac',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   953
							'fail_ape'  => 'WARNING',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   954
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   955
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   956
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   957
				// AU   - audio       - NeXT/Sun AUdio (AU)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   958
				'au'   => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   959
							'pattern'   => '^\\.snd',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   960
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   961
							'module'    => 'au',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   962
							'mime_type' => 'audio/basic',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   963
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   964
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   965
				// AMR  - audio       - Adaptive Multi Rate
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   966
				'amr'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   967
							'pattern'   => '^\\x23\\x21AMR\\x0A', // #!AMR[0A]
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   968
							'group'     => 'audio',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   969
							'module'    => 'amr',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   970
							'mime_type' => 'audio/amr',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   971
						),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   972
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   973
				// AVR  - audio       - Audio Visual Research
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   974
				'avr'  => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   975
							'pattern'   => '^2BIT',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   976
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   977
							'module'    => 'avr',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   978
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   979
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   980
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   981
				// BONK - audio       - Bonk v0.9+
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   982
				'bonk' => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   983
							'pattern'   => '^\\x00(BONK|INFO|META| ID3)',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   984
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   985
							'module'    => 'bonk',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   986
							'mime_type' => 'audio/xmms-bonk',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   987
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   988
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   989
				// DSF  - audio       - Direct Stream Digital (DSD) Storage Facility files (DSF) - https://en.wikipedia.org/wiki/Direct_Stream_Digital
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   990
				'dsf'  => array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   991
							'pattern'   => '^DSD ',  // including trailing space: 44 53 44 20
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   992
							'group'     => 'audio',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   993
							'module'    => 'dsf',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   994
							'mime_type' => 'audio/dsd',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   995
						),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   996
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   997
				// DSS  - audio       - Digital Speech Standard
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   998
				'dss'  => array(
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   999
							'pattern'   => '^[\\x02-\\x08]ds[s2]',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1000
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1001
							'module'    => 'dss',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1002
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1003
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1004
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1005
				// DSDIFF - audio     - Direct Stream Digital Interchange File Format
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1006
				'dsdiff' => array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1007
							'pattern'   => '^FRM8',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1008
							'group'     => 'audio',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1009
							'module'    => 'dsdiff',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1010
							'mime_type' => 'audio/dsd',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1011
						),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1012
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1013
				// DTS  - audio       - Dolby Theatre System
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1014
				'dts'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1015
							'pattern'   => '^\\x7F\\xFE\\x80\\x01',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1016
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1017
							'module'    => 'dts',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1018
							'mime_type' => 'audio/dts',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1019
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1020
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1021
				// FLAC - audio       - Free Lossless Audio Codec
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1022
				'flac' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1023
							'pattern'   => '^fLaC',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1024
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1025
							'module'    => 'flac',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1026
							'mime_type' => 'audio/flac',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1027
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1028
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1029
				// LA   - audio       - Lossless Audio (LA)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1030
				'la'   => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1031
							'pattern'   => '^LA0[2-4]',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1032
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1033
							'module'    => 'la',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1034
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1035
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1036
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1037
				// LPAC - audio       - Lossless Predictive Audio Compression (LPAC)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1038
				'lpac' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1039
							'pattern'   => '^LPAC',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1040
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1041
							'module'    => 'lpac',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1042
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1043
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1044
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1045
				// MIDI - audio       - MIDI (Musical Instrument Digital Interface)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1046
				'midi' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1047
							'pattern'   => '^MThd',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1048
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1049
							'module'    => 'midi',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1050
							'mime_type' => 'audio/midi',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1051
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1052
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1053
				// MAC  - audio       - Monkey's Audio Compressor
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1054
				'mac'  => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1055
							'pattern'   => '^MAC ',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1056
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1057
							'module'    => 'monkey',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1058
							'mime_type' => 'audio/x-monkeys-audio',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1059
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1060
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1061
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1062
				// MOD  - audio       - MODule (SoundTracker)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1063
				'mod'  => array(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1064
							//'pattern'   => '^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)', // has been known to produce false matches in random files (e.g. JPEGs), leave out until more precise matching available
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1065
							'pattern'   => '^.{1080}(M\\.K\\.)',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1066
							'group'     => 'audio',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1067
							'module'    => 'mod',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1068
							'option'    => 'mod',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1069
							'mime_type' => 'audio/mod',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1070
						),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1071
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1072
				// MOD  - audio       - MODule (Impulse Tracker)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1073
				'it'   => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1074
							'pattern'   => '^IMPM',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1075
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1076
							'module'    => 'mod',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1077
							//'option'    => 'it',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1078
							'mime_type' => 'audio/it',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1079
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1080
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1081
				// MOD  - audio       - MODule (eXtended Module, various sub-formats)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1082
				'xm'   => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1083
							'pattern'   => '^Extended Module',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1084
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1085
							'module'    => 'mod',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1086
							//'option'    => 'xm',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1087
							'mime_type' => 'audio/xm',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1088
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1089
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1090
				// MOD  - audio       - MODule (ScreamTracker)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1091
				's3m'  => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1092
							'pattern'   => '^.{44}SCRM',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1093
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1094
							'module'    => 'mod',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1095
							//'option'    => 's3m',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1096
							'mime_type' => 'audio/s3m',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1097
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1098
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1099
				// MPC  - audio       - Musepack / MPEGplus
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1100
				'mpc'  => array(
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1101
							'pattern'   => '^(MPCK|MP\\+)',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1102
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1103
							'module'    => 'mpc',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1104
							'mime_type' => 'audio/x-musepack',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1105
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1106
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1107
				// MP3  - audio       - MPEG-audio Layer 3 (very similar to AAC-ADTS)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1108
				'mp3'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1109
							'pattern'   => '^\\xFF[\\xE2-\\xE7\\xF2-\\xF7\\xFA-\\xFF][\\x00-\\x0B\\x10-\\x1B\\x20-\\x2B\\x30-\\x3B\\x40-\\x4B\\x50-\\x5B\\x60-\\x6B\\x70-\\x7B\\x80-\\x8B\\x90-\\x9B\\xA0-\\xAB\\xB0-\\xBB\\xC0-\\xCB\\xD0-\\xDB\\xE0-\\xEB\\xF0-\\xFB]',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1110
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1111
							'module'    => 'mp3',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1112
							'mime_type' => 'audio/mpeg',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1113
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1114
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1115
				// OFR  - audio       - OptimFROG
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1116
				'ofr'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1117
							'pattern'   => '^(\\*RIFF|OFR)',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1118
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1119
							'module'    => 'optimfrog',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1120
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1121
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1122
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1123
				// RKAU - audio       - RKive AUdio compressor
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1124
				'rkau' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1125
							'pattern'   => '^RKA',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1126
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1127
							'module'    => 'rkau',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1128
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1129
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1130
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1131
				// SHN  - audio       - Shorten
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1132
				'shn'  => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1133
							'pattern'   => '^ajkg',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1134
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1135
							'module'    => 'shorten',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1136
							'mime_type' => 'audio/xmms-shn',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1137
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1138
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1139
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1140
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1141
				// TAK  - audio       - Tom's lossless Audio Kompressor
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1142
				'tak'  => array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1143
							'pattern'   => '^tBaK',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1144
							'group'     => 'audio',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1145
							'module'    => 'tak',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1146
							'mime_type' => 'application/octet-stream',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1147
						),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1148
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1149
				// TTA  - audio       - TTA Lossless Audio Compressor (http://tta.corecodec.org)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1150
				'tta'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1151
							'pattern'   => '^TTA',  // could also be '^TTA(\\x01|\\x02|\\x03|2|1)'
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1152
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1153
							'module'    => 'tta',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1154
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1155
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1156
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1157
				// VOC  - audio       - Creative Voice (VOC)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1158
				'voc'  => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1159
							'pattern'   => '^Creative Voice File',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1160
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1161
							'module'    => 'voc',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1162
							'mime_type' => 'audio/voc',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1163
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1164
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1165
				// VQF  - audio       - transform-domain weighted interleave Vector Quantization Format (VQF)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1166
				'vqf'  => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1167
							'pattern'   => '^TWIN',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1168
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1169
							'module'    => 'vqf',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1170
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1171
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1172
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1173
				// WV  - audio        - WavPack (v4.0+)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1174
				'wv'   => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1175
							'pattern'   => '^wvpk',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1176
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1177
							'module'    => 'wavpack',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1178
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1179
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1180
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1181
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1182
				// Audio-Video formats
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1183
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1184
				// ASF  - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1185
				'asf'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1186
							'pattern'   => '^\\x30\\x26\\xB2\\x75\\x8E\\x66\\xCF\\x11\\xA6\\xD9\\x00\\xAA\\x00\\x62\\xCE\\x6C',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1187
							'group'     => 'audio-video',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1188
							'module'    => 'asf',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1189
							'mime_type' => 'video/x-ms-asf',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1190
							'iconv_req' => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1191
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1192
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1193
				// BINK - audio/video - Bink / Smacker
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1194
				'bink' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1195
							'pattern'   => '^(BIK|SMK)',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1196
							'group'     => 'audio-video',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1197
							'module'    => 'bink',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1198
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1199
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1200
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1201
				// FLV  - audio/video - FLash Video
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1202
				'flv' => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1203
							'pattern'   => '^FLV[\\x01]',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1204
							'group'     => 'audio-video',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1205
							'module'    => 'flv',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1206
							'mime_type' => 'video/x-flv',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1207
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1208
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1209
				// IVF - audio/video - IVF
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1210
				'ivf' => array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1211
							'pattern'   => '^DKIF',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1212
							'group'     => 'audio-video',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1213
							'module'    => 'ivf',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1214
							'mime_type' => 'video/x-ivf',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1215
						),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1216
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1217
				// MKAV - audio/video - Mastroka
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1218
				'matroska' => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1219
							'pattern'   => '^\\x1A\\x45\\xDF\\xA3',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1220
							'group'     => 'audio-video',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1221
							'module'    => 'matroska',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1222
							'mime_type' => 'video/x-matroska', // may also be audio/x-matroska
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1223
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1224
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1225
				// MPEG - audio/video - MPEG (Moving Pictures Experts Group)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1226
				'mpeg' => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1227
							'pattern'   => '^\\x00\\x00\\x01[\\xB3\\xBA]',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1228
							'group'     => 'audio-video',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1229
							'module'    => 'mpeg',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1230
							'mime_type' => 'video/mpeg',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1231
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1232
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1233
				// NSV  - audio/video - Nullsoft Streaming Video (NSV)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1234
				'nsv'  => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1235
							'pattern'   => '^NSV[sf]',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1236
							'group'     => 'audio-video',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1237
							'module'    => 'nsv',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1238
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1239
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1240
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1241
				// Ogg  - audio/video - Ogg (Ogg-Vorbis, Ogg-FLAC, Speex, Ogg-Theora(*), Ogg-Tarkin(*))
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1242
				'ogg'  => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1243
							'pattern'   => '^OggS',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1244
							'group'     => 'audio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1245
							'module'    => 'ogg',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1246
							'mime_type' => 'application/ogg',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1247
							'fail_id3'  => 'WARNING',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1248
							'fail_ape'  => 'WARNING',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1249
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1250
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1251
				// QT   - audio/video - Quicktime
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1252
				'quicktime' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1253
							'pattern'   => '^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1254
							'group'     => 'audio-video',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1255
							'module'    => 'quicktime',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1256
							'mime_type' => 'video/quicktime',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1257
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1258
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1259
				// RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com) / FORM = Audio Interchange File Format (AIFF)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1260
				'riff' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1261
							'pattern'   => '^(RIFF|SDSS|FORM)',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1262
							'group'     => 'audio-video',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1263
							'module'    => 'riff',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1264
							'mime_type' => 'audio/wav',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1265
							'fail_ape'  => 'WARNING',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1266
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1267
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1268
				// Real - audio/video - RealAudio, RealVideo
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1269
				'real' => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1270
							'pattern'   => '^\\.(RMF|ra)',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1271
							'group'     => 'audio-video',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1272
							'module'    => 'real',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1273
							'mime_type' => 'audio/x-realaudio',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1274
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1275
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1276
				// SWF - audio/video - ShockWave Flash
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1277
				'swf' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1278
							'pattern'   => '^(F|C)WS',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1279
							'group'     => 'audio-video',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1280
							'module'    => 'swf',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1281
							'mime_type' => 'application/x-shockwave-flash',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1282
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1283
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1284
				// TS - audio/video - MPEG-2 Transport Stream
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1285
				'ts' => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1286
							'pattern'   => '^(\\x47.{187}){10,}', // packets are 188 bytes long and start with 0x47 "G".  Check for at least 10 packets matching this pattern
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1287
							'group'     => 'audio-video',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1288
							'module'    => 'ts',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1289
							'mime_type' => 'video/MP2T',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1290
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1291
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1292
				// WTV - audio/video - Windows Recorded TV Show
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1293
				'wtv' => array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1294
							'pattern'   => '^\\xB7\\xD8\\x00\\x20\\x37\\x49\\xDA\\x11\\xA6\\x4E\\x00\\x07\\xE9\\x5E\\xAD\\x8D',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1295
							'group'     => 'audio-video',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1296
							'module'    => 'wtv',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1297
							'mime_type' => 'video/x-ms-wtv',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1298
						),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1299
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1300
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1301
				// Still-Image formats
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1302
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1303
				// BMP  - still image - Bitmap (Windows, OS/2; uncompressed, RLE8, RLE4)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1304
				'bmp'  => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1305
							'pattern'   => '^BM',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1306
							'group'     => 'graphic',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1307
							'module'    => 'bmp',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1308
							'mime_type' => 'image/bmp',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1309
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1310
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1311
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1312
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1313
				// GIF  - still image - Graphics Interchange Format
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1314
				'gif'  => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1315
							'pattern'   => '^GIF',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1316
							'group'     => 'graphic',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1317
							'module'    => 'gif',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1318
							'mime_type' => 'image/gif',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1319
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1320
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1321
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1322
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1323
				// JPEG - still image - Joint Photographic Experts Group (JPEG)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1324
				'jpg'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1325
							'pattern'   => '^\\xFF\\xD8\\xFF',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1326
							'group'     => 'graphic',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1327
							'module'    => 'jpg',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1328
							'mime_type' => 'image/jpeg',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1329
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1330
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1331
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1332
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1333
				// PCD  - still image - Kodak Photo CD
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1334
				'pcd'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1335
							'pattern'   => '^.{2048}PCD_IPI\\x00',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1336
							'group'     => 'graphic',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1337
							'module'    => 'pcd',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1338
							'mime_type' => 'image/x-photo-cd',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1339
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1340
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1341
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1342
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1343
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1344
				// PNG  - still image - Portable Network Graphics (PNG)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1345
				'png'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1346
							'pattern'   => '^\\x89\\x50\\x4E\\x47\\x0D\\x0A\\x1A\\x0A',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1347
							'group'     => 'graphic',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1348
							'module'    => 'png',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1349
							'mime_type' => 'image/png',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1350
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1351
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1352
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1353
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1354
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1355
				// SVG  - still image - Scalable Vector Graphics (SVG)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1356
				'svg'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1357
							'pattern'   => '(<!DOCTYPE svg PUBLIC |xmlns="http://www\\.w3\\.org/2000/svg")',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1358
							'group'     => 'graphic',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1359
							'module'    => 'svg',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1360
							'mime_type' => 'image/svg+xml',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1361
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1362
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1363
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1364
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1365
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1366
				// TIFF - still image - Tagged Information File Format (TIFF)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1367
				'tiff' => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1368
							'pattern'   => '^(II\\x2A\\x00|MM\\x00\\x2A)',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1369
							'group'     => 'graphic',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1370
							'module'    => 'tiff',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1371
							'mime_type' => 'image/tiff',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1372
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1373
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1374
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1375
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1376
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1377
				// EFAX - still image - eFax (TIFF derivative)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1378
				'efax'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1379
							'pattern'   => '^\\xDC\\xFE',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1380
							'group'     => 'graphic',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1381
							'module'    => 'efax',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1382
							'mime_type' => 'image/efax',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1383
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1384
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1385
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1386
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1387
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1388
				// Data formats
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1389
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1390
				// ISO  - data        - International Standards Organization (ISO) CD-ROM Image
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1391
				'iso'  => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1392
							'pattern'   => '^.{32769}CD001',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1393
							'group'     => 'misc',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1394
							'module'    => 'iso',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1395
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1396
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1397
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1398
							'iconv_req' => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1399
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1400
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1401
				// HPK  - data        - HPK compressed data
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1402
				'hpk'  => array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1403
							'pattern'   => '^BPUL',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1404
							'group'     => 'archive',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1405
							'module'    => 'hpk',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1406
							'mime_type' => 'application/octet-stream',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1407
							'fail_id3'  => 'ERROR',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1408
							'fail_ape'  => 'ERROR',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1409
						),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1410
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1411
				// RAR  - data        - RAR compressed data
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1412
				'rar'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1413
							'pattern'   => '^Rar\\!',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1414
							'group'     => 'archive',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1415
							'module'    => 'rar',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1416
							'mime_type' => 'application/vnd.rar',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1417
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1418
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1419
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1420
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1421
				// SZIP - audio/data  - SZIP compressed data
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1422
				'szip' => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1423
							'pattern'   => '^SZ\\x0A\\x04',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1424
							'group'     => 'archive',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1425
							'module'    => 'szip',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1426
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1427
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1428
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1429
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1430
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1431
				// TAR  - data        - TAR compressed data
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1432
				'tar'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1433
							'pattern'   => '^.{100}[0-9\\x20]{7}\\x00[0-9\\x20]{7}\\x00[0-9\\x20]{7}\\x00[0-9\\x20\\x00]{12}[0-9\\x20\\x00]{12}',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1434
							'group'     => 'archive',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1435
							'module'    => 'tar',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1436
							'mime_type' => 'application/x-tar',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1437
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1438
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1439
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1440
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1441
				// GZIP  - data        - GZIP compressed data
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1442
				'gz'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1443
							'pattern'   => '^\\x1F\\x8B\\x08',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1444
							'group'     => 'archive',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1445
							'module'    => 'gzip',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1446
							'mime_type' => 'application/gzip',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1447
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1448
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1449
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1450
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1451
				// ZIP  - data         - ZIP compressed data
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1452
				'zip'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1453
							'pattern'   => '^PK\\x03\\x04',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1454
							'group'     => 'archive',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1455
							'module'    => 'zip',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1456
							'mime_type' => 'application/zip',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1457
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1458
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1459
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1460
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1461
				// XZ   - data         - XZ compressed data
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1462
				'xz'  => array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1463
							'pattern'   => '^\\xFD7zXZ\\x00',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1464
							'group'     => 'archive',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1465
							'module'    => 'xz',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1466
							'mime_type' => 'application/x-xz',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1467
							'fail_id3'  => 'ERROR',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1468
							'fail_ape'  => 'ERROR',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1469
						),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1470
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1471
				// XZ   - data         - XZ compressed data
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1472
				'7zip'  => array(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1473
							'pattern'   => '^7z\\xBC\\xAF\\x27\\x1C',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1474
							'group'     => 'archive',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1475
							'module'    => '7zip',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1476
							'mime_type' => 'application/x-7z-compressed',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1477
							'fail_id3'  => 'ERROR',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1478
							'fail_ape'  => 'ERROR',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1479
						),
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1480
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1481
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1482
				// Misc other formats
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1483
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1484
				// PAR2 - data        - Parity Volume Set Specification 2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1485
				'par2' => array (
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1486
							'pattern'   => '^PAR2\\x00PKT',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1487
							'group'     => 'misc',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1488
							'module'    => 'par2',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1489
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1490
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1491
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1492
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1493
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1494
				// PDF  - data        - Portable Document Format
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1495
				'pdf'  => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1496
							'pattern'   => '^\\x25PDF',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1497
							'group'     => 'misc',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1498
							'module'    => 'pdf',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1499
							'mime_type' => 'application/pdf',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1500
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1501
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1502
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1503
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1504
				// MSOFFICE  - data   - ZIP compressed data
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1505
				'msoffice' => array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1506
							'pattern'   => '^\\xD0\\xCF\\x11\\xE0\\xA1\\xB1\\x1A\\xE1', // D0CF11E == DOCFILE == Microsoft Office Document
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1507
							'group'     => 'misc',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1508
							'module'    => 'msoffice',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1509
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1510
							'fail_id3'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1511
							'fail_ape'  => 'ERROR',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1512
						),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1513
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1514
				// TORRENT             - .torrent
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1515
				'torrent' => array(
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1516
							'pattern'   => '^(d8\\:announce|d7\\:comment)',
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1517
							'group'     => 'misc',
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1518
							'module'    => 'torrent',
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1519
							'mime_type' => 'application/x-bittorrent',
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1520
							'fail_id3'  => 'ERROR',
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1521
							'fail_ape'  => 'ERROR',
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1522
						),
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1523
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1524
				 // CUE  - data       - CUEsheet (index to single-file disc images)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1525
				 'cue' => array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1526
							'pattern'   => '', // empty pattern means cannot be automatically detected, will fall through all other formats and match based on filename and very basic file contents
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1527
							'group'     => 'misc',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1528
							'module'    => 'cue',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1529
							'mime_type' => 'application/octet-stream',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1530
						   ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1531
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1532
			);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1533
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1534
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1535
		return $format_info;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1536
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1537
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1538
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1539
	 * @param string $filedata
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1540
	 * @param string $filename
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1541
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1542
	 * @return mixed|false
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1543
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1544
	public function GetFileFormat(&$filedata, $filename='') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1545
		// this function will determine the format of a file based on usually
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1546
		// the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1547
		// and in the case of ISO CD image, 6 bytes offset 32kb from the start
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1548
		// of the file).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1549
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1550
		// Identify file format - loop through $format_info and detect with reg expr
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1551
		foreach ($this->GetFileFormatArray() as $format_name => $info) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1552
			// The /s switch on preg_match() forces preg_match() NOT to treat
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1553
			// newline (0x0A) characters as special chars but do a binary match
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1554
			if (!empty($info['pattern']) && preg_match('#'.$info['pattern'].'#s', $filedata)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1555
				$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1556
				return $info;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1557
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1558
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1559
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1560
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1561
		if (preg_match('#\\.mp[123a]$#i', $filename)) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1562
			// Too many mp3 encoders on the market put garbage in front of mpeg files
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1563
			// use assume format on these if format detection failed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1564
			$GetFileFormatArray = $this->GetFileFormatArray();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1565
			$info = $GetFileFormatArray['mp3'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1566
			$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1567
			return $info;
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1568
		} elseif (preg_match('#\\.mp[cp\\+]$#i', $filename) && preg_match('#[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0]#s', $filedata)) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1569
			// old-format (SV4-SV6) Musepack header that has a very loose pattern match and could falsely match other data (e.g. corrupt mp3)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1570
			// only enable this pattern check if the filename ends in .mpc/mpp/mp+
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1571
			$GetFileFormatArray = $this->GetFileFormatArray();
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1572
			$info = $GetFileFormatArray['mpc'];
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1573
			$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1574
			return $info;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1575
		} elseif (preg_match('#\\.cue$#i', $filename) && preg_match('#FILE "[^"]+" (BINARY|MOTOROLA|AIFF|WAVE|MP3)#', $filedata)) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1576
			// there's not really a useful consistent "magic" at the beginning of .cue files to identify them
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1577
			// so until I think of something better, just go by filename if all other format checks fail
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1578
			// and verify there's at least one instance of "TRACK xx AUDIO" in the file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1579
			$GetFileFormatArray = $this->GetFileFormatArray();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1580
			$info = $GetFileFormatArray['cue'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1581
			$info['include']   = 'module.'.$info['group'].'.'.$info['module'].'.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1582
			return $info;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1583
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1584
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1585
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1586
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1587
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1588
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1589
	 * Converts array to $encoding charset from $this->encoding.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1590
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1591
	 * @param array  $array
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1592
	 * @param string $encoding
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1593
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1594
	public function CharConvert(&$array, $encoding) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1595
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1596
		// identical encoding - end here
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1597
		if ($encoding == $this->encoding) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1598
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1599
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1600
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1601
		// loop thru array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1602
		foreach ($array as $key => $value) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1603
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1604
			// go recursive
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1605
			if (is_array($value)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1606
				$this->CharConvert($array[$key], $encoding);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1607
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1608
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1609
			// convert string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1610
			elseif (is_string($value)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1611
				$array[$key] = trim(getid3_lib::iconv_fallback($encoding, $this->encoding, $value));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1612
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1613
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1614
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1615
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1616
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1617
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1618
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1619
	public function HandleAllTags() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1620
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1621
		// key name => array (tag name, character encoding)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1622
		static $tags;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1623
		if (empty($tags)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1624
			$tags = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1625
				'asf'       => array('asf'           , 'UTF-16LE'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1626
				'midi'      => array('midi'          , 'ISO-8859-1'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1627
				'nsv'       => array('nsv'           , 'ISO-8859-1'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1628
				'ogg'       => array('vorbiscomment' , 'UTF-8'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1629
				'png'       => array('png'           , 'UTF-8'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1630
				'tiff'      => array('tiff'          , 'ISO-8859-1'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1631
				'quicktime' => array('quicktime'     , 'UTF-8'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1632
				'real'      => array('real'          , 'ISO-8859-1'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1633
				'vqf'       => array('vqf'           , 'ISO-8859-1'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1634
				'zip'       => array('zip'           , 'ISO-8859-1'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1635
				'riff'      => array('riff'          , 'ISO-8859-1'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1636
				'lyrics3'   => array('lyrics3'       , 'ISO-8859-1'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1637
				'id3v1'     => array('id3v1'         , $this->encoding_id3v1),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1638
				'id3v2'     => array('id3v2'         , 'UTF-8'), // not according to the specs (every frame can have a different encoding), but getID3() force-converts all encodings to UTF-8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1639
				'ape'       => array('ape'           , 'UTF-8'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1640
				'cue'       => array('cue'           , 'ISO-8859-1'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1641
				'matroska'  => array('matroska'      , 'UTF-8'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1642
				'flac'      => array('vorbiscomment' , 'UTF-8'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1643
				'divxtag'   => array('divx'          , 'ISO-8859-1'),
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1644
				'iptc'      => array('iptc'          , 'ISO-8859-1'),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1645
				'dsdiff'    => array('dsdiff'        , 'ISO-8859-1'),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1646
			);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1647
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1648
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1649
		// loop through comments array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1650
		foreach ($tags as $comment_name => $tagname_encoding_array) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1651
			list($tag_name, $encoding) = $tagname_encoding_array;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1652
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1653
			// fill in default encoding type if not already present
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1654
			if (isset($this->info[$comment_name]) && !isset($this->info[$comment_name]['encoding'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1655
				$this->info[$comment_name]['encoding'] = $encoding;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1656
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1657
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1658
			// copy comments if key name set
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1659
			if (!empty($this->info[$comment_name]['comments'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1660
				foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1661
					foreach ($valuearray as $key => $value) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1662
						if (is_string($value)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1663
							$value = trim($value, " \r\n\t"); // do not trim nulls from $value!! Unicode characters will get mangled if trailing nulls are removed!
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1664
						}
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1665
						if (isset($value) && $value !== "") {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1666
							if (!is_numeric($key)) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1667
								$this->info['tags'][trim($tag_name)][trim($tag_key)][$key] = $value;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1668
							} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1669
								$this->info['tags'][trim($tag_name)][trim($tag_key)][]     = $value;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1670
							}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1671
						}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1672
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1673
					if ($tag_key == 'picture') {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1674
						// pictures can take up a lot of space, and we don't need multiple copies of them; let there be a single copy in [comments][picture], and not elsewhere
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1675
						unset($this->info[$comment_name]['comments'][$tag_key]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1676
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1677
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1678
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1679
				if (!isset($this->info['tags'][$tag_name])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1680
					// comments are set but contain nothing but empty strings, so skip
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1681
					continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1682
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1683
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1684
				$this->CharConvert($this->info['tags'][$tag_name], $this->info[$comment_name]['encoding']);           // only copy gets converted!
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1685
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1686
				if ($this->option_tags_html) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1687
					foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1688
						if ($tag_key == 'picture') {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1689
							// Do not to try to convert binary picture data to HTML
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1690
							// https://github.com/JamesHeinrich/getID3/issues/178
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1691
							continue;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1692
						}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1693
						$this->info['tags_html'][$tag_name][$tag_key] = getid3_lib::recursiveMultiByteCharString2HTML($valuearray, $this->info[$comment_name]['encoding']);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1694
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1695
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1696
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1697
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1698
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1699
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1700
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1701
		// pictures can take up a lot of space, and we don't need multiple copies of them; let there be a single copy in [comments][picture], and not elsewhere
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1702
		if (!empty($this->info['tags'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1703
			$unset_keys = array('tags', 'tags_html');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1704
			foreach ($this->info['tags'] as $tagtype => $tagarray) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1705
				foreach ($tagarray as $tagname => $tagdata) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1706
					if ($tagname == 'picture') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1707
						foreach ($tagdata as $key => $tagarray) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1708
							$this->info['comments']['picture'][] = $tagarray;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1709
							if (isset($tagarray['data']) && isset($tagarray['image_mime'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1710
								if (isset($this->info['tags'][$tagtype][$tagname][$key])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1711
									unset($this->info['tags'][$tagtype][$tagname][$key]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1712
								}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1713
								if (isset($this->info['tags_html'][$tagtype][$tagname][$key])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1714
									unset($this->info['tags_html'][$tagtype][$tagname][$key]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1715
								}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1716
							}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1717
						}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1718
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1719
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1720
				foreach ($unset_keys as $unset_key) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1721
					// remove possible empty keys from (e.g. [tags][id3v2][picture])
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1722
					if (empty($this->info[$unset_key][$tagtype]['picture'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1723
						unset($this->info[$unset_key][$tagtype]['picture']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1724
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1725
					if (empty($this->info[$unset_key][$tagtype])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1726
						unset($this->info[$unset_key][$tagtype]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1727
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1728
					if (empty($this->info[$unset_key])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1729
						unset($this->info[$unset_key]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1730
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1731
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1732
				// remove duplicate copy of picture data from (e.g. [id3v2][comments][picture])
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1733
				if (isset($this->info[$tagtype]['comments']['picture'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1734
					unset($this->info[$tagtype]['comments']['picture']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1735
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1736
				if (empty($this->info[$tagtype]['comments'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1737
					unset($this->info[$tagtype]['comments']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1738
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1739
				if (empty($this->info[$tagtype])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1740
					unset($this->info[$tagtype]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1741
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1742
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1743
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1744
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1745
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1746
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1747
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1748
	 * Calls getid3_lib::CopyTagsToComments() but passes in the option_tags_html setting from this instance of getID3
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1749
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1750
	 * @param array $ThisFileInfo
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1751
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1752
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1753
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1754
	public function CopyTagsToComments(&$ThisFileInfo) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1755
	    return getid3_lib::CopyTagsToComments($ThisFileInfo, $this->option_tags_html);
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1756
	}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1757
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1758
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1759
	 * @param string $algorithm
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1760
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1761
	 * @return array|bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1762
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1763
	public function getHashdata($algorithm) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1764
		switch ($algorithm) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1765
			case 'md5':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1766
			case 'sha1':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1767
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1768
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1769
			default:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1770
				return $this->error('bad algorithm "'.$algorithm.'" in getHashdata()');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1771
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1772
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1773
		if (!empty($this->info['fileformat']) && !empty($this->info['dataformat']) && ($this->info['fileformat'] == 'ogg') && ($this->info['audio']['dataformat'] == 'vorbis')) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1774
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1775
			// We cannot get an identical md5_data value for Ogg files where the comments
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1776
			// span more than 1 Ogg page (compared to the same audio data with smaller
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1777
			// comments) using the normal getID3() method of MD5'ing the data between the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1778
			// end of the comments and the end of the file (minus any trailing tags),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1779
			// because the page sequence numbers of the pages that the audio data is on
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1780
			// do not match. Under normal circumstances, where comments are smaller than
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1781
			// the nominal 4-8kB page size, then this is not a problem, but if there are
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1782
			// very large comments, the only way around it is to strip off the comment
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1783
			// tags with vorbiscomment and MD5 that file.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1784
			// This procedure must be applied to ALL Ogg files, not just the ones with
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1785
			// comments larger than 1 page, because the below method simply MD5's the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1786
			// whole file with the comments stripped, not just the portion after the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1787
			// comments block (which is the standard getID3() method.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1788
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1789
			// The above-mentioned problem of comments spanning multiple pages and changing
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1790
			// page sequence numbers likely happens for OggSpeex and OggFLAC as well, but
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1791
			// currently vorbiscomment only works on OggVorbis files.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1792
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1793
			// phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.safe_modeDeprecatedRemoved
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1794
			if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1795
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1796
				$this->warning('Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1797
				$this->info[$algorithm.'_data'] = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1798
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1799
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1800
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1801
				// Prevent user from aborting script
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1802
				$old_abort = ignore_user_abort(true);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1803
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1804
				// Create empty file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1805
				$empty = tempnam(GETID3_TEMP_DIR, 'getID3');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1806
				touch($empty);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1807
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1808
				// Use vorbiscomment to make temp file without comments
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1809
				$temp = tempnam(GETID3_TEMP_DIR, 'getID3');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1810
				$file = $this->info['filenamepath'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1811
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1812
				if (GETID3_OS_ISWINDOWS) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1813
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1814
					if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1815
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1816
						$commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w -c "'.$empty.'" "'.$file.'" "'.$temp.'"';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1817
						$VorbisCommentError = `$commandline`;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1818
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1819
					} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1820
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1821
						$VorbisCommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1822
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1823
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1824
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1825
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1826
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1827
					$commandline = 'vorbiscomment -w -c '.escapeshellarg($empty).' '.escapeshellarg($file).' '.escapeshellarg($temp).' 2>&1';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1828
					$VorbisCommentError = `$commandline`;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1829
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1830
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1831
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1832
				if (!empty($VorbisCommentError)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1833
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1834
					$this->warning('Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1835
					$this->info[$algorithm.'_data'] = false;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1836
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1837
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1838
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1839
					// Get hash of newly created file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1840
					switch ($algorithm) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1841
						case 'md5':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1842
							$this->info[$algorithm.'_data'] = md5_file($temp);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1843
							break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1844
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1845
						case 'sha1':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1846
							$this->info[$algorithm.'_data'] = sha1_file($temp);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1847
							break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1848
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1849
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1850
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1851
				// Clean up
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1852
				unlink($empty);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1853
				unlink($temp);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1854
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1855
				// Reset abort setting
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1856
				ignore_user_abort($old_abort);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1857
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1858
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1859
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1860
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1861
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1862
			if (!empty($this->info['avdataoffset']) || (isset($this->info['avdataend']) && ($this->info['avdataend'] < $this->info['filesize']))) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1863
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1864
				// get hash from part of file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1865
				$this->info[$algorithm.'_data'] = getid3_lib::hash_data($this->info['filenamepath'], $this->info['avdataoffset'], $this->info['avdataend'], $algorithm);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1866
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1867
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1868
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1869
				// get hash from whole file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1870
				switch ($algorithm) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1871
					case 'md5':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1872
						$this->info[$algorithm.'_data'] = md5_file($this->info['filenamepath']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1873
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1874
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1875
					case 'sha1':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1876
						$this->info[$algorithm.'_data'] = sha1_file($this->info['filenamepath']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1877
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1878
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1879
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1880
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1881
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1882
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1883
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1884
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1885
	public function ChannelsBitratePlaytimeCalculations() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1886
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1887
		// set channelmode on audio
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1888
		if (!empty($this->info['audio']['channelmode']) || !isset($this->info['audio']['channels'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1889
			// ignore
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1890
		} elseif ($this->info['audio']['channels'] == 1) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1891
			$this->info['audio']['channelmode'] = 'mono';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1892
		} elseif ($this->info['audio']['channels'] == 2) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1893
			$this->info['audio']['channelmode'] = 'stereo';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1894
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1895
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1896
		// Calculate combined bitrate - audio + video
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1897
		$CombinedBitrate  = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1898
		$CombinedBitrate += (isset($this->info['audio']['bitrate']) ? $this->info['audio']['bitrate'] : 0);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1899
		$CombinedBitrate += (isset($this->info['video']['bitrate']) ? $this->info['video']['bitrate'] : 0);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1900
		if (($CombinedBitrate > 0) && empty($this->info['bitrate'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1901
			$this->info['bitrate'] = $CombinedBitrate;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1902
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1903
		//if ((isset($this->info['video']) && !isset($this->info['video']['bitrate'])) || (isset($this->info['audio']) && !isset($this->info['audio']['bitrate']))) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1904
		//	// for example, VBR MPEG video files cannot determine video bitrate:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1905
		//	// should not set overall bitrate and playtime from audio bitrate only
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1906
		//	unset($this->info['bitrate']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1907
		//}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1908
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1909
		// video bitrate undetermined, but calculable
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1910
		if (isset($this->info['video']['dataformat']) && $this->info['video']['dataformat'] && (!isset($this->info['video']['bitrate']) || ($this->info['video']['bitrate'] == 0))) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1911
			// if video bitrate not set
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1912
			if (isset($this->info['audio']['bitrate']) && ($this->info['audio']['bitrate'] > 0) && ($this->info['audio']['bitrate'] == $this->info['bitrate'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1913
				// AND if audio bitrate is set to same as overall bitrate
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1914
				if (isset($this->info['playtime_seconds']) && ($this->info['playtime_seconds'] > 0)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1915
					// AND if playtime is set
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1916
					if (isset($this->info['avdataend']) && isset($this->info['avdataoffset'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1917
						// AND if AV data offset start/end is known
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1918
						// THEN we can calculate the video bitrate
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1919
						$this->info['bitrate'] = round((($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1920
						$this->info['video']['bitrate'] = $this->info['bitrate'] - $this->info['audio']['bitrate'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1921
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1922
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1923
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1924
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1925
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1926
		if ((!isset($this->info['playtime_seconds']) || ($this->info['playtime_seconds'] <= 0)) && !empty($this->info['bitrate'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1927
			$this->info['playtime_seconds'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['bitrate'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1928
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1929
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1930
		if (!isset($this->info['bitrate']) && !empty($this->info['playtime_seconds'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1931
			$this->info['bitrate'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1932
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1933
		if (isset($this->info['bitrate']) && empty($this->info['audio']['bitrate']) && empty($this->info['video']['bitrate'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1934
			if (isset($this->info['audio']['dataformat']) && empty($this->info['video']['resolution_x'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1935
				// audio only
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1936
				$this->info['audio']['bitrate'] = $this->info['bitrate'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1937
			} elseif (isset($this->info['video']['resolution_x']) && empty($this->info['audio']['dataformat'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1938
				// video only
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1939
				$this->info['video']['bitrate'] = $this->info['bitrate'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1940
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1941
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1942
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1943
		// Set playtime string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1944
		if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1945
			$this->info['playtime_string'] = getid3_lib::PlaytimeString($this->info['playtime_seconds']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1946
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1947
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1948
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1949
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1950
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1951
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1952
	public function CalculateCompressionRatioVideo() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1953
		if (empty($this->info['video'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1954
			return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1955
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1956
		if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1957
			return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1958
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1959
		if (empty($this->info['video']['bits_per_sample'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1960
			return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1961
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1962
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1963
		switch ($this->info['video']['dataformat']) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1964
			case 'bmp':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1965
			case 'gif':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1966
			case 'jpeg':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1967
			case 'jpg':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1968
			case 'png':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1969
			case 'tiff':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1970
				$FrameRate = 1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1971
				$PlaytimeSeconds = 1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1972
				$BitrateCompressed = $this->info['filesize'] * 8;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1973
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1974
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1975
			default:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1976
				if (!empty($this->info['video']['frame_rate'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1977
					$FrameRate = $this->info['video']['frame_rate'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1978
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1979
					return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1980
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1981
				if (!empty($this->info['playtime_seconds'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1982
					$PlaytimeSeconds = $this->info['playtime_seconds'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1983
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1984
					return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1985
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1986
				if (!empty($this->info['video']['bitrate'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1987
					$BitrateCompressed = $this->info['video']['bitrate'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1988
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1989
					return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1990
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1991
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1992
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1993
		$BitrateUncompressed = $this->info['video']['resolution_x'] * $this->info['video']['resolution_y'] * $this->info['video']['bits_per_sample'] * $FrameRate;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1994
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1995
		$this->info['video']['compression_ratio'] = getid3_lib::SafeDiv($BitrateCompressed, $BitrateUncompressed, 1);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1996
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1997
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1998
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1999
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2000
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2001
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2002
	public function CalculateCompressionRatioAudio() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2003
		if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate']) || !is_numeric($this->info['audio']['sample_rate'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2004
			return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2005
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2006
		$this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2007
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2008
		if (!empty($this->info['audio']['streams'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2009
			foreach ($this->info['audio']['streams'] as $streamnumber => $streamdata) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2010
				if (!empty($streamdata['bitrate']) && !empty($streamdata['channels']) && !empty($streamdata['sample_rate'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2011
					$this->info['audio']['streams'][$streamnumber]['compression_ratio'] = $streamdata['bitrate'] / ($streamdata['channels'] * $streamdata['sample_rate'] * (!empty($streamdata['bits_per_sample']) ? $streamdata['bits_per_sample'] : 16));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2012
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2013
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2014
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2015
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2016
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2017
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2018
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2019
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2020
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2021
	public function CalculateReplayGain() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2022
		if (isset($this->info['replay_gain'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2023
			if (!isset($this->info['replay_gain']['reference_volume'])) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2024
				$this->info['replay_gain']['reference_volume'] = 89.0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2025
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2026
			if (isset($this->info['replay_gain']['track']['adjustment'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2027
				$this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2028
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2029
			if (isset($this->info['replay_gain']['album']['adjustment'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2030
				$this->info['replay_gain']['album']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['album']['adjustment'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2031
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2032
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2033
			if (isset($this->info['replay_gain']['track']['peak'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2034
				$this->info['replay_gain']['track']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['track']['peak']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2035
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2036
			if (isset($this->info['replay_gain']['album']['peak'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2037
				$this->info['replay_gain']['album']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['album']['peak']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2038
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2039
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2040
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2041
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2042
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2043
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2044
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2045
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2046
	public function ProcessAudioStreams() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2047
		if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2048
			if (!isset($this->info['audio']['streams'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2049
				foreach ($this->info['audio'] as $key => $value) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2050
					if ($key != 'streams') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2051
						$this->info['audio']['streams'][0][$key] = $value;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2052
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2053
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2054
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2055
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2056
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2057
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2058
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2059
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2060
	 * @return string|bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2061
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2062
	public function getid3_tempnam() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2063
		return tempnam($this->tempdir, 'gI3');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2064
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2065
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2066
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2067
	 * @param string $name
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2068
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2069
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2070
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2071
	 * @throws getid3_exception
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2072
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2073
	public function include_module($name) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2074
		//if (!file_exists($this->include_path.'module.'.$name.'.php')) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2075
		if (!file_exists(GETID3_INCLUDEPATH.'module.'.$name.'.php')) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2076
			throw new getid3_exception('Required module.'.$name.'.php is missing.');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2077
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2078
		include_once(GETID3_INCLUDEPATH.'module.'.$name.'.php');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2079
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2080
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2081
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2082
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2083
	 * @param string $filename
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2084
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2085
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2086
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2087
	public static function is_writable ($filename) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2088
		$ret = is_writable($filename);
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2089
		if (!$ret) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2090
			$perms = fileperms($filename);
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2091
			$ret = ($perms & 0x0080) || ($perms & 0x0010) || ($perms & 0x0002);
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2092
		}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2093
		return $ret;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2094
	}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2095
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2096
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2097
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2098
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2099
abstract class getid3_handler
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2100
{
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2101
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2102
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2103
	* @var getID3
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2104
	*/
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2105
	protected $getid3;                       // pointer
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2106
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2107
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2108
	 * Analyzing filepointer or string.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2109
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2110
	 * @var bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2111
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2112
	protected $data_string_flag     = false;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2113
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2114
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2115
	 * String to analyze.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2116
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2117
	 * @var string
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2118
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2119
	protected $data_string          = '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2120
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2121
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2122
	 * Seek position in string.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2123
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2124
	 * @var int
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2125
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2126
	protected $data_string_position = 0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2127
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2128
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2129
	 * String length.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2130
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2131
	 * @var int
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2132
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2133
	protected $data_string_length   = 0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2134
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2135
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2136
	 * @var string
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2137
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2138
	private $dependency_to;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2139
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2140
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2141
	 * getid3_handler constructor.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2142
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2143
	 * @param getID3 $getid3
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2144
	 * @param string $call_module
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2145
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2146
	public function __construct(getID3 $getid3, $call_module=null) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2147
		$this->getid3 = $getid3;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2148
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2149
		if ($call_module) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2150
			$this->dependency_to = str_replace('getid3_', '', $call_module);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2151
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2152
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2153
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2154
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2155
	 * Analyze from file pointer.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2156
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2157
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2158
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2159
	abstract public function Analyze();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2160
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2161
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2162
	 * Analyze from string instead.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2163
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2164
	 * @param string $string
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2165
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2166
	public function AnalyzeString($string) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2167
		// Enter string mode
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2168
		$this->setStringMode($string);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2169
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2170
		// Save info
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2171
		$saved_avdataoffset = $this->getid3->info['avdataoffset'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2172
		$saved_avdataend    = $this->getid3->info['avdataend'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2173
		$saved_filesize     = (isset($this->getid3->info['filesize']) ? $this->getid3->info['filesize'] : null); // may be not set if called as dependency without openfile() call
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2174
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2175
		// Reset some info
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2176
		$this->getid3->info['avdataoffset'] = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2177
		$this->getid3->info['avdataend']    = $this->getid3->info['filesize'] = $this->data_string_length;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2178
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2179
		// Analyze
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2180
		$this->Analyze();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2181
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2182
		// Restore some info
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2183
		$this->getid3->info['avdataoffset'] = $saved_avdataoffset;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2184
		$this->getid3->info['avdataend']    = $saved_avdataend;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2185
		$this->getid3->info['filesize']     = $saved_filesize;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2186
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2187
		// Exit string mode
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2188
		$this->data_string_flag = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2189
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2190
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2191
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2192
	 * @param string $string
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2193
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2194
	public function setStringMode($string) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2195
		$this->data_string_flag   = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2196
		$this->data_string        = $string;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2197
		$this->data_string_length = strlen($string);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2198
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2199
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2200
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2201
	 * @phpstan-impure
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2202
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2203
	 * @return int|bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2204
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2205
	protected function ftell() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2206
		if ($this->data_string_flag) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2207
			return $this->data_string_position;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2208
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2209
		return ftell($this->getid3->fp);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2210
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2211
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2212
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2213
	 * @param int $bytes
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2214
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2215
	 * @phpstan-impure
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2216
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2217
	 * @return string|false
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2218
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2219
	 * @throws getid3_exception
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2220
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2221
	protected function fread($bytes) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2222
		if ($this->data_string_flag) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2223
			$this->data_string_position += $bytes;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2224
			return substr($this->data_string, $this->data_string_position - $bytes, $bytes);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2225
		}
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2226
		if ($bytes == 0) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2227
			return '';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2228
		} elseif ($bytes < 0) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2229
			throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().')', 10);
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2230
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2231
		$pos = $this->ftell() + $bytes;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2232
		if (!getid3_lib::intValueSupported($pos)) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2233
			throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2234
		}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2235
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2236
		//return fread($this->getid3->fp, $bytes);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2237
		/*
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2238
		* https://www.getid3.org/phpBB3/viewtopic.php?t=1930
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2239
		* "I found out that the root cause for the problem was how getID3 uses the PHP system function fread().
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2240
		* It seems to assume that fread() would always return as many bytes as were requested.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2241
		* However, according the PHP manual (http://php.net/manual/en/function.fread.php), this is the case only with regular local files, but not e.g. with Linux pipes.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2242
		* The call may return only part of the requested data and a new call is needed to get more."
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2243
		*/
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2244
		$contents = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2245
		do {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2246
			//if (($this->getid3->memory_limit > 0) && ($bytes > $this->getid3->memory_limit)) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2247
			if (($this->getid3->memory_limit > 0) && (($bytes / $this->getid3->memory_limit) > 0.99)) { // enable a more-fuzzy match to prevent close misses generating errors like "PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 33554464 bytes)"
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2248
				throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') that is more than available PHP memory ('.$this->getid3->memory_limit.')', 10);
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2249
			}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2250
			$part = fread($this->getid3->fp, $bytes);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2251
			$partLength  = strlen($part);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2252
			$bytes      -= $partLength;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2253
			$contents   .= $part;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2254
		} while (($bytes > 0) && ($partLength > 0));
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2255
		return $contents;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2256
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2257
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2258
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2259
	 * @param int $bytes
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2260
	 * @param int $whence
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2261
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2262
	 * @phpstan-impure
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2263
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2264
	 * @return int
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2265
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2266
	 * @throws getid3_exception
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2267
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2268
	protected function fseek($bytes, $whence=SEEK_SET) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2269
		if ($this->data_string_flag) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2270
			switch ($whence) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2271
				case SEEK_SET:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2272
					$this->data_string_position = $bytes;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2273
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2274
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2275
				case SEEK_CUR:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2276
					$this->data_string_position += $bytes;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2277
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2278
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2279
				case SEEK_END:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2280
					$this->data_string_position = $this->data_string_length + $bytes;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2281
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2282
			}
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2283
			return 0; // fseek returns 0 on success
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2284
		}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2285
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2286
		$pos = $bytes;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2287
		if ($whence == SEEK_CUR) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2288
			$pos = $this->ftell() + $bytes;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2289
		} elseif ($whence == SEEK_END) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2290
			$pos = $this->getid3->info['filesize'] + $bytes;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2291
		}
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2292
		if (!getid3_lib::intValueSupported($pos)) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2293
			throw new getid3_exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10);
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2294
		}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2295
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2296
		// https://github.com/JamesHeinrich/getID3/issues/327
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2297
		$result = fseek($this->getid3->fp, $bytes, $whence);
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2298
		if ($result !== 0) { // fseek returns 0 on success
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2299
			throw new getid3_exception('cannot fseek('.$pos.'). resource/stream does not appear to support seeking', 10);
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2300
		}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2301
		return $result;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2302
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2303
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2304
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2305
	 * @phpstan-impure
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2306
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2307
	 * @return string|false
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2308
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2309
	 * @throws getid3_exception
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2310
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2311
	protected function fgets() {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2312
		// must be able to handle CR/LF/CRLF but not read more than one lineend
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2313
		$buffer   = ''; // final string we will return
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2314
		$prevchar = ''; // save previously-read character for end-of-line checking
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2315
		if ($this->data_string_flag) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2316
			while (true) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2317
				$thischar = substr($this->data_string, $this->data_string_position++, 1);
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2318
				if (($prevchar == "\r") && ($thischar != "\n")) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2319
					// read one byte too many, back up
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2320
					$this->data_string_position--;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2321
					break;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2322
				}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2323
				$buffer .= $thischar;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2324
				if ($thischar == "\n") {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2325
					break;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2326
				}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2327
				if ($this->data_string_position >= $this->data_string_length) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2328
					// EOF
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2329
					break;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2330
				}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2331
				$prevchar = $thischar;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2332
			}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2333
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2334
		} else {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2335
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2336
			// Ideally we would just use PHP's fgets() function, however...
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2337
			// it does not behave consistently with regards to mixed line endings, may be system-dependent
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2338
			// and breaks entirely when given a file with mixed \r vs \n vs \r\n line endings (e.g. some PDFs)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2339
			//return fgets($this->getid3->fp);
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2340
			while (true) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2341
				$thischar = fgetc($this->getid3->fp);
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2342
				if (($prevchar == "\r") && ($thischar != "\n")) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2343
					// read one byte too many, back up
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2344
					fseek($this->getid3->fp, -1, SEEK_CUR);
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2345
					break;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2346
				}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2347
				$buffer .= $thischar;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2348
				if ($thischar == "\n") {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2349
					break;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2350
				}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2351
				if (feof($this->getid3->fp)) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2352
					break;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2353
				}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2354
				$prevchar = $thischar;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2355
			}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2356
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2357
		}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2358
		return $buffer;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2359
	}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2360
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2361
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2362
	 * @phpstan-impure
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2363
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2364
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2365
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2366
	protected function feof() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2367
		if ($this->data_string_flag) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2368
			return $this->data_string_position >= $this->data_string_length;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2369
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2370
		return feof($this->getid3->fp);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2371
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2372
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2373
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2374
	 * @param string $module
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2375
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2376
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2377
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2378
	final protected function isDependencyFor($module) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2379
		return $this->dependency_to == $module;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2380
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2381
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2382
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2383
	 * @param string $text
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2384
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2385
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2386
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2387
	protected function error($text) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2388
		$this->getid3->info['error'][] = $text;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2389
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2390
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2391
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2392
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2393
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2394
	 * @param string $text
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2395
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2396
	 * @return bool
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2397
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2398
	protected function warning($text) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2399
		return $this->getid3->warning($text);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2400
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2401
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2402
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2403
	 * @param string $text
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2404
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2405
	protected function notice($text) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2406
		// does nothing for now
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2407
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2408
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2409
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2410
	 * @param string $name
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2411
	 * @param int    $offset
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2412
	 * @param int    $length
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2413
	 * @param string $image_mime
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2414
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2415
	 * @return string|null
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2416
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2417
	 * @throws Exception
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2418
	 * @throws getid3_exception
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2419
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2420
	public function saveAttachment($name, $offset, $length, $image_mime=null) {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2421
		$fp_dest = null;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2422
		$dest = null;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2423
		try {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2424
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2425
			// do not extract at all
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2426
			if ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_NONE) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2427
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2428
				$attachment = null; // do not set any
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2429
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2430
			// extract to return array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2431
			} elseif ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_INLINE) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2432
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2433
				$this->fseek($offset);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2434
				$attachment = $this->fread($length); // get whole data in one pass, till it is anyway stored in memory
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2435
				if ($attachment === false || strlen($attachment) != $length) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2436
					throw new Exception('failed to read attachment data');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2437
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2438
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2439
			// assume directory path is given
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2440
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2441
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2442
				// set up destination path
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2443
				$dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->getid3->option_save_attachments), DIRECTORY_SEPARATOR);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2444
				if (!is_dir($dir) || !getID3::is_writable($dir)) { // check supplied directory
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2445
					throw new Exception('supplied path ('.$dir.') does not exist, or is not writable');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2446
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2447
				$dest = $dir.DIRECTORY_SEPARATOR.$name.($image_mime ? '.'.getid3_lib::ImageExtFromMime($image_mime) : '');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2448
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2449
				// create dest file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2450
				if (($fp_dest = fopen($dest, 'wb')) == false) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2451
					throw new Exception('failed to create file '.$dest);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2452
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2453
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2454
				// copy data
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2455
				$this->fseek($offset);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2456
				$buffersize = ($this->data_string_flag ? $length : $this->getid3->fread_buffer_size());
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2457
				$bytesleft = $length;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2458
				while ($bytesleft > 0) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2459
					if (($buffer = $this->fread(min($buffersize, $bytesleft))) === false || ($byteswritten = fwrite($fp_dest, $buffer)) === false || ($byteswritten === 0)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2460
						throw new Exception($buffer === false ? 'not enough data to read' : 'failed to write to destination file, may be not enough disk space');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2461
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2462
					$bytesleft -= $byteswritten;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2463
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2464
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2465
				fclose($fp_dest);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2466
				$attachment = $dest;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2467
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2468
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2469
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2470
		} catch (Exception $e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2471
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2472
			// close and remove dest file if created
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2473
			if (isset($fp_dest) && is_resource($fp_dest)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2474
				fclose($fp_dest);
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2475
			}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2476
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2477
			if (isset($dest) && file_exists($dest)) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2478
				unlink($dest);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2479
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2480
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2481
			// do not set any is case of error
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2482
			$attachment = null;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2483
			$this->warning('Failed to extract attachment '.$name.': '.$e->getMessage());
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2484
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2485
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2486
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2487
		// seek to the end of attachment
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2488
		$this->fseek($offset + $length);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2489
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2490
		return $attachment;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2491
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2492
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2493
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2494
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2495
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2496
class getid3_exception extends Exception
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2497
{
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2498
	public $message;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2499
}