|
24 | 24 | define('GETID3_DEMO_BROWSE_ALLOW_MD5_LINK', false); // if enabled, shows "enable" link for MD5 hashes for file/data/source
|
25 | 25 |
|
26 | 26 | $PageEncoding = 'UTF-8';
|
27 |
| - |
| 27 | +$FileSystemEncoding = ((GetID3\Utils::isWindows() && version_compare(PHP_VERSION, '7.1.0', '<')) ? 'Windows-1252' : 'UTF-8'); |
28 | 28 | $writescriptfilename = 'demo.write.php';
|
29 | 29 |
|
30 | 30 | // Needed for windows only. Leave commented-out to auto-detect, only define here if auto-detection does not work properly
|
|
75 | 75 | if (isset($_REQUEST['filename'])) {
|
76 | 76 |
|
77 | 77 | if (!file_exists($_REQUEST['filename']) || !is_file($_REQUEST['filename'])) {
|
78 |
| - die(GetID3\Utils::iconv_fallback('ISO-8859-1', $PageEncoding, $_REQUEST['filename'].' does not exist')); |
| 78 | + die(GetID3\Utils::iconv_fallback($FileSystemEncoding, $PageEncoding, $_REQUEST['filename'].' does not exist')); |
79 | 79 | }
|
80 | 80 | $starttime = microtime(true);
|
81 | 81 |
|
|
92 | 92 | }
|
93 | 93 |
|
94 | 94 |
|
95 |
| - GetID3\Utils::CopyTagsToComments($ThisFileInfo); |
| 95 | + $getID3->CopyTagsToComments($ThisFileInfo); |
96 | 96 |
|
97 | 97 | $listdirectory = dirname($_REQUEST['filename']);
|
98 | 98 | $listdirectory = realpath($listdirectory); // get rid of /../../ references
|
|
106 | 106 | if (preg_match('#^(ht|f)tp://#', $_REQUEST['filename'])) {
|
107 | 107 | echo '<i>Cannot browse remote filesystems</i><br>';
|
108 | 108 | } else {
|
109 |
| - echo 'Browse: <a href="'.htmlentities($_SERVER['PHP_SELF'].'?listdirectory='.urlencode($listdirectory), ENT_QUOTES | ENT_SUBSTITUTE, $PageEncoding).'">' . GetID3\Utils::iconv_fallback('ISO-8859-1', $PageEncoding, $listdirectory) . '</a><br>'; |
| 109 | + echo 'Browse: <a href="'.htmlentities($_SERVER['PHP_SELF'].'?listdirectory='.urlencode($listdirectory), ENT_QUOTES | ENT_SUBSTITUTE, $PageEncoding).'">' . GetID3\Utils::iconv_fallback($FileSystemEncoding, $PageEncoding, $listdirectory) . '</a><br>'; |
110 | 110 | }
|
111 | 111 |
|
112 | 112 | GetID3\Utils::ksort_recursive($ThisFileInfo);
|
|
172 | 172 | $getID3->setOption(array('option_md5_data' => (isset($_REQUEST['ShowMD5']) && GETID3_DEMO_BROWSE_ALLOW_MD5_LINK)));
|
173 | 173 | $fileinformation = $getID3->analyze($currentfilename);
|
174 | 174 |
|
175 |
| - GetID3\Utils::CopyTagsToComments($fileinformation); |
| 175 | + $getID3->CopyTagsToComments($fileinformation); |
176 | 176 |
|
177 | 177 | $TotalScannedFilesize += (isset($fileinformation['filesize']) ? $fileinformation['filesize'] : 0);
|
178 | 178 |
|
|
196 | 196 | if (isset($fileinformation['bitrate']) && ($fileinformation['bitrate'] > 0)) {
|
197 | 197 | $TotalScannedBitrateFiles++;
|
198 | 198 | }
|
| 199 | + |
| 200 | + } else { |
| 201 | + |
| 202 | + echo '<div style="color: red;">Unknown filesystem entry: "'.htmlentities($currentfilename, ENT_QUOTES | ENT_SUBSTITUTE, $PageEncoding).'"</div>'; |
| 203 | + |
199 | 204 | }
|
200 | 205 | }
|
201 | 206 | $endtime = microtime(true);
|
|
207 | 212 | $columnsintable = 14;
|
208 | 213 | echo '<table class="table" cellspacing="0" cellpadding="3">';
|
209 | 214 |
|
210 |
| - echo '<tr bgcolor="#'.$getID3checkColor_Head.'"><th colspan="'.$columnsintable.'">Files in ' . GetID3\Utils::iconv_fallback('ISO-8859-1', $PageEncoding, $currentfulldir) . '</th></tr>'; |
| 215 | + echo '<tr bgcolor="#'.$getID3checkColor_Head.'"><th colspan="'.$columnsintable.'">Files in ' . GetID3\Utils::iconv_fallback($FileSystemEncoding, $PageEncoding, $currentfulldir) . '</th></tr>'; |
211 | 216 | $rowcounter = 0;
|
212 | 217 | foreach ($DirectoryContents as $dirname => $val) {
|
213 | 218 | if (isset($DirectoryContents[$dirname]['dir']) && is_array($DirectoryContents[$dirname]['dir'])) {
|
|
227 | 232 | echo '"> <input type="submit" value="Go">';
|
228 | 233 | echo '</form></td>';
|
229 | 234 | } else {
|
230 |
| - //$escaped_filename = htmlentities($filename, ENT_SUBSTITUTE, $PageEncoding); // do filesystems always return filenames in ISO-8859-1? |
231 |
| - $escaped_filename = htmlentities($filename, ENT_SUBSTITUTE, 'ISO-8859-1'); // do filesystems always return filenames in ISO-8859-1? |
| 235 | + $escaped_filename = htmlentities($filename, ENT_SUBSTITUTE, $FileSystemEncoding); // do filesystems always return filenames in ISO-8859-1? |
232 | 236 | $escaped_filename = ($escaped_filename ? $escaped_filename : rawurlencode($filename));
|
233 | 237 | echo '<td colspan="'.$columnsintable.'"><a href="'.htmlentities($_SERVER['PHP_SELF'].'?listdirectory='.urlencode($dirname.$filename), ENT_QUOTES | ENT_SUBSTITUTE, $PageEncoding).'"><b>'.$escaped_filename.'</b></a></td>';
|
234 | 238 | }
|
|
261 | 265 | uksort($DirectoryContents[$dirname]['known'], 'MoreNaturalSort');
|
262 | 266 | foreach ($DirectoryContents[$dirname]['known'] as $filename => $fileinfo) {
|
263 | 267 | echo '<tr bgcolor="#'.(($rowcounter++ % 2) ? $getID3checkColor_FileDark : $getID3checkColor_FileLight).'">';
|
264 |
| - //$escaped_filename = htmlentities($filename, ENT_SUBSTITUTE, $PageEncoding); // do filesystems always return filenames in ISO-8859-1? |
265 |
| - $escaped_filename = htmlentities($filename, ENT_SUBSTITUTE, 'ISO-8859-1'); // do filesystems always return filenames in ISO-8859-1? |
| 268 | + $escaped_filename = htmlentities($filename, ENT_SUBSTITUTE, $FileSystemEncoding); // do filesystems always return filenames in ISO-8859-1? |
266 | 269 | $escaped_filename = ($escaped_filename ? $escaped_filename : rawurlencode($filename));
|
267 | 270 | echo '<td><a href="'.htmlentities($_SERVER['PHP_SELF'].'?filename='.urlencode($dirname.$filename), ENT_QUOTES | ENT_SUBSTITUTE, $PageEncoding).'" title="View detailed analysis">'.$escaped_filename.'</a></td>';
|
268 | 271 | echo '<td align="right"> '.number_format($fileinfo['filesize']).'</td>';
|
@@ -449,7 +452,9 @@ function string_var_dump($variable) {
|
449 | 452 | return $dumpedvariable;
|
450 | 453 | }
|
451 | 454 |
|
452 |
| -function table_var_dump($variable, $wrap_in_td=false, $encoding='ISO-8859-1') { |
| 455 | +function table_var_dump($variable, $wrap_in_td=false, $encoding='') { |
| 456 | + global $FileSystemEncoding; |
| 457 | + $encoding = ($encoding ? $encoding : $FileSystemEncoding); |
453 | 458 | $returnstring = '';
|
454 | 459 | switch (gettype($variable)) {
|
455 | 460 | case 'array':
|
|
0 commit comments