@@ -13,6 +13,8 @@ discard block |
||
13 | 13 | * @param - action (string) - action type require : 'delete' or 'update' |
14 | 14 | * @param - old_path (string) - old path info stored to change |
15 | 15 | * @param - new_path (string) - new path info to substitute |
16 | + * @param string $action |
|
17 | + * @param string $old_path |
|
16 | 18 | * @desc Update the file or directory path in the document db document table |
17 | 19 | * |
18 | 20 | */ |
@@ -76,8 +78,8 @@ discard block |
||
76 | 78 | * Deletes a file or a directory |
77 | 79 | * |
78 | 80 | * @author - Hugues Peeters |
79 | - * @param $file (String) - the path of file or directory to delete |
|
80 | - * @return boolean - true if the delete succeed, false otherwise. |
|
81 | + * @param string $file (String) - the path of file or directory to delete |
|
82 | + * @return boolean|null - true if the delete succeed, false otherwise. |
|
81 | 83 | * @see - delete() uses check_name_exist() and removeDir() functions |
82 | 84 | */ |
83 | 85 | function my_delete($file) |
@@ -162,9 +164,9 @@ discard block |
||
162 | 164 | * Renames a file or a directory |
163 | 165 | * |
164 | 166 | * @author - Hugues Peeters <[email protected]> |
165 | - * @param - $file_path (string) - complete path of the file or the directory |
|
166 | - * @param - $new_file_name (string) - new name for the file or the directory |
|
167 | - * @return - boolean - true if succeed |
|
167 | + * @param string $file_path (string) - complete path of the file or the directory |
|
168 | + * @param string $new_file_name (string) - new name for the file or the directory |
|
169 | + * @return string boolean - true if succeed |
|
168 | 170 | * - boolean - false otherwise |
169 | 171 | * @see - rename() uses the check_name_exist() and php2phps() functions |
170 | 172 | */ |
@@ -327,7 +329,6 @@ discard block |
||
327 | 329 | * Calculation size of a directory |
328 | 330 | * |
329 | 331 | * @returns integer size |
330 | - * @param string $path path to size |
|
331 | 332 | * @param boolean $recursive if true , include subdir in total |
332 | 333 | */ |
333 | 334 | function dirsize($root, $recursive = true) { |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /license.txt */ |
3 | 3 | /** |
4 | - * This is the file manage library for Chamilo. |
|
5 | - * Include/require it in your code to use its functionality. |
|
6 | - * @package chamilo.library |
|
7 | - */ |
|
4 | + * This is the file manage library for Chamilo. |
|
5 | + * Include/require it in your code to use its functionality. |
|
6 | + * @package chamilo.library |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Update the file or directory path in the document db document table |
@@ -170,37 +170,37 @@ discard block |
||
170 | 170 | */ |
171 | 171 | function my_rename($file_path, $new_file_name) { |
172 | 172 | |
173 | - $save_dir = getcwd(); |
|
174 | - $path = dirname($file_path); |
|
175 | - $old_file_name = basename($file_path); |
|
176 | - $new_file_name = api_replace_dangerous_char($new_file_name); |
|
177 | - |
|
178 | - // If no extension, take the old one |
|
179 | - if ((strpos($new_file_name, '.') === false) && ($dotpos = strrpos($old_file_name, '.'))) { |
|
180 | - $new_file_name .= substr($old_file_name, $dotpos); |
|
181 | - } |
|
182 | - |
|
183 | - // Note: still possible: 'xx.yy' -rename-> '.yy' -rename-> 'zz' |
|
184 | - // This is useful for folder names, where otherwise '.' would be sticky |
|
185 | - |
|
186 | - // Extension PHP is not allowed, change to PHPS |
|
187 | - $new_file_name = php2phps($new_file_name); |
|
188 | - |
|
189 | - if ($new_file_name == $old_file_name) { |
|
190 | - return $old_file_name; |
|
191 | - } |
|
192 | - |
|
193 | - if (strtolower($new_file_name) != strtolower($old_file_name) && check_name_exist($path.'/'.$new_file_name)) { |
|
194 | - return false; |
|
195 | - } |
|
196 | - // On a Windows server, it would be better not to do the above check |
|
197 | - // because it succeeds for some new names resembling the old name. |
|
198 | - // But on Unix/Linux the check must be done because rename overwrites. |
|
199 | - |
|
200 | - chdir($path); |
|
201 | - $res = rename($old_file_name, $new_file_name) ? $new_file_name : false; |
|
202 | - chdir($save_dir); |
|
203 | - return $res; |
|
173 | + $save_dir = getcwd(); |
|
174 | + $path = dirname($file_path); |
|
175 | + $old_file_name = basename($file_path); |
|
176 | + $new_file_name = api_replace_dangerous_char($new_file_name); |
|
177 | + |
|
178 | + // If no extension, take the old one |
|
179 | + if ((strpos($new_file_name, '.') === false) && ($dotpos = strrpos($old_file_name, '.'))) { |
|
180 | + $new_file_name .= substr($old_file_name, $dotpos); |
|
181 | + } |
|
182 | + |
|
183 | + // Note: still possible: 'xx.yy' -rename-> '.yy' -rename-> 'zz' |
|
184 | + // This is useful for folder names, where otherwise '.' would be sticky |
|
185 | + |
|
186 | + // Extension PHP is not allowed, change to PHPS |
|
187 | + $new_file_name = php2phps($new_file_name); |
|
188 | + |
|
189 | + if ($new_file_name == $old_file_name) { |
|
190 | + return $old_file_name; |
|
191 | + } |
|
192 | + |
|
193 | + if (strtolower($new_file_name) != strtolower($old_file_name) && check_name_exist($path.'/'.$new_file_name)) { |
|
194 | + return false; |
|
195 | + } |
|
196 | + // On a Windows server, it would be better not to do the above check |
|
197 | + // because it succeeds for some new names resembling the old name. |
|
198 | + // But on Unix/Linux the check must be done because rename overwrites. |
|
199 | + |
|
200 | + chdir($path); |
|
201 | + $res = rename($old_file_name, $new_file_name) ? $new_file_name : false; |
|
202 | + chdir($save_dir); |
|
203 | + return $res; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -217,38 +217,38 @@ discard block |
||
217 | 217 | */ |
218 | 218 | function move($source, $target, $forceMove = false, $moveContent = false) |
219 | 219 | { |
220 | - if (check_name_exist($source)) { |
|
221 | - $file_name = basename($source); |
|
220 | + if (check_name_exist($source)) { |
|
221 | + $file_name = basename($source); |
|
222 | 222 | $isWindowsOS = api_is_windows_os(); |
223 | 223 | $canExec = function_exists('exec'); |
224 | 224 | |
225 | - /* File case */ |
|
226 | - if (is_file($source)) { |
|
227 | - if ($forceMove && !$isWindowsOS && $canExec) { |
|
228 | - exec('mv ' . $source . ' ' . $target . '/' . $file_name); |
|
229 | - } else { |
|
230 | - copy($source, $target . '/' . $file_name); |
|
231 | - unlink($source); |
|
232 | - } |
|
233 | - return true; |
|
234 | - } elseif (is_dir($source)) { |
|
235 | - /* Directory */ |
|
236 | - if ($forceMove && !$isWindowsOS && $canExec) { |
|
237 | - if ($moveContent) { |
|
238 | - $base = basename($source); |
|
239 | - exec('mv '.$source.'/* '.$target.$base.'/'); |
|
240 | - exec('rm -rf '.$source); |
|
241 | - } else { |
|
242 | - exec('mv $source $target'); |
|
243 | - } |
|
244 | - } else { |
|
245 | - copyDirTo($source, $target); |
|
246 | - } |
|
247 | - return true; |
|
248 | - } |
|
249 | - } else { |
|
250 | - return false; |
|
251 | - } |
|
225 | + /* File case */ |
|
226 | + if (is_file($source)) { |
|
227 | + if ($forceMove && !$isWindowsOS && $canExec) { |
|
228 | + exec('mv ' . $source . ' ' . $target . '/' . $file_name); |
|
229 | + } else { |
|
230 | + copy($source, $target . '/' . $file_name); |
|
231 | + unlink($source); |
|
232 | + } |
|
233 | + return true; |
|
234 | + } elseif (is_dir($source)) { |
|
235 | + /* Directory */ |
|
236 | + if ($forceMove && !$isWindowsOS && $canExec) { |
|
237 | + if ($moveContent) { |
|
238 | + $base = basename($source); |
|
239 | + exec('mv '.$source.'/* '.$target.$base.'/'); |
|
240 | + exec('rm -rf '.$source); |
|
241 | + } else { |
|
242 | + exec('mv $source $target'); |
|
243 | + } |
|
244 | + } else { |
|
245 | + copyDirTo($source, $target); |
|
246 | + } |
|
247 | + return true; |
|
248 | + } |
|
249 | + } else { |
|
250 | + return false; |
|
251 | + } |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -261,54 +261,54 @@ discard block |
||
261 | 261 | */ |
262 | 262 | function copyDirTo($orig_dir_path, $destination, $move = true) |
263 | 263 | { |
264 | - if ($orig_dir_path == $destination) { |
|
265 | - return false; |
|
266 | - } |
|
264 | + if ($orig_dir_path == $destination) { |
|
265 | + return false; |
|
266 | + } |
|
267 | 267 | |
268 | - $save_dir = getcwd(); |
|
269 | - // Extract directory name - create it at destination - update destination trail |
|
270 | - $dir_name = basename($orig_dir_path); |
|
268 | + $save_dir = getcwd(); |
|
269 | + // Extract directory name - create it at destination - update destination trail |
|
270 | + $dir_name = basename($orig_dir_path); |
|
271 | 271 | $dir_to_copy = array(); |
272 | - if (is_dir($orig_dir_path)) { |
|
273 | - if (!is_dir($destination.'/'.$dir_name)) { |
|
274 | - mkdir( |
|
275 | - $destination.'/'.$dir_name, |
|
276 | - api_get_permissions_for_new_directories() |
|
277 | - ); |
|
278 | - } |
|
279 | - $destination_trail = $destination.'/'.$dir_name; |
|
280 | - if (is_dir($destination)) { |
|
281 | - chdir($orig_dir_path) ; |
|
282 | - $handle = opendir($orig_dir_path); |
|
283 | - |
|
284 | - while ($element = readdir($handle)) { |
|
285 | - if ($element == '.' || $element == '..') { |
|
286 | - continue; // Skip the current and parent directories |
|
287 | - } elseif (is_file($element)) { |
|
288 | - copy($element, $destination_trail.'/'.$element); |
|
289 | - |
|
290 | - if ($move) { |
|
291 | - unlink($element) ; |
|
292 | - } |
|
293 | - } elseif (is_dir($element)) { |
|
294 | - $dir_to_copy[] = $orig_dir_path.'/'.$element; |
|
295 | - } |
|
296 | - } |
|
297 | - |
|
298 | - closedir($handle) ; |
|
299 | - |
|
300 | - if (sizeof($dir_to_copy) > 0) { |
|
301 | - foreach ($dir_to_copy as $this_dir) { |
|
302 | - copyDirTo($this_dir, $destination_trail, $move); // Recursivity |
|
303 | - } |
|
304 | - } |
|
305 | - |
|
306 | - if ($move) { |
|
307 | - rmdir($orig_dir_path) ; |
|
308 | - } |
|
309 | - chdir($save_dir); |
|
310 | - } |
|
311 | - } |
|
272 | + if (is_dir($orig_dir_path)) { |
|
273 | + if (!is_dir($destination.'/'.$dir_name)) { |
|
274 | + mkdir( |
|
275 | + $destination.'/'.$dir_name, |
|
276 | + api_get_permissions_for_new_directories() |
|
277 | + ); |
|
278 | + } |
|
279 | + $destination_trail = $destination.'/'.$dir_name; |
|
280 | + if (is_dir($destination)) { |
|
281 | + chdir($orig_dir_path) ; |
|
282 | + $handle = opendir($orig_dir_path); |
|
283 | + |
|
284 | + while ($element = readdir($handle)) { |
|
285 | + if ($element == '.' || $element == '..') { |
|
286 | + continue; // Skip the current and parent directories |
|
287 | + } elseif (is_file($element)) { |
|
288 | + copy($element, $destination_trail.'/'.$element); |
|
289 | + |
|
290 | + if ($move) { |
|
291 | + unlink($element) ; |
|
292 | + } |
|
293 | + } elseif (is_dir($element)) { |
|
294 | + $dir_to_copy[] = $orig_dir_path.'/'.$element; |
|
295 | + } |
|
296 | + } |
|
297 | + |
|
298 | + closedir($handle) ; |
|
299 | + |
|
300 | + if (sizeof($dir_to_copy) > 0) { |
|
301 | + foreach ($dir_to_copy as $this_dir) { |
|
302 | + copyDirTo($this_dir, $destination_trail, $move); // Recursivity |
|
303 | + } |
|
304 | + } |
|
305 | + |
|
306 | + if ($move) { |
|
307 | + rmdir($orig_dir_path) ; |
|
308 | + } |
|
309 | + chdir($save_dir); |
|
310 | + } |
|
311 | + } |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | * @param string $filename filename |
320 | 320 | */ |
321 | 321 | function getextension($filename) { |
322 | - $bouts = explode('.', $filename); |
|
323 | - return array(array_pop($bouts), implode('.', $bouts)); |
|
322 | + $bouts = explode('.', $filename); |
|
323 | + return array(array_pop($bouts), implode('.', $bouts)); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -331,19 +331,19 @@ discard block |
||
331 | 331 | * @param boolean $recursive if true , include subdir in total |
332 | 332 | */ |
333 | 333 | function dirsize($root, $recursive = true) { |
334 | - $dir = @opendir($root); |
|
335 | - $size = 0; |
|
336 | - while ($file = @readdir($dir)) { |
|
337 | - if (!in_array($file, array('.', '..'))) { |
|
338 | - if (is_dir($root.'/'.$file)) { |
|
339 | - $size += $recursive ? dirsize($root.'/'.$file) : 0; |
|
340 | - } else { |
|
341 | - $size += @filesize($root.'/'.$file); |
|
342 | - } |
|
343 | - } |
|
344 | - } |
|
345 | - @closedir($dir); |
|
346 | - return $size; |
|
334 | + $dir = @opendir($root); |
|
335 | + $size = 0; |
|
336 | + while ($file = @readdir($dir)) { |
|
337 | + if (!in_array($file, array('.', '..'))) { |
|
338 | + if (is_dir($root.'/'.$file)) { |
|
339 | + $size += $recursive ? dirsize($root.'/'.$file) : 0; |
|
340 | + } else { |
|
341 | + $size += @filesize($root.'/'.$file); |
|
342 | + } |
|
343 | + } |
|
344 | + } |
|
345 | + @closedir($dir); |
|
346 | + return $size; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /* CLASS FileManager */ |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | */ |
363 | 363 | class FileManager |
364 | 364 | { |
365 | - /** |
|
365 | + /** |
|
366 | 366 | Returns a list of all directories, except the base dir, |
367 | 367 | of the current course. This function uses recursion. |
368 | 368 | |
@@ -370,131 +370,130 @@ discard block |
||
370 | 370 | |
371 | 371 | @author Roan Embrechts |
372 | 372 | @version 1.0.1 |
373 | - */ |
|
374 | - function list_all_directories($path) |
|
373 | + */ |
|
374 | + function list_all_directories($path) |
|
375 | 375 | { |
376 | - $result_array = array(); |
|
377 | - if (is_dir($path)) { |
|
378 | - $save_dir = getcwd(); |
|
379 | - chdir($path); |
|
380 | - $handle = opendir($path); |
|
381 | - while ($element = readdir($handle)) { |
|
382 | - if ($element == '.' || $element == '..') continue; |
|
376 | + $result_array = array(); |
|
377 | + if (is_dir($path)) { |
|
378 | + $save_dir = getcwd(); |
|
379 | + chdir($path); |
|
380 | + $handle = opendir($path); |
|
381 | + while ($element = readdir($handle)) { |
|
382 | + if ($element == '.' || $element == '..') continue; |
|
383 | 383 | // Skip the current and parent directories |
384 | - if (is_dir($element)) { |
|
385 | - $dir_array[] = $path.'/'.$element; |
|
386 | - } |
|
387 | - } |
|
388 | - closedir($handle); |
|
389 | - // Recursive operation if subdirectories exist |
|
390 | - $dir_number = sizeof($dir_array); |
|
391 | - if ($dir_number > 0) { |
|
392 | - for ($i = 0 ; $i < $dir_number ; $i++) { |
|
393 | - $sub_dir_array = FileManager::list_all_directories($dir_array[$i]); // Function recursivity |
|
394 | - if (is_array($dir_array) && is_array($sub_dir_array)) { |
|
395 | - $dir_array = array_merge($dir_array, $sub_dir_array); // Data merge |
|
396 | - } |
|
397 | - } |
|
398 | - } |
|
399 | - $result_array = $dir_array; |
|
400 | - chdir($save_dir) ; |
|
401 | - } |
|
402 | - return $result_array ; |
|
403 | - } |
|
404 | - |
|
405 | - /** |
|
384 | + if (is_dir($element)) { |
|
385 | + $dir_array[] = $path.'/'.$element; |
|
386 | + } |
|
387 | + } |
|
388 | + closedir($handle); |
|
389 | + // Recursive operation if subdirectories exist |
|
390 | + $dir_number = sizeof($dir_array); |
|
391 | + if ($dir_number > 0) { |
|
392 | + for ($i = 0 ; $i < $dir_number ; $i++) { |
|
393 | + $sub_dir_array = FileManager::list_all_directories($dir_array[$i]); // Function recursivity |
|
394 | + if (is_array($dir_array) && is_array($sub_dir_array)) { |
|
395 | + $dir_array = array_merge($dir_array, $sub_dir_array); // Data merge |
|
396 | + } |
|
397 | + } |
|
398 | + } |
|
399 | + $result_array = $dir_array; |
|
400 | + chdir($save_dir) ; |
|
401 | + } |
|
402 | + return $result_array ; |
|
403 | + } |
|
404 | + |
|
405 | + /** |
|
406 | 406 | This function receives a list of directories. |
407 | 407 | It returns a list of all files in these directories |
408 | 408 | |
409 | 409 | @author Roan Embrechts |
410 | 410 | @version 1.0 |
411 | - */ |
|
412 | - function list_all_files($dir_array) |
|
411 | + */ |
|
412 | + function list_all_files($dir_array) |
|
413 | 413 | { |
414 | - $element_array = array(); |
|
415 | - if (is_dir($dir_array)) { |
|
416 | - |
|
417 | - $save_dir = getcwd(); |
|
418 | - foreach ($dir_array as $directory) { |
|
419 | - chdir($directory); |
|
420 | - $handle = opendir($directory); |
|
421 | - while ($element = readdir($handle)) { |
|
422 | - if ($element == '.' || $element == '..' || $element == '.htaccess') continue; |
|
414 | + $element_array = array(); |
|
415 | + if (is_dir($dir_array)) { |
|
416 | + |
|
417 | + $save_dir = getcwd(); |
|
418 | + foreach ($dir_array as $directory) { |
|
419 | + chdir($directory); |
|
420 | + $handle = opendir($directory); |
|
421 | + while ($element = readdir($handle)) { |
|
422 | + if ($element == '.' || $element == '..' || $element == '.htaccess') continue; |
|
423 | 423 | // Skip the current and parent directories |
424 | - if (!is_dir($element)) { |
|
425 | - $element_array[] = $directory.'/'.$element; |
|
426 | - } |
|
427 | - } |
|
428 | - closedir($handle); |
|
429 | - chdir('..'); |
|
430 | - chdir($save_dir); |
|
431 | - } |
|
432 | - } |
|
433 | - |
|
434 | - return $element_array; |
|
435 | - } |
|
436 | - |
|
437 | - /** |
|
424 | + if (!is_dir($element)) { |
|
425 | + $element_array[] = $directory.'/'.$element; |
|
426 | + } |
|
427 | + } |
|
428 | + closedir($handle); |
|
429 | + chdir('..'); |
|
430 | + chdir($save_dir); |
|
431 | + } |
|
432 | + } |
|
433 | + |
|
434 | + return $element_array; |
|
435 | + } |
|
436 | + |
|
437 | + /** |
|
438 | 438 | Loads contents of file $filename into memory and returns them as a string. |
439 | 439 | Function kept for compatibility with older PHP versions. |
440 | 440 | Function is binary safe (is needed on Windows) |
441 | - */ |
|
442 | - function compat_load_file($file_name) |
|
441 | + */ |
|
442 | + function compat_load_file($file_name) |
|
443 | 443 | { |
444 | - $buffer = ''; |
|
445 | - if (file_exists($file_name)) { |
|
446 | - $fp = fopen($file_name, 'rb'); |
|
447 | - $buffer = fread ($fp, filesize($file_name)); |
|
448 | - fclose ($fp); |
|
449 | - } |
|
450 | - return $buffer; |
|
451 | - } |
|
452 | - |
|
453 | - /** |
|
454 | - * Adds file/folder to document table in database |
|
455 | - * improvement from set_default_settings (see below): |
|
456 | - * take all info from function parameters |
|
457 | - * no global variables needed |
|
458 | - * |
|
459 | - * NOTE $glued_table should already have backticks around it |
|
460 | - * (get it from the database library, and it is done automatically) |
|
461 | - * |
|
462 | - * @param path, filename, filetype, |
|
463 | - $glued_table, default_visibility |
|
444 | + $buffer = ''; |
|
445 | + if (file_exists($file_name)) { |
|
446 | + $fp = fopen($file_name, 'rb'); |
|
447 | + $buffer = fread ($fp, filesize($file_name)); |
|
448 | + fclose ($fp); |
|
449 | + } |
|
450 | + return $buffer; |
|
451 | + } |
|
464 | 452 | |
465 | - * action: Adds an entry to the document table with the default settings. |
|
466 | - * @author Olivier Cauberghe <[email protected]> |
|
467 | - * @author Roan Embrechts |
|
468 | - * @version 1.2 |
|
469 | - */ |
|
470 | - function set_default_settings($upload_path, $filename, $filetype = 'file', $glued_table, $default_visibility = 'v') |
|
453 | + /** |
|
454 | + * Adds file/folder to document table in database |
|
455 | + * improvement from set_default_settings (see below): |
|
456 | + * take all info from function parameters |
|
457 | + * no global variables needed |
|
458 | + * |
|
459 | + * NOTE $glued_table should already have backticks around it |
|
460 | + * (get it from the database library, and it is done automatically) |
|
461 | + * |
|
462 | + * @param path, filename, filetype, |
|
463 | + $glued_table, default_visibility |
|
464 | + * action: Adds an entry to the document table with the default settings. |
|
465 | + * @author Olivier Cauberghe <[email protected]> |
|
466 | + * @author Roan Embrechts |
|
467 | + * @version 1.2 |
|
468 | + */ |
|
469 | + function set_default_settings($upload_path, $filename, $filetype = 'file', $glued_table, $default_visibility = 'v') |
|
471 | 470 | { |
472 | - if (!$default_visibility) $default_visibility = 'v'; |
|
473 | - |
|
474 | - // Make sure path is not wrongly formed |
|
475 | - $upload_path = !empty($upload_path) ? "/$upload_path" : ''; |
|
476 | - |
|
477 | - $endchar = substr($filename, strlen($filename) - 1, 1); |
|
478 | - if ($endchar == "\\" || $endchar == '/') { |
|
479 | - $filename = substr($filename, 0, strlen($filename) - 1); |
|
480 | - } |
|
481 | - |
|
482 | - $full_file_name = $upload_path.'/'.$filename; |
|
483 | - $full_file_name = str_replace("//", '/', $full_file_name); |
|
484 | - |
|
485 | - $sql_query = "SELECT count(*) as number_existing FROM $glued_table WHERE path='$full_file_name'"; |
|
486 | - $sql_result = Database::query($sql_query); |
|
487 | - $result = Database::fetch_array($sql_result); |
|
488 | - // Determine which query to execute |
|
489 | - if ($result['number_existing'] > 0) { |
|
490 | - // Entry exists, update |
|
491 | - $query = "UPDATE $glued_table SET path='$full_file_name',visibility='$default_visibility', filetype='$filetype' |
|
471 | + if (!$default_visibility) $default_visibility = 'v'; |
|
472 | + |
|
473 | + // Make sure path is not wrongly formed |
|
474 | + $upload_path = !empty($upload_path) ? "/$upload_path" : ''; |
|
475 | + |
|
476 | + $endchar = substr($filename, strlen($filename) - 1, 1); |
|
477 | + if ($endchar == "\\" || $endchar == '/') { |
|
478 | + $filename = substr($filename, 0, strlen($filename) - 1); |
|
479 | + } |
|
480 | + |
|
481 | + $full_file_name = $upload_path.'/'.$filename; |
|
482 | + $full_file_name = str_replace("//", '/', $full_file_name); |
|
483 | + |
|
484 | + $sql_query = "SELECT count(*) as number_existing FROM $glued_table WHERE path='$full_file_name'"; |
|
485 | + $sql_result = Database::query($sql_query); |
|
486 | + $result = Database::fetch_array($sql_result); |
|
487 | + // Determine which query to execute |
|
488 | + if ($result['number_existing'] > 0) { |
|
489 | + // Entry exists, update |
|
490 | + $query = "UPDATE $glued_table SET path='$full_file_name',visibility='$default_visibility', filetype='$filetype' |
|
492 | 491 | WHERE path='$full_file_name'"; |
493 | - } else { |
|
494 | - // No entry exists, create new one |
|
495 | - $query = "INSERT INTO $glued_table (path,visibility,filetype) |
|
492 | + } else { |
|
493 | + // No entry exists, create new one |
|
494 | + $query = "INSERT INTO $glued_table (path,visibility,filetype) |
|
496 | 495 | VALUES ('$full_file_name','$default_visibility','$filetype')"; |
497 | - } |
|
498 | - Database::query($query); |
|
499 | - } |
|
496 | + } |
|
497 | + Database::query($query); |
|
498 | + } |
|
500 | 499 | } |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | /* File case */ |
226 | 226 | if (is_file($source)) { |
227 | 227 | if ($forceMove && !$isWindowsOS && $canExec) { |
228 | - exec('mv ' . $source . ' ' . $target . '/' . $file_name); |
|
228 | + exec('mv '.$source.' '.$target.'/'.$file_name); |
|
229 | 229 | } else { |
230 | - copy($source, $target . '/' . $file_name); |
|
230 | + copy($source, $target.'/'.$file_name); |
|
231 | 231 | unlink($source); |
232 | 232 | } |
233 | 233 | return true; |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | } |
279 | 279 | $destination_trail = $destination.'/'.$dir_name; |
280 | 280 | if (is_dir($destination)) { |
281 | - chdir($orig_dir_path) ; |
|
281 | + chdir($orig_dir_path); |
|
282 | 282 | $handle = opendir($orig_dir_path); |
283 | 283 | |
284 | 284 | while ($element = readdir($handle)) { |
@@ -288,14 +288,14 @@ discard block |
||
288 | 288 | copy($element, $destination_trail.'/'.$element); |
289 | 289 | |
290 | 290 | if ($move) { |
291 | - unlink($element) ; |
|
291 | + unlink($element); |
|
292 | 292 | } |
293 | 293 | } elseif (is_dir($element)) { |
294 | 294 | $dir_to_copy[] = $orig_dir_path.'/'.$element; |
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
298 | - closedir($handle) ; |
|
298 | + closedir($handle); |
|
299 | 299 | |
300 | 300 | if (sizeof($dir_to_copy) > 0) { |
301 | 301 | foreach ($dir_to_copy as $this_dir) { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | |
306 | 306 | if ($move) { |
307 | - rmdir($orig_dir_path) ; |
|
307 | + rmdir($orig_dir_path); |
|
308 | 308 | } |
309 | 309 | chdir($save_dir); |
310 | 310 | } |
@@ -389,17 +389,17 @@ discard block |
||
389 | 389 | // Recursive operation if subdirectories exist |
390 | 390 | $dir_number = sizeof($dir_array); |
391 | 391 | if ($dir_number > 0) { |
392 | - for ($i = 0 ; $i < $dir_number ; $i++) { |
|
392 | + for ($i = 0; $i < $dir_number; $i++) { |
|
393 | 393 | $sub_dir_array = FileManager::list_all_directories($dir_array[$i]); // Function recursivity |
394 | 394 | if (is_array($dir_array) && is_array($sub_dir_array)) { |
395 | - $dir_array = array_merge($dir_array, $sub_dir_array); // Data merge |
|
395 | + $dir_array = array_merge($dir_array, $sub_dir_array); // Data merge |
|
396 | 396 | } |
397 | 397 | } |
398 | 398 | } |
399 | - $result_array = $dir_array; |
|
400 | - chdir($save_dir) ; |
|
399 | + $result_array = $dir_array; |
|
400 | + chdir($save_dir); |
|
401 | 401 | } |
402 | - return $result_array ; |
|
402 | + return $result_array; |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | $buffer = ''; |
445 | 445 | if (file_exists($file_name)) { |
446 | 446 | $fp = fopen($file_name, 'rb'); |
447 | - $buffer = fread ($fp, filesize($file_name)); |
|
448 | - fclose ($fp); |
|
447 | + $buffer = fread($fp, filesize($file_name)); |
|
448 | + fclose($fp); |
|
449 | 449 | } |
450 | 450 | return $buffer; |
451 | 451 | } |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | Database::query($query); |
34 | 34 | break; |
35 | 35 | case 'update': |
36 | - if ($new_path[0] == '.') $new_path = substr($new_path, 1); |
|
36 | + if ($new_path[0] == '.') { |
|
37 | + $new_path = substr($new_path, 1); |
|
38 | + } |
|
37 | 39 | $new_path = str_replace('//', '/', $new_path); |
38 | 40 | |
39 | 41 | // Attempt to update - tested & working for root dir |
@@ -379,7 +381,9 @@ discard block |
||
379 | 381 | chdir($path); |
380 | 382 | $handle = opendir($path); |
381 | 383 | while ($element = readdir($handle)) { |
382 | - if ($element == '.' || $element == '..') continue; |
|
384 | + if ($element == '.' || $element == '..') { |
|
385 | + continue; |
|
386 | + } |
|
383 | 387 | // Skip the current and parent directories |
384 | 388 | if (is_dir($element)) { |
385 | 389 | $dir_array[] = $path.'/'.$element; |
@@ -419,7 +423,9 @@ discard block |
||
419 | 423 | chdir($directory); |
420 | 424 | $handle = opendir($directory); |
421 | 425 | while ($element = readdir($handle)) { |
422 | - if ($element == '.' || $element == '..' || $element == '.htaccess') continue; |
|
426 | + if ($element == '.' || $element == '..' || $element == '.htaccess') { |
|
427 | + continue; |
|
428 | + } |
|
423 | 429 | // Skip the current and parent directories |
424 | 430 | if (!is_dir($element)) { |
425 | 431 | $element_array[] = $directory.'/'.$element; |
@@ -469,7 +475,9 @@ discard block |
||
469 | 475 | */ |
470 | 476 | function set_default_settings($upload_path, $filename, $filetype = 'file', $glued_table, $default_visibility = 'v') |
471 | 477 | { |
472 | - if (!$default_visibility) $default_visibility = 'v'; |
|
478 | + if (!$default_visibility) { |
|
479 | + $default_visibility = 'v'; |
|
480 | + } |
|
473 | 481 | |
474 | 482 | // Make sure path is not wrongly formed |
475 | 483 | $upload_path = !empty($upload_path) ? "/$upload_path" : ''; |
@@ -17,6 +17,7 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @author - Hugues Peeters <[email protected]> |
19 | 19 | * @param - file_name (string) name of a file |
20 | + * @param string $file_name |
|
20 | 21 | * @return - the filenam phps'ized |
21 | 22 | */ |
22 | 23 | function php2phps($file_name) { |
@@ -73,7 +74,7 @@ discard block |
||
73 | 74 | * Returns the name without extension, used for the title |
74 | 75 | * |
75 | 76 | * @param string $name |
76 | - * @return name without the extension |
|
77 | + * @return string without the extension |
|
77 | 78 | */ |
78 | 79 | function get_document_title($name) { |
79 | 80 | // If they upload .htaccess... |
@@ -86,7 +87,7 @@ discard block |
||
86 | 87 | * This function checks if the upload succeeded |
87 | 88 | * |
88 | 89 | * @param array $uploaded_file ($_FILES) |
89 | - * @return true if upload succeeded |
|
90 | + * @return boolean if upload succeeded |
|
90 | 91 | */ |
91 | 92 | function process_uploaded_file($uploaded_file, $show_output = true) |
92 | 93 | { |
@@ -698,6 +699,8 @@ discard block |
||
698 | 699 | * @param - dir (string) - Path of the directory |
699 | 700 | * whe the file should be added |
700 | 701 | * @param - max_dir_space (int) - maximum size of the diretory in byte |
702 | + * @param string $dir |
|
703 | + * @param integer $max_dir_space |
|
701 | 704 | * @return - boolean true if there is enough space, |
702 | 705 | * boolean false otherwise |
703 | 706 | * |
@@ -1022,7 +1025,7 @@ discard block |
||
1022 | 1025 | * @param array $courseInfo |
1023 | 1026 | * @param array $userInfo |
1024 | 1027 | * @param array $uploaded_file - follows the $_FILES Structure |
1025 | - * @param string $upload_path - destination of the upload. |
|
1028 | + * @param string $uploadPath - destination of the upload. |
|
1026 | 1029 | * This path is to append to $base_work_dir |
1027 | 1030 | * @param string $base_work_dir - base working directory of the module |
1028 | 1031 | * @param int $maxFilledSpace - amount of bytes to not exceed in the base |
@@ -1201,7 +1204,7 @@ discard block |
||
1201 | 1204 | * @param bool $save_visibility |
1202 | 1205 | * @param int $group_id |
1203 | 1206 | * @param int $session_id Session ID, if any |
1204 | - * @return int id if inserted document |
|
1207 | + * @return string|false id if inserted document |
|
1205 | 1208 | */ |
1206 | 1209 | function add_document( |
1207 | 1210 | $_course, |
@@ -1337,7 +1340,7 @@ discard block |
||
1337 | 1340 | * |
1338 | 1341 | * @author Olivier Cauberghe <[email protected]> |
1339 | 1342 | * @param path+filename eg: /main/document/document.php |
1340 | - * @return The directory depth |
|
1343 | + * @return integer directory depth |
|
1341 | 1344 | */ |
1342 | 1345 | function get_levels($filename) { |
1343 | 1346 | $levels = explode('/', $filename); |
@@ -1354,6 +1357,7 @@ discard block |
||
1354 | 1357 | * @author Olivier Cauberghe <[email protected]> |
1355 | 1358 | * @param path,filename |
1356 | 1359 | * action: Adds an entry to the document table with the default settings. |
1360 | + * @param string $upload_path |
|
1357 | 1361 | */ |
1358 | 1362 | function set_default_settings($upload_path, $filename, $filetype = 'file') |
1359 | 1363 | { |
@@ -1778,6 +1782,7 @@ discard block |
||
1778 | 1782 | |
1779 | 1783 | @author Roan Embrechts |
1780 | 1784 | @version 0.6 |
1785 | + * @param string $buffer |
|
1781 | 1786 | */ |
1782 | 1787 | function api_replace_links_in_string($upload_path, $buffer) { |
1783 | 1788 | // Search for hyperlinks |
@@ -2013,7 +2018,6 @@ discard block |
||
2013 | 2018 | * @param int $groupId |
2014 | 2019 | * @param bool $output |
2015 | 2020 | * @param array $parent |
2016 | - * @param string $uploadPath |
|
2017 | 2021 | * |
2018 | 2022 | */ |
2019 | 2023 | function add_all_documents_in_folder_to_database( |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | $name_no_ext = substr($name, 0, strlen($name) - strlen(strstr($name, $ext))); |
64 | 64 | $n = 0; |
65 | 65 | $unique = ''; |
66 | - while (file_exists($path . $name_no_ext . $unique . $ext)) { |
|
67 | - $unique = '_' . ++$n; |
|
66 | + while (file_exists($path.$name_no_ext.$unique.$ext)) { |
|
67 | + $unique = '_'.++$n; |
|
68 | 68 | } |
69 | - return $name_no_ext . $unique . $ext; |
|
69 | + return $name_no_ext.$unique.$ext; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | // Not used at the moment, but could be handy if we want to limit the size of an upload (e.g. image upload in html editor). |
106 | 106 | $max_file_size = intval($_POST['MAX_FILE_SIZE']); |
107 | 107 | if ($show_output) { |
108 | - Display::display_error_message(get_lang('UplExceedMaxPostSize'). format_file_size($max_file_size)); |
|
108 | + Display::display_error_message(get_lang('UplExceedMaxPostSize').format_file_size($max_file_size)); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | return false; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | case 4: |
120 | 120 | // No file was uploaded. |
121 | 121 | if ($show_output) { |
122 | - Display::display_error_message(get_lang('UplNoFileUploaded').' '. get_lang('UplSelectFileFirst')); |
|
122 | + Display::display_error_message(get_lang('UplNoFileUploaded').' '.get_lang('UplSelectFileFirst')); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | return false; |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | // Display success message with extra info to user |
460 | 460 | if ($output) { |
461 | 461 | Display::display_confirmation_message( |
462 | - get_lang('UplUploadSucceeded') . '<br /> ' . $documentTitle . ' ' . get_lang('UplFileOverwritten'), |
|
462 | + get_lang('UplUploadSucceeded').'<br /> '.$documentTitle.' '.get_lang('UplFileOverwritten'), |
|
463 | 463 | false |
464 | 464 | ); |
465 | 465 | } |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | // Display success message to user |
584 | 584 | if ($output) { |
585 | 585 | Display::display_confirmation_message( |
586 | - get_lang('UplUploadSucceeded') . '<br />' . get_lang('UplFileSavedAs') .' '.$documentTitle, |
|
586 | + get_lang('UplUploadSucceeded').'<br />'.get_lang('UplFileSavedAs').' '.$documentTitle, |
|
587 | 587 | false |
588 | 588 | ); |
589 | 589 | } |
@@ -730,12 +730,12 @@ discard block |
||
730 | 730 | function dir_total_space($dir_path) |
731 | 731 | { |
732 | 732 | $save_dir = getcwd(); |
733 | - chdir($dir_path) ; |
|
733 | + chdir($dir_path); |
|
734 | 734 | $handle = opendir($dir_path); |
735 | 735 | $sumSize = 0; |
736 | 736 | $dirList = array(); |
737 | 737 | while ($element = readdir($handle)) { |
738 | - if ( $element == '.' || $element == '..') { |
|
738 | + if ($element == '.' || $element == '..') { |
|
739 | 739 | continue; // Skip the current and parent directories |
740 | 740 | } |
741 | 741 | if (is_file($element)) { |
@@ -746,11 +746,11 @@ discard block |
||
746 | 746 | } |
747 | 747 | } |
748 | 748 | |
749 | - closedir($handle) ; |
|
749 | + closedir($handle); |
|
750 | 750 | |
751 | 751 | if (sizeof($dirList) > 0) { |
752 | 752 | foreach ($dirList as $j) { |
753 | - $sizeDir = dir_total_space($j); // Recursivity |
|
753 | + $sizeDir = dir_total_space($j); // Recursivity |
|
754 | 754 | $sumSize += $sizeDir; |
755 | 755 | } |
756 | 756 | } |
@@ -784,63 +784,63 @@ discard block |
||
784 | 784 | |
785 | 785 | static $mime_type = array(); |
786 | 786 | |
787 | - $mime_type[] = 'application/msword'; $extension[] = '.doc'; |
|
788 | - $mime_type[] = 'application/rtf'; $extension[] = '.rtf'; |
|
789 | - $mime_type[] = 'application/vnd.ms-powerpoint'; $extension[] = '.ppt'; |
|
790 | - $mime_type[] = 'application/vnd.ms-excel'; $extension[] = '.xls'; |
|
791 | - $mime_type[] = 'application/pdf'; $extension[] = '.pdf'; |
|
792 | - $mime_type[] = 'application/postscript'; $extension[] = '.ps'; |
|
793 | - $mime_type[] = 'application/mac-binhex40'; $extension[] = '.hqx'; |
|
794 | - $mime_type[] = 'application/x-gzip'; $extension[] = 'tar.gz'; |
|
795 | - $mime_type[] = 'application/x-shockwave-flash'; $extension[] = '.swf'; |
|
796 | - $mime_type[] = 'application/x-stuffit'; $extension[] = '.sit'; |
|
797 | - $mime_type[] = 'application/x-tar'; $extension[] = '.tar'; |
|
798 | - $mime_type[] = 'application/zip'; $extension[] = '.zip'; |
|
799 | - $mime_type[] = 'application/x-tar'; $extension[] = '.tar'; |
|
800 | - $mime_type[] = 'text/html'; $extension[] = '.html'; |
|
801 | - $mime_type[] = 'text/plain'; $extension[] = '.txt'; |
|
802 | - $mime_type[] = 'text/rtf'; $extension[] = '.rtf'; |
|
803 | - $mime_type[] = 'img/gif'; $extension[] = '.gif'; |
|
804 | - $mime_type[] = 'img/jpeg'; $extension[] = '.jpg'; |
|
805 | - $mime_type[] = 'img/png'; $extension[] = '.png'; |
|
806 | - $mime_type[] = 'audio/midi'; $extension[] = '.mid'; |
|
807 | - $mime_type[] = 'audio/mpeg'; $extension[] = '.mp3'; |
|
808 | - $mime_type[] = 'audio/x-aiff'; $extension[] = '.aif'; |
|
809 | - $mime_type[] = 'audio/x-pn-realaudio'; $extension[] = '.rm'; |
|
810 | - $mime_type[] = 'audio/x-pn-realaudio-plugin'; $extension[] = '.rpm'; |
|
811 | - $mime_type[] = 'audio/x-wav'; $extension[] = '.wav'; |
|
812 | - $mime_type[] = 'video/mpeg'; $extension[] = '.mpg'; |
|
813 | - $mime_type[] = 'video/mpeg4-generic'; $extension[] = '.mp4'; |
|
814 | - $mime_type[] = 'video/quicktime'; $extension[] = '.mov'; |
|
815 | - $mime_type[] = 'video/x-msvideo'; $extension[] = '.avi'; |
|
816 | - |
|
817 | - $mime_type[] = 'video/x-ms-wmv'; $extension[] = '.wmv'; |
|
818 | - $mime_type[] = 'video/x-flv'; $extension[] = '.flv'; |
|
819 | - $mime_type[] = 'image/svg+xml'; $extension[] = '.svg'; |
|
820 | - $mime_type[] = 'image/svg+xml'; $extension[] = '.svgz'; |
|
821 | - $mime_type[] = 'video/ogg'; $extension[] = '.ogv'; |
|
822 | - $mime_type[] = 'audio/ogg'; $extension[] = '.oga'; |
|
823 | - $mime_type[] = 'application/ogg'; $extension[] = '.ogg'; |
|
824 | - $mime_type[] = 'application/ogg'; $extension[] = '.ogx'; |
|
825 | - $mime_type[] = 'application/x-freemind'; $extension[] = '.mm'; |
|
826 | - |
|
827 | - $mime_type[] = 'application/vnd.ms-word.document.macroEnabled.12'; $extension[] = '.docm'; |
|
828 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; $extension[] = '.docx'; |
|
829 | - $mime_type[] = 'application/vnd.ms-word.template.macroEnabled.12'; $extension[] = '.dotm'; |
|
830 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; $extension[] = '.dotx'; |
|
831 | - $mime_type[] = 'application/vnd.ms-powerpoint.template.macroEnabled.12'; $extension[] = '.potm'; |
|
832 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.template'; $extension[] = '.potx'; |
|
833 | - $mime_type[] = 'application/vnd.ms-powerpoint.addin.macroEnabled.12'; $extension[] = '.ppam'; |
|
834 | - $mime_type[] = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12'; $extension[] = '.ppsm'; |
|
835 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'; $extension[] = '.ppsx'; |
|
836 | - $mime_type[] = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12'; $extension[] = '.pptm'; |
|
837 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; $extension[] = '.pptx'; |
|
838 | - $mime_type[] = 'application/vnd.ms-excel.addin.macroEnabled.12'; $extension[] = '.xlam'; |
|
839 | - $mime_type[] = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'; $extension[] = '.xlsb'; |
|
840 | - $mime_type[] = 'application/vnd.ms-excel.sheet.macroEnabled.12'; $extension[] = '.xlsm'; |
|
841 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $extension[] = '.xlsx'; |
|
842 | - $mime_type[] = 'application/vnd.ms-excel.template.macroEnabled.12'; $extension[] = '.xltm'; |
|
843 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; $extension[] = '.xltx'; |
|
787 | + $mime_type[] = 'application/msword'; $extension[] = '.doc'; |
|
788 | + $mime_type[] = 'application/rtf'; $extension[] = '.rtf'; |
|
789 | + $mime_type[] = 'application/vnd.ms-powerpoint'; $extension[] = '.ppt'; |
|
790 | + $mime_type[] = 'application/vnd.ms-excel'; $extension[] = '.xls'; |
|
791 | + $mime_type[] = 'application/pdf'; $extension[] = '.pdf'; |
|
792 | + $mime_type[] = 'application/postscript'; $extension[] = '.ps'; |
|
793 | + $mime_type[] = 'application/mac-binhex40'; $extension[] = '.hqx'; |
|
794 | + $mime_type[] = 'application/x-gzip'; $extension[] = 'tar.gz'; |
|
795 | + $mime_type[] = 'application/x-shockwave-flash'; $extension[] = '.swf'; |
|
796 | + $mime_type[] = 'application/x-stuffit'; $extension[] = '.sit'; |
|
797 | + $mime_type[] = 'application/x-tar'; $extension[] = '.tar'; |
|
798 | + $mime_type[] = 'application/zip'; $extension[] = '.zip'; |
|
799 | + $mime_type[] = 'application/x-tar'; $extension[] = '.tar'; |
|
800 | + $mime_type[] = 'text/html'; $extension[] = '.html'; |
|
801 | + $mime_type[] = 'text/plain'; $extension[] = '.txt'; |
|
802 | + $mime_type[] = 'text/rtf'; $extension[] = '.rtf'; |
|
803 | + $mime_type[] = 'img/gif'; $extension[] = '.gif'; |
|
804 | + $mime_type[] = 'img/jpeg'; $extension[] = '.jpg'; |
|
805 | + $mime_type[] = 'img/png'; $extension[] = '.png'; |
|
806 | + $mime_type[] = 'audio/midi'; $extension[] = '.mid'; |
|
807 | + $mime_type[] = 'audio/mpeg'; $extension[] = '.mp3'; |
|
808 | + $mime_type[] = 'audio/x-aiff'; $extension[] = '.aif'; |
|
809 | + $mime_type[] = 'audio/x-pn-realaudio'; $extension[] = '.rm'; |
|
810 | + $mime_type[] = 'audio/x-pn-realaudio-plugin'; $extension[] = '.rpm'; |
|
811 | + $mime_type[] = 'audio/x-wav'; $extension[] = '.wav'; |
|
812 | + $mime_type[] = 'video/mpeg'; $extension[] = '.mpg'; |
|
813 | + $mime_type[] = 'video/mpeg4-generic'; $extension[] = '.mp4'; |
|
814 | + $mime_type[] = 'video/quicktime'; $extension[] = '.mov'; |
|
815 | + $mime_type[] = 'video/x-msvideo'; $extension[] = '.avi'; |
|
816 | + |
|
817 | + $mime_type[] = 'video/x-ms-wmv'; $extension[] = '.wmv'; |
|
818 | + $mime_type[] = 'video/x-flv'; $extension[] = '.flv'; |
|
819 | + $mime_type[] = 'image/svg+xml'; $extension[] = '.svg'; |
|
820 | + $mime_type[] = 'image/svg+xml'; $extension[] = '.svgz'; |
|
821 | + $mime_type[] = 'video/ogg'; $extension[] = '.ogv'; |
|
822 | + $mime_type[] = 'audio/ogg'; $extension[] = '.oga'; |
|
823 | + $mime_type[] = 'application/ogg'; $extension[] = '.ogg'; |
|
824 | + $mime_type[] = 'application/ogg'; $extension[] = '.ogx'; |
|
825 | + $mime_type[] = 'application/x-freemind'; $extension[] = '.mm'; |
|
826 | + |
|
827 | + $mime_type[] = 'application/vnd.ms-word.document.macroEnabled.12'; $extension[] = '.docm'; |
|
828 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; $extension[] = '.docx'; |
|
829 | + $mime_type[] = 'application/vnd.ms-word.template.macroEnabled.12'; $extension[] = '.dotm'; |
|
830 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; $extension[] = '.dotx'; |
|
831 | + $mime_type[] = 'application/vnd.ms-powerpoint.template.macroEnabled.12'; $extension[] = '.potm'; |
|
832 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.template'; $extension[] = '.potx'; |
|
833 | + $mime_type[] = 'application/vnd.ms-powerpoint.addin.macroEnabled.12'; $extension[] = '.ppam'; |
|
834 | + $mime_type[] = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12'; $extension[] = '.ppsm'; |
|
835 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'; $extension[] = '.ppsx'; |
|
836 | + $mime_type[] = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12'; $extension[] = '.pptm'; |
|
837 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; $extension[] = '.pptx'; |
|
838 | + $mime_type[] = 'application/vnd.ms-excel.addin.macroEnabled.12'; $extension[] = '.xlam'; |
|
839 | + $mime_type[] = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'; $extension[] = '.xlsb'; |
|
840 | + $mime_type[] = 'application/vnd.ms-excel.sheet.macroEnabled.12'; $extension[] = '.xlsm'; |
|
841 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $extension[] = '.xlsx'; |
|
842 | + $mime_type[] = 'application/vnd.ms-excel.template.macroEnabled.12'; $extension[] = '.xltm'; |
|
843 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; $extension[] = '.xltx'; |
|
844 | 844 | |
845 | 845 | // Test on PC (files with no extension get application/octet-stream) |
846 | 846 | //$mime_type[] = 'application/octet-stream'; $extension[] = '.ext'; |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | |
850 | 850 | foreach ($mime_type as $key => & $type) { |
851 | 851 | if ($type == $file_type) { |
852 | - $file_name .= $extension[$key]; |
|
852 | + $file_name .= $extension[$key]; |
|
853 | 853 | break; |
854 | 854 | } |
855 | 855 | } |
@@ -957,12 +957,12 @@ discard block |
||
957 | 957 | } |
958 | 958 | |
959 | 959 | // It happens on Linux that $upload_path sometimes doesn't start with '/' |
960 | - if ($upload_path[0] != '/' && substr($base_work_dir,-1,1) != '/') { |
|
960 | + if ($upload_path[0] != '/' && substr($base_work_dir, -1, 1) != '/') { |
|
961 | 961 | $upload_path = '/'.$upload_path; |
962 | 962 | } |
963 | 963 | |
964 | 964 | if ($upload_path[strlen($upload_path) - 1] == '/') { |
965 | - $upload_path=substr($upload_path, 0, -1); |
|
965 | + $upload_path = substr($upload_path, 0, -1); |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | /* Uncompressing phase */ |
@@ -974,15 +974,15 @@ discard block |
||
974 | 974 | - add it to the database |
975 | 975 | - parse & change relative html links |
976 | 976 | */ |
977 | - if (PHP_OS == 'Linux' && ! get_cfg_var('safe_mode') && false) { // *** UGent, changed by OC *** |
|
977 | + if (PHP_OS == 'Linux' && !get_cfg_var('safe_mode') && false) { // *** UGent, changed by OC *** |
|
978 | 978 | // Shell Method - if this is possible, it gains some speed |
979 | - exec("unzip -d \"".$base_work_dir.$upload_path."/\"".$uploaded_file['name']." " .$uploaded_file['tmp_name']); |
|
979 | + exec("unzip -d \"".$base_work_dir.$upload_path."/\"".$uploaded_file['name']." ".$uploaded_file['tmp_name']); |
|
980 | 980 | } else { |
981 | 981 | // PHP method - slower... |
982 | 982 | $save_dir = getcwd(); |
983 | 983 | chdir($base_work_dir.$upload_path); |
984 | 984 | $unzippingState = $zip_file->extract(); |
985 | - for ($j=0; $j < count($unzippingState); $j++) { |
|
985 | + for ($j = 0; $j < count($unzippingState); $j++) { |
|
986 | 986 | $state = $unzippingState[$j]; |
987 | 987 | |
988 | 988 | // Fix relative links in html files |
@@ -996,8 +996,8 @@ discard block |
||
996 | 996 | if (is_dir($base_work_dir.$upload_path.'/'.$file)) $filetype = 'folder'; |
997 | 997 | |
998 | 998 | $safe_file = api_replace_dangerous_char($file, 'strict'); |
999 | - @rename($base_work_dir.$upload_path.'/'.$file,$base_work_dir.$upload_path.'/'.$safe_file); |
|
1000 | - set_default_settings($upload_path, $safe_file,$filetype); |
|
999 | + @rename($base_work_dir.$upload_path.'/'.$file, $base_work_dir.$upload_path.'/'.$safe_file); |
|
1000 | + set_default_settings($upload_path, $safe_file, $filetype); |
|
1001 | 1001 | } |
1002 | 1002 | } |
1003 | 1003 | |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | $zip = new PclZip($uploaded_file['tmp_name']); |
1048 | 1048 | |
1049 | 1049 | // Check the zip content (real size and file extension) |
1050 | - $zip_content_array = (array)$zip->listContent(); |
|
1050 | + $zip_content_array = (array) $zip->listContent(); |
|
1051 | 1051 | |
1052 | 1052 | $realSize = 0; |
1053 | 1053 | foreach ($zip_content_array as & $this_content) { |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | function filter_extension(&$filename) |
1144 | 1144 | { |
1145 | 1145 | if (substr($filename, -1) == '/') { |
1146 | - return 1; // Authorize directories |
|
1146 | + return 1; // Authorize directories |
|
1147 | 1147 | } |
1148 | 1148 | $blacklist = api_get_setting('upload_extensions_list_type'); |
1149 | 1149 | if ($blacklist != 'whitelist') { // if = blacklist |
@@ -1369,9 +1369,9 @@ discard block |
||
1369 | 1369 | $upload_path = str_replace('//', '/', $upload_path); |
1370 | 1370 | |
1371 | 1371 | if ($upload_path == '/') { |
1372 | - $upload_path=''; |
|
1372 | + $upload_path = ''; |
|
1373 | 1373 | } elseif (!empty($upload_path) && $upload_path[0] != '/') { |
1374 | - $upload_path="/$upload_path"; |
|
1374 | + $upload_path = "/$upload_path"; |
|
1375 | 1375 | } |
1376 | 1376 | |
1377 | 1377 | $endchar = substr($filename, strlen($filename) - 1, 1); |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | $img_path_list = array(); |
1410 | 1410 | |
1411 | 1411 | if (!$fp = fopen($html_file, 'r')) { |
1412 | - return ; |
|
1412 | + return; |
|
1413 | 1413 | } |
1414 | 1414 | |
1415 | 1415 | // Aearch and store occurences of the <img> tag in an array |
@@ -1429,7 +1429,7 @@ discard block |
||
1429 | 1429 | $img_tag_list = $matches[0]; |
1430 | 1430 | } |
1431 | 1431 | |
1432 | - fclose ($fp); |
|
1432 | + fclose($fp); |
|
1433 | 1433 | unset($buffer); |
1434 | 1434 | |
1435 | 1435 | // Search the image file path from all the <IMG> tag detected |
@@ -1542,7 +1542,7 @@ discard block |
||
1542 | 1542 | WHERE |
1543 | 1543 | c_id = $course_id AND |
1544 | 1544 | ( |
1545 | - path = '" . $systemFolderName . "' |
|
1545 | + path = '".$systemFolderName."' |
|
1546 | 1546 | ) |
1547 | 1547 | "; |
1548 | 1548 | |
@@ -1693,7 +1693,7 @@ discard block |
||
1693 | 1693 | |
1694 | 1694 | // Fix the image tags |
1695 | 1695 | |
1696 | - for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb ; $i++) { |
|
1696 | + for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb; $i++) { |
|
1697 | 1697 | $replace_what = $original_img_path[$i]; |
1698 | 1698 | // We only need the directory and the filename /path/to/file_html_files/missing_file.gif -> file_html_files/missing_file.gif |
1699 | 1699 | $exploded_file_path = explode('/', $new_img_path[$i]); |
@@ -1734,7 +1734,7 @@ discard block |
||
1734 | 1734 | .'</body>' |
1735 | 1735 | .'</html>'; |
1736 | 1736 | if (file_exists($file_path)) { |
1737 | - if (!($fp = fopen ($file_path, 'w'))) { |
|
1737 | + if (!($fp = fopen($file_path, 'w'))) { |
|
1738 | 1738 | return false; |
1739 | 1739 | } |
1740 | 1740 | return fwrite($fp, $file_content); |
@@ -1754,7 +1754,7 @@ discard block |
||
1754 | 1754 | // Open the file |
1755 | 1755 | if (file_exists($full_file_name)) { |
1756 | 1756 | $fp = fopen($full_file_name, 'r'); |
1757 | - $buffer = fread ($fp, filesize ($full_file_name)); |
|
1757 | + $buffer = fread($fp, filesize($full_file_name)); |
|
1758 | 1758 | |
1759 | 1759 | // Parse the contents |
1760 | 1760 | $new_html_content = api_replace_links_in_string($upload_path, $buffer); |
@@ -1897,7 +1897,7 @@ discard block |
||
1897 | 1897 | |
1898 | 1898 | foreach ($tag_list as & $this_tag) { |
1899 | 1899 | //Display::display_normal_message(htmlentities($this_tag)); //debug |
1900 | - if ( preg_match("~".$param_name."[\s]*=[\s]*[\"]{1}([^\"]+)[\"]{1}~i", $this_tag, $matches)) { |
|
1900 | + if (preg_match("~".$param_name."[\s]*=[\s]*[\"]{1}([^\"]+)[\"]{1}~i", $this_tag, $matches)) { |
|
1901 | 1901 | $file_path_list[] = $matches[1]; // older |
1902 | 1902 | $href_list[] = $matches[0]; // to also add target="_self" |
1903 | 1903 | } |
@@ -1918,9 +1918,9 @@ discard block |
||
1918 | 1918 | |
1919 | 1919 | // Fix the link to use download.php or showinframes.php |
1920 | 1920 | if (preg_match("/<a([\s]*[\"\/:'=a-z0-9]*){5}href[^<]*>/i", $tag_list[$count])) { |
1921 | - $replace_by[$count] = " $param_name =\"showinframes.php?file=" . $upload_path.$file_path_list[$count]."\" target=\"_self\" "; |
|
1921 | + $replace_by[$count] = " $param_name =\"showinframes.php?file=".$upload_path.$file_path_list[$count]."\" target=\"_self\" "; |
|
1922 | 1922 | } else { |
1923 | - $replace_by[$count] = " $param_name =\"download.php?doc_url=" . $upload_path.$file_path_list[$count]."\" "; |
|
1923 | + $replace_by[$count] = " $param_name =\"download.php?doc_url=".$upload_path.$file_path_list[$count]."\" "; |
|
1924 | 1924 | } |
1925 | 1925 | } else { |
1926 | 1926 | // "mailto" or url already fixed, leave as is |
@@ -1929,7 +1929,7 @@ discard block |
||
1929 | 1929 | } |
1930 | 1930 | } elseif ($is_absolute_hyperlink) { |
1931 | 1931 | //$message .= "Absolute hyperlink, don't change, add target=_self: "; |
1932 | - $replace_by[$count] = " $param_name=\"" . $file_path_list[$count] . "\" target =\"_self\""; |
|
1932 | + $replace_by[$count] = " $param_name=\"".$file_path_list[$count]."\" target =\"_self\""; |
|
1933 | 1933 | } else { |
1934 | 1934 | // Don't change anything |
1935 | 1935 | //$message .= "Local anchor, don't change: "; |
@@ -1974,7 +1974,7 @@ discard block |
||
1974 | 1974 | { |
1975 | 1975 | // Do we need a / or not? |
1976 | 1976 | $added_slash = ($upload_path == '/') ? '' : '/'; |
1977 | - $folder_id = DocumentManager::get_document_id(api_get_course_info(), $upload_path); |
|
1977 | + $folder_id = DocumentManager::get_document_id(api_get_course_info(), $upload_path); |
|
1978 | 1978 | // Build the form |
1979 | 1979 | $form = "<p><strong>".get_lang('MissingImagesDetected')."</strong></p>" |
1980 | 1980 | ."<form method=\"post\" action=\"".api_get_self()."\" enctype=\"multipart/form-data\">" |
@@ -993,7 +993,9 @@ |
||
993 | 993 | if ($file != '.' && $file != '..') { |
994 | 994 | |
995 | 995 | $filetype = 'file'; |
996 | - if (is_dir($base_work_dir.$upload_path.'/'.$file)) $filetype = 'folder'; |
|
996 | + if (is_dir($base_work_dir.$upload_path.'/'.$file)) { |
|
997 | + $filetype = 'folder'; |
|
998 | + } |
|
997 | 999 | |
998 | 1000 | $safe_file = api_replace_dangerous_char($file, 'strict'); |
999 | 1001 | @rename($base_work_dir.$upload_path.'/'.$file,$base_work_dir.$upload_path.'/'.$safe_file); |
@@ -145,6 +145,7 @@ |
||
145 | 145 | |
146 | 146 | /** |
147 | 147 | * @param array $dates result of parseDateRange() |
148 | + * @param string $format |
|
148 | 149 | * |
149 | 150 | * @return bool |
150 | 151 | */ |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | class DateRangePicker extends HTML_QuickForm_text |
8 | 8 | { |
9 | 9 | /** |
10 | - * Constructor |
|
11 | - */ |
|
10 | + * Constructor |
|
11 | + */ |
|
12 | 12 | public function __construct($elementName = null, $elementLabel = null, $attributes = null) |
13 | 13 | { |
14 | 14 | if (!isset($attributes['id'])) { |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | - * @param array $dates result of parseDateRange() |
|
148 | - * |
|
149 | - * @return bool |
|
150 | - */ |
|
147 | + * @param array $dates result of parseDateRange() |
|
148 | + * |
|
149 | + * @return bool |
|
150 | + */ |
|
151 | 151 | public function validateDates($dates, $format = null) |
152 | 152 | { |
153 | 153 | if (empty($dates['start']) || empty($dates['end'])) { |
@@ -88,7 +88,7 @@ |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | $timePicker = 'true'; |
91 | - $timePickerValue = $this->getAttribute('timePicker'); |
|
91 | + $timePickerValue = $this->getAttribute('timePicker'); |
|
92 | 92 | if (!empty($timePickerValue)) { |
93 | 93 | $timePicker = $timePickerValue; |
94 | 94 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @param string $label |
214 | 214 | * @param array $attributes |
215 | 215 | * |
216 | - * @return mixed |
|
216 | + * @return HTML_QuickForm_element |
|
217 | 217 | */ |
218 | 218 | public function addDatePicker($name, $label, $attributes = []) |
219 | 219 | { |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param string $label |
226 | 226 | * @param array $attributes |
227 | 227 | * |
228 | - * @return mixed |
|
228 | + * @return HTML_QuickForm_element |
|
229 | 229 | */ |
230 | 230 | public function addDateTimePicker($name, $label, $attributes = []) |
231 | 231 | { |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | * @param array $options |
689 | 689 | * @param array $attributes |
690 | 690 | * |
691 | - * @return HTML_QuickForm_radio |
|
691 | + * @return HTML_QuickForm_group |
|
692 | 692 | */ |
693 | 693 | public function addRadio($name, $label, $options = array(), $attributes = array()) |
694 | 694 | { |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | * @param string $name |
818 | 818 | * @param string $label |
819 | 819 | * |
820 | - * @return mixed |
|
820 | + * @return HTML_QuickForm_element |
|
821 | 821 | */ |
822 | 822 | public function addButtonAdvancedSettings($name, $label = '') |
823 | 823 | { |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | /** |
915 | 915 | * This function has been created for avoiding changes directly within QuickForm class. |
916 | 916 | * When we use it, the element is threated as 'required' to be dealt during validation. |
917 | - * @param array $element The array of elements |
|
917 | + * @param array $elements The array of elements |
|
918 | 918 | * @param string $message The message displayed |
919 | 919 | */ |
920 | 920 | public function add_multiple_required_rule($elements, $message) |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $renderer->setHeaderTemplate('<legend>{header}</legend>'); |
100 | 100 | |
101 | 101 | //Set required field template |
102 | - $this->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>'); |
|
102 | + $this->setRequiredNote('<span class="form_required">*</span> <small>'.get_lang('ThisFieldIsRequired').'</small>'); |
|
103 | 103 | $noteTemplate = <<<EOT |
104 | 104 | <div class="form-group"> |
105 | 105 | <div class="col-sm-offset-2 col-sm-10">{requiredNote}</div> |
@@ -851,9 +851,9 @@ discard block |
||
851 | 851 | $label = get_lang('PleaseStandBy'); |
852 | 852 | } |
853 | 853 | $this->with_progress_bar = true; |
854 | - $this->updateAttributes("onsubmit=\"javascript: myUpload.start('dynamic_div','".Display::returnIconPath('progress_bar.gif')."','" . $label . "','" . $this->getAttribute('id') . "')\""); |
|
855 | - $this->addElement('html', '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/upload.js" type="text/javascript"></script>'); |
|
856 | - $this->addElement('html', '<script type="text/javascript">var myUpload = new upload(' . (abs(intval($delay)) * 1000) . ');</script>'); |
|
854 | + $this->updateAttributes("onsubmit=\"javascript: myUpload.start('dynamic_div','".Display::returnIconPath('progress_bar.gif')."','".$label."','".$this->getAttribute('id')."')\""); |
|
855 | + $this->addElement('html', '<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/upload.js" type="text/javascript"></script>'); |
|
856 | + $this->addElement('html', '<script type="text/javascript">var myUpload = new upload('.(abs(intval($delay)) * 1000).');</script>'); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | /** |
@@ -870,11 +870,11 @@ discard block |
||
870 | 870 | return; |
871 | 871 | } |
872 | 872 | |
873 | - $xajax_upload = new xajax(api_get_path(WEB_LIBRARY_PATH) . 'upload.xajax.php'); |
|
873 | + $xajax_upload = new xajax(api_get_path(WEB_LIBRARY_PATH).'upload.xajax.php'); |
|
874 | 874 | |
875 | 875 | $xajax_upload->registerFunction('updateProgress'); |
876 | 876 | // IMPORTANT : must be the first element of the form |
877 | - $el = $this->insertElementBefore(FormValidator::createElement('html', '<input type="hidden" name="UPLOAD_IDENTIFIER" value="' . $upload_id . '" />'), $element_after); |
|
877 | + $el = $this->insertElementBefore(FormValidator::createElement('html', '<input type="hidden" name="UPLOAD_IDENTIFIER" value="'.$upload_id.'" />'), $element_after); |
|
878 | 878 | |
879 | 879 | $this->addElement('html', '<br />'); |
880 | 880 | |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | $this->addElement( |
883 | 883 | 'html', |
884 | 884 | '<div id="dynamic_div_container" style="display:none"> |
885 | - <div id="dynamic_div_label">' . get_lang('UploadFile') . '</div> |
|
885 | + <div id="dynamic_div_label">' . get_lang('UploadFile').'</div> |
|
886 | 886 | <div id="dynamic_div_frame" style="width:214px; height:12px; border:1px solid grey; background-image:url(' . Display::returnIconPath('real_upload_frame.gif').');"> |
887 | 887 | <div id="dynamic_div_filled" style="width:0%;height:100%;background-image:url(' . Display::returnIconPath('real_upload_step.gif').');background-repeat:repeat-x;background-position:center;"></div> |
888 | 888 | </div> |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | $this->addElement('html', ' |
894 | 894 | <div id="dynamic_div_waiter_container" style="display:none"> |
895 | 895 | <div id="dynamic_div_waiter_label"> |
896 | - ' . get_lang('SlideshowConversion') . ' |
|
896 | + ' . get_lang('SlideshowConversion').' |
|
897 | 897 | </div> |
898 | 898 | <div id="dynamic_div_waiter_frame"> |
899 | 899 | '.Display::return_icon('real_upload_frame.gif').' |
@@ -903,18 +903,18 @@ discard block |
||
903 | 903 | } |
904 | 904 | |
905 | 905 | // Get the xajax code |
906 | - $this->addElement('html', $xajax_upload->getJavascript(api_get_path(WEB_LIBRARY_PATH) . 'xajax')); |
|
906 | + $this->addElement('html', $xajax_upload->getJavascript(api_get_path(WEB_LIBRARY_PATH).'xajax')); |
|
907 | 907 | |
908 | 908 | // Get the upload code |
909 | - $this->addElement('html', '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/upload.js" type="text/javascript"></script>'); |
|
910 | - $this->addElement('html', '<script type="text/javascript">var myUpload = new upload(' . (abs(intval($delay)) * 1000) . ');</script>'); |
|
909 | + $this->addElement('html', '<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/upload.js" type="text/javascript"></script>'); |
|
910 | + $this->addElement('html', '<script type="text/javascript">var myUpload = new upload('.(abs(intval($delay)) * 1000).');</script>'); |
|
911 | 911 | |
912 | 912 | if (!$wait_after_upload) { |
913 | 913 | $wait_after_upload = 0; |
914 | 914 | } |
915 | 915 | |
916 | 916 | // Add the upload event |
917 | - $this->updateAttributes("onsubmit=\"javascript: myUpload.startRealUpload('dynamic_div','" . $upload_id . "','" . $this->getAttribute('id') . "'," . $wait_after_upload . ")\""); |
|
917 | + $this->updateAttributes("onsubmit=\"javascript: myUpload.startRealUpload('dynamic_div','".$upload_id."','".$this->getAttribute('id')."',".$wait_after_upload.")\""); |
|
918 | 918 | } |
919 | 919 | |
920 | 920 | /** |
@@ -25,8 +25,7 @@ |
||
25 | 25 | * Get allowed tags |
26 | 26 | * @param int $mode NO_HTML, STUDENT_HTML, TEACHER_HTML, |
27 | 27 | * STUDENT_HTML_FULLPAGE or TEACHER_HTML_FULLPAGE |
28 | - * @param boolean $fullpage If true, the allowed tags for full-page editing |
|
29 | - * are returned. |
|
28 | + * @return string |
|
30 | 29 | */ |
31 | 30 | static function get_allowed_tags($mode) |
32 | 31 | { |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | function validate($html, $mode = NO_HTML) |
18 | 18 | { |
19 | - $allowed_tags = self::get_allowed_tags ($mode, $fullpage); |
|
19 | + $allowed_tags = self::get_allowed_tags($mode, $fullpage); |
|
20 | 20 | $cleaned_html = kses($html, $allowed_tags); |
21 | 21 | return $html == $cleaned_html; |
22 | 22 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | // Include the allowed tags. |
34 | 34 | //include(dirname(__FILE__).'/allowed_tags.inc.php'); |
35 | 35 | global $allowed_tags_student, $allowed_tags_student_full_page, $allowed_tags_teacher, $allowed_tags_teacher_full_page; |
36 | - switch($mode) |
|
36 | + switch ($mode) |
|
37 | 37 | { |
38 | 38 | case NO_HTML: |
39 | 39 | return array(); |
@@ -9,7 +9,6 @@ |
||
9 | 9 | { |
10 | 10 | /** |
11 | 11 | * @param $value array Uploaded file info (from $_FILES) |
12 | - * @param null $options |
|
13 | 12 | * @return bool |
14 | 13 | */ |
15 | 14 | public function validate($elementValue, $maxSize) |
@@ -7,22 +7,22 @@ |
||
7 | 7 | */ |
8 | 8 | class HTML_QuickForm_Rule_MaxFileSize extends HTML_QuickForm_Rule |
9 | 9 | { |
10 | - /** |
|
11 | - * @param $value array Uploaded file info (from $_FILES) |
|
12 | - * @param null $options |
|
13 | - * @return bool |
|
14 | - */ |
|
15 | - public function validate($elementValue, $maxSize) |
|
16 | - { |
|
17 | - if (!empty($elementValue['error']) && |
|
18 | - (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error']) |
|
19 | - ) { |
|
20 | - return false; |
|
21 | - } |
|
22 | - if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { |
|
23 | - return true; |
|
24 | - } |
|
10 | + /** |
|
11 | + * @param $value array Uploaded file info (from $_FILES) |
|
12 | + * @param null $options |
|
13 | + * @return bool |
|
14 | + */ |
|
15 | + public function validate($elementValue, $maxSize) |
|
16 | + { |
|
17 | + if (!empty($elementValue['error']) && |
|
18 | + (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error']) |
|
19 | + ) { |
|
20 | + return false; |
|
21 | + } |
|
22 | + if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { |
|
23 | + return true; |
|
24 | + } |
|
25 | 25 | |
26 | - return ($maxSize >= @filesize($elementValue['tmp_name'])); |
|
27 | - } |
|
26 | + return ($maxSize >= @filesize($elementValue['tmp_name'])); |
|
27 | + } |
|
28 | 28 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * @param string Mobile phone number to be validated |
18 | 18 | * @param string Not using it. Just to respect the declaration |
19 | - * @return boolean Returns true if valid, false otherwise. |
|
19 | + * @return integer Returns true if valid, false otherwise. |
|
20 | 20 | */ |
21 | 21 | function validate($mobilePhoneNumber, $options = null) |
22 | 22 | { |
@@ -456,6 +456,10 @@ discard block |
||
456 | 456 | |
457 | 457 | |
458 | 458 | // Add warning(s) to $this->warnings[] |
459 | + |
|
460 | + /** |
|
461 | + * @param string $message |
|
462 | + */ |
|
459 | 463 | public function warning($message) { |
460 | 464 | |
461 | 465 | if (is_array($message)) { |
@@ -482,6 +486,11 @@ discard block |
||
482 | 486 | |
483 | 487 | |
484 | 488 | // Convert string between charsets -- iconv() wrapper |
489 | + |
|
490 | + /** |
|
491 | + * @param string $out_charset |
|
492 | + * @param string $string |
|
493 | + */ |
|
485 | 494 | public function iconv($in_charset, $out_charset, $string, $drop01 = false) { |
486 | 495 | |
487 | 496 | if ($drop01 && ($string === "\x00" || $string === "\x01")) { |
@@ -509,6 +518,9 @@ discard block |
||
509 | 518 | |
510 | 519 | |
511 | 520 | |
521 | + /** |
|
522 | + * @param string $name |
|
523 | + */ |
|
512 | 524 | public function include_module($name) { |
513 | 525 | |
514 | 526 | if (!file_exists($this->include_path.'module.'.$name.'.php')) { |
@@ -1342,6 +1354,10 @@ discard block |
||
1342 | 1354 | |
1343 | 1355 | |
1344 | 1356 | // Convert Big Endian byte string to int - max 32 bits |
1357 | + |
|
1358 | + /** |
|
1359 | + * @param string $byte_word |
|
1360 | + */ |
|
1345 | 1361 | public static function BigEndian2Int($byte_word, $signed = false) { |
1346 | 1362 | |
1347 | 1363 | $int_value = 0; |
@@ -1391,6 +1407,9 @@ discard block |
||
1391 | 1407 | |
1392 | 1408 | |
1393 | 1409 | |
1410 | + /** |
|
1411 | + * @param string $byte_word |
|
1412 | + */ |
|
1394 | 1413 | public static function BigEndian2Float($byte_word) { |
1395 | 1414 | |
1396 | 1415 | // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic |
@@ -1478,6 +1497,9 @@ discard block |
||
1478 | 1497 | |
1479 | 1498 | |
1480 | 1499 | |
1500 | + /** |
|
1501 | + * @param string $binary_numerator |
|
1502 | + */ |
|
1481 | 1503 | public static function DecimalBinary2Float($binary_numerator) { |
1482 | 1504 | $numerator = bindec($binary_numerator); |
1483 | 1505 | $denominator = bindec('1'.str_repeat('0', strlen($binary_numerator))); |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | $class = new $class_name($this); |
301 | 301 | |
302 | 302 | try { |
303 | - $this->option_analyze and $class->Analyze(); |
|
303 | + $this->option_analyze and $class->Analyze(); |
|
304 | 304 | } |
305 | 305 | catch (getid3_exception $e) { |
306 | 306 | throw $e; |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | // CalculateReplayGain() { |
384 | 384 | if (@$this->info['replay_gain']) { |
385 | 385 | if (!@$this->info['replay_gain']['reference_volume']) { |
386 | - $this->info['replay_gain']['reference_volume'] = 89; |
|
386 | + $this->info['replay_gain']['reference_volume'] = 89; |
|
387 | 387 | } |
388 | 388 | if (isset($this->info['replay_gain']['track']['adjustment'])) { |
389 | 389 | $this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment']; |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | |
404 | 404 | // ProcessAudioStreams() { |
405 | 405 | if (@!$this->info['audio']['streams'] && (@$this->info['audio']['bitrate'] || @$this->info['audio']['channels'] || @$this->info['audio']['sample_rate'])) { |
406 | - foreach ($this->info['audio'] as $key => $value) { |
|
406 | + foreach ($this->info['audio'] as $key => $value) { |
|
407 | 407 | if ($key != 'streams') { |
408 | 408 | $this->info['audio']['streams'][0][$key] = $value; |
409 | 409 | } |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | 'group' => 'audio', |
545 | 545 | 'module' => 'ac3', |
546 | 546 | 'mime_type' => 'audio/ac3', |
547 | - ), |
|
547 | + ), |
|
548 | 548 | |
549 | 549 | // AAC - audio - Advanced Audio Coding (AAC) - ADIF format |
550 | 550 | 'adif' => array ( |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | 'module' => 'aac_adif', |
554 | 554 | 'mime_type' => 'application/octet-stream', |
555 | 555 | 'fail_ape' => 'WARNING', |
556 | - ), |
|
556 | + ), |
|
557 | 557 | |
558 | 558 | |
559 | 559 | // AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3) |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | 'module' => 'aac_adts', |
564 | 564 | 'mime_type' => 'application/octet-stream', |
565 | 565 | 'fail_ape' => 'WARNING', |
566 | - ), |
|
566 | + ), |
|
567 | 567 | |
568 | 568 | |
569 | 569 | // AU - audio - NeXT/Sun AUdio (AU) |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | 'group' => 'audio', |
573 | 573 | 'module' => 'au', |
574 | 574 | 'mime_type' => 'audio/basic', |
575 | - ), |
|
575 | + ), |
|
576 | 576 | |
577 | 577 | // AVR - audio - Audio Visual Research |
578 | 578 | 'avr' => array ( |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | 'group' => 'audio', |
581 | 581 | 'module' => 'avr', |
582 | 582 | 'mime_type' => 'application/octet-stream', |
583 | - ), |
|
583 | + ), |
|
584 | 584 | |
585 | 585 | // BONK - audio - Bonk v0.9+ |
586 | 586 | 'bonk' => array ( |
@@ -588,15 +588,15 @@ discard block |
||
588 | 588 | 'group' => 'audio', |
589 | 589 | 'module' => 'bonk', |
590 | 590 | 'mime_type' => 'audio/xmms-bonk', |
591 | - ), |
|
591 | + ), |
|
592 | 592 | |
593 | 593 | // DTS - audio - Dolby Theatre System |
594 | - 'dts' => array( |
|
595 | - 'pattern' => '^\x7F\xFE\x80\x01', |
|
596 | - 'group' => 'audio', |
|
597 | - 'module' => 'dts', |
|
598 | - 'mime_type' => 'audio/dts', |
|
599 | - ), |
|
594 | + 'dts' => array( |
|
595 | + 'pattern' => '^\x7F\xFE\x80\x01', |
|
596 | + 'group' => 'audio', |
|
597 | + 'module' => 'dts', |
|
598 | + 'mime_type' => 'audio/dts', |
|
599 | + ), |
|
600 | 600 | |
601 | 601 | // FLAC - audio - Free Lossless Audio Codec |
602 | 602 | 'flac' => array ( |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | 'group' => 'audio', |
605 | 605 | 'module' => 'xiph', |
606 | 606 | 'mime_type' => 'audio/x-flac', |
607 | - ), |
|
607 | + ), |
|
608 | 608 | |
609 | 609 | // LA - audio - Lossless Audio (LA) |
610 | 610 | 'la' => array ( |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | 'group' => 'audio', |
613 | 613 | 'module' => 'la', |
614 | 614 | 'mime_type' => 'application/octet-stream', |
615 | - ), |
|
615 | + ), |
|
616 | 616 | |
617 | 617 | // LPAC - audio - Lossless Predictive Audio Compression (LPAC) |
618 | 618 | 'lpac' => array ( |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | 'group' => 'audio', |
621 | 621 | 'module' => 'lpac', |
622 | 622 | 'mime_type' => 'application/octet-stream', |
623 | - ), |
|
623 | + ), |
|
624 | 624 | |
625 | 625 | // MIDI - audio - MIDI (Musical Instrument Digital Interface) |
626 | 626 | 'midi' => array ( |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | 'group' => 'audio', |
629 | 629 | 'module' => 'midi', |
630 | 630 | 'mime_type' => 'audio/midi', |
631 | - ), |
|
631 | + ), |
|
632 | 632 | |
633 | 633 | // MAC - audio - Monkey's Audio Compressor |
634 | 634 | 'mac' => array ( |
@@ -636,31 +636,31 @@ discard block |
||
636 | 636 | 'group' => 'audio', |
637 | 637 | 'module' => 'monkey', |
638 | 638 | 'mime_type' => 'application/octet-stream', |
639 | - ), |
|
639 | + ), |
|
640 | 640 | |
641 | 641 | // MOD - audio - MODule (assorted sub-formats) |
642 | 642 | 'mod' => array ( |
643 | 643 | 'pattern' => '^.{1080}(M.K.|[5-9]CHN|[1-3][0-9]CH)', |
644 | 644 | 'mime_type' => 'audio/mod', |
645 | - ), |
|
645 | + ), |
|
646 | 646 | |
647 | 647 | // MOD - audio - MODule (Impulse Tracker) |
648 | 648 | 'it' => array ( |
649 | 649 | 'pattern' => '^IMPM', |
650 | 650 | 'mime_type' => 'audio/it', |
651 | - ), |
|
651 | + ), |
|
652 | 652 | |
653 | 653 | // MOD - audio - MODule (eXtended Module, various sub-formats) |
654 | 654 | 'xm' => array ( |
655 | 655 | 'pattern' => '^Extended Module', |
656 | 656 | 'mime_type' => 'audio/xm', |
657 | - ), |
|
657 | + ), |
|
658 | 658 | |
659 | 659 | // MOD - audio - MODule (ScreamTracker) |
660 | 660 | 's3m' => array ( |
661 | 661 | 'pattern' => '^.{44}SCRM', |
662 | 662 | 'mime_type' => 'audio/s3m', |
663 | - ), |
|
663 | + ), |
|
664 | 664 | |
665 | 665 | // MPC - audio - Musepack / MPEGplus SV7+ |
666 | 666 | 'mpc' => array ( |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | 'group' => 'audio', |
669 | 669 | 'module' => 'mpc', |
670 | 670 | 'mime_type' => 'audio/x-musepack', |
671 | - ), |
|
671 | + ), |
|
672 | 672 | |
673 | 673 | // MPC - audio - Musepack / MPEGplus SV4-6 |
674 | 674 | 'mpc_old' => array ( |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | 'group' => 'audio', |
677 | 677 | 'module' => 'mpc_old', |
678 | 678 | 'mime_type' => 'application/octet-stream', |
679 | - ), |
|
679 | + ), |
|
680 | 680 | |
681 | 681 | |
682 | 682 | // MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS) |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | 'group' => 'audio', |
686 | 686 | 'module' => 'mp3', |
687 | 687 | 'mime_type' => 'audio/mpeg', |
688 | - ), |
|
688 | + ), |
|
689 | 689 | |
690 | 690 | // OFR - audio - OptimFROG |
691 | 691 | 'ofr' => array ( |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | 'group' => 'audio', |
694 | 694 | 'module' => 'optimfrog', |
695 | 695 | 'mime_type' => 'application/octet-stream', |
696 | - ), |
|
696 | + ), |
|
697 | 697 | |
698 | 698 | // RKAU - audio - RKive AUdio compressor |
699 | 699 | 'rkau' => array ( |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | 'group' => 'audio', |
702 | 702 | 'module' => 'rkau', |
703 | 703 | 'mime_type' => 'application/octet-stream', |
704 | - ), |
|
704 | + ), |
|
705 | 705 | |
706 | 706 | // SHN - audio - Shorten |
707 | 707 | 'shn' => array ( |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | 'mime_type' => 'audio/xmms-shn', |
712 | 712 | 'fail_id3' => 'ERROR', |
713 | 713 | 'fail_ape' => 'ERROR', |
714 | - ), |
|
714 | + ), |
|
715 | 715 | |
716 | 716 | // TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org) |
717 | 717 | 'tta' => array ( |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | 'group' => 'audio', |
720 | 720 | 'module' => 'tta', |
721 | 721 | 'mime_type' => 'application/octet-stream', |
722 | - ), |
|
722 | + ), |
|
723 | 723 | |
724 | 724 | // VOC - audio - Creative Voice (VOC) |
725 | 725 | 'voc' => array ( |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | 'group' => 'audio', |
728 | 728 | 'module' => 'voc', |
729 | 729 | 'mime_type' => 'audio/voc', |
730 | - ), |
|
730 | + ), |
|
731 | 731 | |
732 | 732 | // VQF - audio - transform-domain weighted interleave Vector Quantization Format (VQF) |
733 | 733 | 'vqf' => array ( |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | 'group' => 'audio', |
736 | 736 | 'module' => 'vqf', |
737 | 737 | 'mime_type' => 'application/octet-stream', |
738 | - ), |
|
738 | + ), |
|
739 | 739 | |
740 | 740 | // WV - audio - WavPack (v4.0+) |
741 | 741 | 'vw' => array( |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | 'group' => 'audio', |
744 | 744 | 'module' => 'wavpack', |
745 | 745 | 'mime_type' => 'application/octet-stream', |
746 | - ), |
|
746 | + ), |
|
747 | 747 | |
748 | 748 | |
749 | 749 | // Audio-Video formats |
@@ -754,13 +754,13 @@ discard block |
||
754 | 754 | 'group' => 'audio-video', |
755 | 755 | 'module' => 'asf', |
756 | 756 | 'mime_type' => 'video/x-ms-asf', |
757 | - ), |
|
757 | + ), |
|
758 | 758 | |
759 | 759 | // BINK - audio/video - Bink / Smacker |
760 | 760 | 'bink' => array( |
761 | 761 | 'pattern' => '^(BIK|SMK)', |
762 | 762 | 'mime_type' => 'application/octet-stream', |
763 | - ), |
|
763 | + ), |
|
764 | 764 | |
765 | 765 | // FLV - audio/video - FLash Video |
766 | 766 | 'flv' => array( |
@@ -768,13 +768,13 @@ discard block |
||
768 | 768 | 'group' => 'audio-video', |
769 | 769 | 'module' => 'flv', |
770 | 770 | 'mime_type' => 'video/x-flv', |
771 | - ), |
|
771 | + ), |
|
772 | 772 | |
773 | 773 | // MKAV - audio/video - Mastroka |
774 | 774 | 'matroska' => array ( |
775 | 775 | 'pattern' => '^\x1A\x45\xDF\xA3', |
776 | 776 | 'mime_type' => 'application/octet-stream', |
777 | - ), |
|
777 | + ), |
|
778 | 778 | |
779 | 779 | // MPEG - audio/video - MPEG (Moving Pictures Experts Group) |
780 | 780 | 'mpeg' => array ( |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | 'group' => 'audio-video', |
783 | 783 | 'module' => 'mpeg', |
784 | 784 | 'mime_type' => 'video/mpeg', |
785 | - ), |
|
785 | + ), |
|
786 | 786 | |
787 | 787 | // NSV - audio/video - Nullsoft Streaming Video (NSV) |
788 | 788 | 'nsv' => array ( |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | 'group' => 'audio-video', |
791 | 791 | 'module' => 'nsv', |
792 | 792 | 'mime_type' => 'application/octet-stream', |
793 | - ), |
|
793 | + ), |
|
794 | 794 | |
795 | 795 | // Ogg - audio/video - Ogg (Ogg Vorbis, OggFLAC, Speex, Ogg Theora(*), Ogg Tarkin(*)) |
796 | 796 | 'ogg' => array ( |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | 'mime_type' => 'application/ogg', |
801 | 801 | 'fail_id3' => 'WARNING', |
802 | 802 | 'fail_ape' => 'WARNING', |
803 | - ), |
|
803 | + ), |
|
804 | 804 | |
805 | 805 | // QT - audio/video - Quicktime |
806 | 806 | 'quicktime' => array ( |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | 'group' => 'audio-video', |
809 | 809 | 'module' => 'quicktime', |
810 | 810 | 'mime_type' => 'video/quicktime', |
811 | - ), |
|
811 | + ), |
|
812 | 812 | |
813 | 813 | // 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) |
814 | 814 | 'riff' => array ( |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | 'module' => 'riff', |
818 | 818 | 'mime_type' => 'audio/x-wave', |
819 | 819 | 'fail_ape' => 'WARNING', |
820 | - ), |
|
820 | + ), |
|
821 | 821 | |
822 | 822 | // Real - audio/video - RealAudio, RealVideo |
823 | 823 | 'real' => array ( |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | 'group' => 'audio-video', |
826 | 826 | 'module' => 'real', |
827 | 827 | 'mime_type' => 'audio/x-realaudio', |
828 | - ), |
|
828 | + ), |
|
829 | 829 | |
830 | 830 | // SWF - audio/video - ShockWave Flash |
831 | 831 | 'swf' => array ( |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | 'group' => 'audio-video', |
834 | 834 | 'module' => 'swf', |
835 | 835 | 'mime_type' => 'application/x-shockwave-flash', |
836 | - ), |
|
836 | + ), |
|
837 | 837 | |
838 | 838 | |
839 | 839 | // Still-Image formats |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | 'mime_type' => 'image/bmp', |
847 | 847 | 'fail_id3' => 'ERROR', |
848 | 848 | 'fail_ape' => 'ERROR', |
849 | - ), |
|
849 | + ), |
|
850 | 850 | |
851 | 851 | // GIF - still image - Graphics Interchange Format |
852 | 852 | 'gif' => array ( |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | 'mime_type' => 'image/gif', |
857 | 857 | 'fail_id3' => 'ERROR', |
858 | 858 | 'fail_ape' => 'ERROR', |
859 | - ), |
|
859 | + ), |
|
860 | 860 | |
861 | 861 | // JPEG - still image - Joint Photographic Experts Group (JPEG) |
862 | 862 | 'jpeg' => array ( |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | 'mime_type' => 'image/jpeg', |
867 | 867 | 'fail_id3' => 'ERROR', |
868 | 868 | 'fail_ape' => 'ERROR', |
869 | - ), |
|
869 | + ), |
|
870 | 870 | |
871 | 871 | // PCD - still image - Kodak Photo CD |
872 | 872 | 'pcd' => array ( |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | 'mime_type' => 'image/x-photo-cd', |
877 | 877 | 'fail_id3' => 'ERROR', |
878 | 878 | 'fail_ape' => 'ERROR', |
879 | - ), |
|
879 | + ), |
|
880 | 880 | |
881 | 881 | |
882 | 882 | // PNG - still image - Portable Network Graphics (PNG) |
@@ -887,16 +887,16 @@ discard block |
||
887 | 887 | 'mime_type' => 'image/png', |
888 | 888 | 'fail_id3' => 'ERROR', |
889 | 889 | 'fail_ape' => 'ERROR', |
890 | - ), |
|
890 | + ), |
|
891 | 891 | |
892 | 892 | |
893 | 893 | // SVG - still image - Scalable Vector Graphics (SVG) |
894 | - 'svg' => array( |
|
895 | - 'pattern' => '<!DOCTYPE svg PUBLIC ', |
|
896 | - 'mime_type' => 'image/svg+xml', |
|
897 | - 'fail_id3' => 'ERROR', |
|
898 | - 'fail_ape' => 'ERROR', |
|
899 | - ), |
|
894 | + 'svg' => array( |
|
895 | + 'pattern' => '<!DOCTYPE svg PUBLIC ', |
|
896 | + 'mime_type' => 'image/svg+xml', |
|
897 | + 'fail_id3' => 'ERROR', |
|
898 | + 'fail_ape' => 'ERROR', |
|
899 | + ), |
|
900 | 900 | |
901 | 901 | |
902 | 902 | // TIFF - still image - Tagged Information File Format (TIFF) |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | 'mime_type' => 'image/tiff', |
908 | 908 | 'fail_id3' => 'ERROR', |
909 | 909 | 'fail_ape' => 'ERROR', |
910 | - ), |
|
910 | + ), |
|
911 | 911 | |
912 | 912 | |
913 | 913 | // Data formats |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | 'mime_type' => 'application/octet-stream', |
918 | 918 | 'fail_id3' => 'ERROR', |
919 | 919 | 'fail_ape' => 'ERROR', |
920 | - ), |
|
920 | + ), |
|
921 | 921 | |
922 | 922 | // ISO - data - International Standards Organization (ISO) CD-ROM Image |
923 | 923 | 'iso' => array ( |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | 'mime_type' => 'application/octet-stream', |
928 | 928 | 'fail_id3' => 'ERROR', |
929 | 929 | 'fail_ape' => 'ERROR', |
930 | - ), |
|
930 | + ), |
|
931 | 931 | |
932 | 932 | // RAR - data - RAR compressed data |
933 | 933 | 'rar' => array( |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | 'mime_type' => 'application/octet-stream', |
936 | 936 | 'fail_id3' => 'ERROR', |
937 | 937 | 'fail_ape' => 'ERROR', |
938 | - ), |
|
938 | + ), |
|
939 | 939 | |
940 | 940 | // SZIP - audio - SZIP compressed data |
941 | 941 | 'szip' => array ( |
@@ -945,7 +945,7 @@ discard block |
||
945 | 945 | 'mime_type' => 'application/octet-stream', |
946 | 946 | 'fail_id3' => 'ERROR', |
947 | 947 | 'fail_ape' => 'ERROR', |
948 | - ), |
|
948 | + ), |
|
949 | 949 | |
950 | 950 | // TAR - data - TAR compressed data |
951 | 951 | 'tar' => array( |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | 'mime_type' => 'application/x-tar', |
956 | 956 | 'fail_id3' => 'ERROR', |
957 | 957 | 'fail_ape' => 'ERROR', |
958 | - ), |
|
958 | + ), |
|
959 | 959 | |
960 | 960 | // GZIP - data - GZIP compressed data |
961 | 961 | 'gz' => array( |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | 'mime_type' => 'application/x-gzip', |
966 | 966 | 'fail_id3' => 'ERROR', |
967 | 967 | 'fail_ape' => 'ERROR', |
968 | - ), |
|
968 | + ), |
|
969 | 969 | |
970 | 970 | |
971 | 971 | // ZIP - data - ZIP compressed data |
@@ -976,33 +976,33 @@ discard block |
||
976 | 976 | 'mime_type' => 'application/zip', |
977 | 977 | 'fail_id3' => 'ERROR', |
978 | 978 | 'fail_ape' => 'ERROR', |
979 | - ), |
|
979 | + ), |
|
980 | 980 | |
981 | 981 | |
982 | 982 | // PAR2 - data - Parity Volume Set Specification 2.0 |
983 | 983 | 'par2' => array ( |
984 | - 'pattern' => '^PAR2\x00PKT', |
|
985 | - 'mime_type' => 'application/octet-stream', |
|
986 | - 'fail_id3' => 'ERROR', |
|
987 | - 'fail_ape' => 'ERROR', |
|
988 | - ), |
|
984 | + 'pattern' => '^PAR2\x00PKT', |
|
985 | + 'mime_type' => 'application/octet-stream', |
|
986 | + 'fail_id3' => 'ERROR', |
|
987 | + 'fail_ape' => 'ERROR', |
|
988 | + ), |
|
989 | 989 | |
990 | 990 | |
991 | - // PDF - data - Portable Document Format |
|
992 | - 'pdf' => array( |
|
991 | + // PDF - data - Portable Document Format |
|
992 | + 'pdf' => array( |
|
993 | 993 | 'pattern' => '^\x25PDF', |
994 | 994 | 'mime_type' => 'application/pdf', |
995 | 995 | 'fail_id3' => 'ERROR', |
996 | 996 | 'fail_ape' => 'ERROR', |
997 | - ), |
|
997 | + ), |
|
998 | 998 | |
999 | - // DOC - data - Microsoft Word |
|
1000 | - 'msoffice' => array( |
|
999 | + // DOC - data - Microsoft Word |
|
1000 | + 'msoffice' => array( |
|
1001 | 1001 | 'pattern' => '^\xD0\xCF\x11\xE0', // D0CF11E == DOCFILE == Microsoft Office Document |
1002 | 1002 | 'mime_type' => 'application/octet-stream', |
1003 | 1003 | 'fail_id3' => 'ERROR', |
1004 | 1004 | 'fail_ape' => 'ERROR', |
1005 | - ), |
|
1005 | + ), |
|
1006 | 1006 | ); |
1007 | 1007 | |
1008 | 1008 | return $format_info; |
@@ -1393,99 +1393,99 @@ discard block |
||
1393 | 1393 | |
1394 | 1394 | public static function BigEndian2Float($byte_word) { |
1395 | 1395 | |
1396 | - // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic |
|
1397 | - // http://www.psc.edu/general/software/packages/ieee/ieee.html |
|
1398 | - // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html |
|
1396 | + // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic |
|
1397 | + // http://www.psc.edu/general/software/packages/ieee/ieee.html |
|
1398 | + // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html |
|
1399 | 1399 | |
1400 | - $bit_word = getid3_lib::BigEndian2Bin($byte_word); |
|
1401 | - if (!$bit_word) { |
|
1400 | + $bit_word = getid3_lib::BigEndian2Bin($byte_word); |
|
1401 | + if (!$bit_word) { |
|
1402 | 1402 | return 0; |
1403 | 1403 | } |
1404 | - $sign_bit = $bit_word{0}; |
|
1405 | - |
|
1406 | - switch (strlen($byte_word) * 8) { |
|
1407 | - case 32: |
|
1408 | - $exponent_bits = 8; |
|
1409 | - $fraction_bits = 23; |
|
1410 | - break; |
|
1411 | - |
|
1412 | - case 64: |
|
1413 | - $exponent_bits = 11; |
|
1414 | - $fraction_bits = 52; |
|
1415 | - break; |
|
1416 | - |
|
1417 | - case 80: |
|
1418 | - // 80-bit Apple SANE format |
|
1419 | - // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/ |
|
1420 | - $exponent_string = substr($bit_word, 1, 15); |
|
1421 | - $is_normalized = intval($bit_word{16}); |
|
1422 | - $fraction_string = substr($bit_word, 17, 63); |
|
1423 | - $exponent = pow(2, getid3_lib::Bin2Dec($exponent_string) - 16383); |
|
1424 | - $fraction = $is_normalized + getid3_lib::DecimalBinary2Float($fraction_string); |
|
1425 | - $float_value = $exponent * $fraction; |
|
1426 | - if ($sign_bit == '1') { |
|
1427 | - $float_value *= -1; |
|
1428 | - } |
|
1429 | - return $float_value; |
|
1430 | - break; |
|
1431 | - |
|
1432 | - default: |
|
1433 | - return false; |
|
1434 | - break; |
|
1435 | - } |
|
1436 | - $exponent_string = substr($bit_word, 1, $exponent_bits); |
|
1437 | - $fraction_string = substr($bit_word, $exponent_bits + 1, $fraction_bits); |
|
1438 | - $exponent = bindec($exponent_string); |
|
1439 | - $fraction = bindec($fraction_string); |
|
1440 | - |
|
1441 | - if (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction != 0)) { |
|
1442 | - // Not a Number |
|
1443 | - $float_value = false; |
|
1444 | - } elseif (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction == 0)) { |
|
1445 | - if ($sign_bit == '1') { |
|
1446 | - $float_value = '-infinity'; |
|
1447 | - } else { |
|
1448 | - $float_value = '+infinity'; |
|
1449 | - } |
|
1450 | - } elseif (($exponent == 0) && ($fraction == 0)) { |
|
1451 | - if ($sign_bit == '1') { |
|
1452 | - $float_value = -0; |
|
1453 | - } else { |
|
1454 | - $float_value = 0; |
|
1455 | - } |
|
1456 | - $float_value = ($sign_bit ? 0 : -0); |
|
1457 | - } elseif (($exponent == 0) && ($fraction != 0)) { |
|
1458 | - // These are 'unnormalized' values |
|
1459 | - $float_value = pow(2, (-1 * (pow(2, $exponent_bits - 1) - 2))) * getid3_lib::DecimalBinary2Float($fraction_string); |
|
1460 | - if ($sign_bit == '1') { |
|
1461 | - $float_value *= -1; |
|
1462 | - } |
|
1463 | - } elseif ($exponent != 0) { |
|
1464 | - $float_value = pow(2, ($exponent - (pow(2, $exponent_bits - 1) - 1))) * (1 + getid3_lib::DecimalBinary2Float($fraction_string)); |
|
1465 | - if ($sign_bit == '1') { |
|
1466 | - $float_value *= -1; |
|
1467 | - } |
|
1468 | - } |
|
1469 | - return (float) $float_value; |
|
1470 | - } |
|
1471 | - |
|
1472 | - |
|
1473 | - |
|
1474 | - public static function LittleEndian2Float($byte_word) { |
|
1475 | - |
|
1476 | - return getid3_lib::BigEndian2Float(strrev($byte_word)); |
|
1477 | - } |
|
1478 | - |
|
1479 | - |
|
1480 | - |
|
1481 | - public static function DecimalBinary2Float($binary_numerator) { |
|
1482 | - $numerator = bindec($binary_numerator); |
|
1483 | - $denominator = bindec('1'.str_repeat('0', strlen($binary_numerator))); |
|
1484 | - return ($numerator / $denominator); |
|
1485 | - } |
|
1486 | - |
|
1487 | - |
|
1488 | - public static function PrintHexBytes($string, $hex=true, $spaces=true, $html_safe=true) { |
|
1404 | + $sign_bit = $bit_word{0}; |
|
1405 | + |
|
1406 | + switch (strlen($byte_word) * 8) { |
|
1407 | + case 32: |
|
1408 | + $exponent_bits = 8; |
|
1409 | + $fraction_bits = 23; |
|
1410 | + break; |
|
1411 | + |
|
1412 | + case 64: |
|
1413 | + $exponent_bits = 11; |
|
1414 | + $fraction_bits = 52; |
|
1415 | + break; |
|
1416 | + |
|
1417 | + case 80: |
|
1418 | + // 80-bit Apple SANE format |
|
1419 | + // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/ |
|
1420 | + $exponent_string = substr($bit_word, 1, 15); |
|
1421 | + $is_normalized = intval($bit_word{16}); |
|
1422 | + $fraction_string = substr($bit_word, 17, 63); |
|
1423 | + $exponent = pow(2, getid3_lib::Bin2Dec($exponent_string) - 16383); |
|
1424 | + $fraction = $is_normalized + getid3_lib::DecimalBinary2Float($fraction_string); |
|
1425 | + $float_value = $exponent * $fraction; |
|
1426 | + if ($sign_bit == '1') { |
|
1427 | + $float_value *= -1; |
|
1428 | + } |
|
1429 | + return $float_value; |
|
1430 | + break; |
|
1431 | + |
|
1432 | + default: |
|
1433 | + return false; |
|
1434 | + break; |
|
1435 | + } |
|
1436 | + $exponent_string = substr($bit_word, 1, $exponent_bits); |
|
1437 | + $fraction_string = substr($bit_word, $exponent_bits + 1, $fraction_bits); |
|
1438 | + $exponent = bindec($exponent_string); |
|
1439 | + $fraction = bindec($fraction_string); |
|
1440 | + |
|
1441 | + if (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction != 0)) { |
|
1442 | + // Not a Number |
|
1443 | + $float_value = false; |
|
1444 | + } elseif (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction == 0)) { |
|
1445 | + if ($sign_bit == '1') { |
|
1446 | + $float_value = '-infinity'; |
|
1447 | + } else { |
|
1448 | + $float_value = '+infinity'; |
|
1449 | + } |
|
1450 | + } elseif (($exponent == 0) && ($fraction == 0)) { |
|
1451 | + if ($sign_bit == '1') { |
|
1452 | + $float_value = -0; |
|
1453 | + } else { |
|
1454 | + $float_value = 0; |
|
1455 | + } |
|
1456 | + $float_value = ($sign_bit ? 0 : -0); |
|
1457 | + } elseif (($exponent == 0) && ($fraction != 0)) { |
|
1458 | + // These are 'unnormalized' values |
|
1459 | + $float_value = pow(2, (-1 * (pow(2, $exponent_bits - 1) - 2))) * getid3_lib::DecimalBinary2Float($fraction_string); |
|
1460 | + if ($sign_bit == '1') { |
|
1461 | + $float_value *= -1; |
|
1462 | + } |
|
1463 | + } elseif ($exponent != 0) { |
|
1464 | + $float_value = pow(2, ($exponent - (pow(2, $exponent_bits - 1) - 1))) * (1 + getid3_lib::DecimalBinary2Float($fraction_string)); |
|
1465 | + if ($sign_bit == '1') { |
|
1466 | + $float_value *= -1; |
|
1467 | + } |
|
1468 | + } |
|
1469 | + return (float) $float_value; |
|
1470 | + } |
|
1471 | + |
|
1472 | + |
|
1473 | + |
|
1474 | + public static function LittleEndian2Float($byte_word) { |
|
1475 | + |
|
1476 | + return getid3_lib::BigEndian2Float(strrev($byte_word)); |
|
1477 | + } |
|
1478 | + |
|
1479 | + |
|
1480 | + |
|
1481 | + public static function DecimalBinary2Float($binary_numerator) { |
|
1482 | + $numerator = bindec($binary_numerator); |
|
1483 | + $denominator = bindec('1'.str_repeat('0', strlen($binary_numerator))); |
|
1484 | + return ($numerator / $denominator); |
|
1485 | + } |
|
1486 | + |
|
1487 | + |
|
1488 | + public static function PrintHexBytes($string, $hex=true, $spaces=true, $html_safe=true) { |
|
1489 | 1489 | |
1490 | 1490 | $return_string = ''; |
1491 | 1491 | for ($i = 0; $i < strlen($string); $i++) { |
@@ -27,42 +27,42 @@ discard block |
||
27 | 27 | //// Settings Section - do NOT modify this file - change setting after newing getid3! |
28 | 28 | |
29 | 29 | // Encoding |
30 | - public $encoding = 'ISO-8859-1'; // CASE SENSITIVE! - i.e. (must be supported by iconv() - see http://www.gnu.org/software/libiconv/). Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE. |
|
31 | - public $encoding_id3v1 = 'ISO-8859-1'; // Override SPECIFICATION encoding for broken ID3v1 tags caused by bad tag programs. Examples: 'EUC-CN' for "Chinese MP3s" and 'CP1251' for "Cyrillic". |
|
32 | - public $encoding_id3v2 = 'ISO-8859-1'; // Override ISO-8859-1 encoding for broken ID3v2 tags caused by BRAINDEAD tag programs that writes system codepage as 'ISO-8859-1' instead of UTF-8. |
|
30 | + public $encoding = 'ISO-8859-1'; // CASE SENSITIVE! - i.e. (must be supported by iconv() - see http://www.gnu.org/software/libiconv/). Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE. |
|
31 | + public $encoding_id3v1 = 'ISO-8859-1'; // Override SPECIFICATION encoding for broken ID3v1 tags caused by bad tag programs. Examples: 'EUC-CN' for "Chinese MP3s" and 'CP1251' for "Cyrillic". |
|
32 | + public $encoding_id3v2 = 'ISO-8859-1'; // Override ISO-8859-1 encoding for broken ID3v2 tags caused by BRAINDEAD tag programs that writes system codepage as 'ISO-8859-1' instead of UTF-8. |
|
33 | 33 | |
34 | 34 | // Tags - disable for speed |
35 | - public $option_tag_id3v1 = false; // Read and process ID3v1 tags. |
|
36 | - public $option_tag_id3v2 = false; // Read and process ID3v2 tags. |
|
37 | - public $option_tag_lyrics3 = false; // Read and process Lyrics3 tags. |
|
38 | - public $option_tag_apetag = false; // Read and process APE tags. |
|
35 | + public $option_tag_id3v1 = false; // Read and process ID3v1 tags. |
|
36 | + public $option_tag_id3v2 = false; // Read and process ID3v2 tags. |
|
37 | + public $option_tag_lyrics3 = false; // Read and process Lyrics3 tags. |
|
38 | + public $option_tag_apetag = false; // Read and process APE tags. |
|
39 | 39 | |
40 | 40 | // Misc calucations - disable for speed |
41 | - public $option_analyze = true; // Analyze file - disable if you only need to detect file format. |
|
42 | - public $option_accurate_results = true; // Disable to greatly speed up parsing of some file formats at the cost of accuracy. |
|
43 | - public $option_tags_process = true; // Copy tags to root key 'tags' and 'comments' and encode to $this->encoding. |
|
44 | - public $option_tags_images = false; // Scan tags for binary image data - ID3v2 and vorbiscomments only. |
|
45 | - public $option_extra_info = true; // Calculate/return additional info such as bitrate, channelmode etc. |
|
46 | - public $option_max_2gb_check = false; // Check whether file is larger than 2 Gb and thus not supported by PHP. |
|
41 | + public $option_analyze = true; // Analyze file - disable if you only need to detect file format. |
|
42 | + public $option_accurate_results = true; // Disable to greatly speed up parsing of some file formats at the cost of accuracy. |
|
43 | + public $option_tags_process = true; // Copy tags to root key 'tags' and 'comments' and encode to $this->encoding. |
|
44 | + public $option_tags_images = false; // Scan tags for binary image data - ID3v2 and vorbiscomments only. |
|
45 | + public $option_extra_info = true; // Calculate/return additional info such as bitrate, channelmode etc. |
|
46 | + public $option_max_2gb_check = false; // Check whether file is larger than 2 Gb and thus not supported by PHP. |
|
47 | 47 | |
48 | 48 | // Misc data hashes - slow - require hash module |
49 | - public $option_md5_data = false; // Get MD5 sum of data part - slow. |
|
50 | - public $option_md5_data_source = false; // Use MD5 of source file if available - only FLAC, MAC, OptimFROG and Wavpack4. |
|
51 | - public $option_sha1_data = false; // Get SHA1 sum of data part - slow. |
|
49 | + public $option_md5_data = false; // Get MD5 sum of data part - slow. |
|
50 | + public $option_md5_data_source = false; // Use MD5 of source file if available - only FLAC, MAC, OptimFROG and Wavpack4. |
|
51 | + public $option_sha1_data = false; // Get SHA1 sum of data part - slow. |
|
52 | 52 | |
53 | 53 | // Public variables |
54 | - public $filename; // Filename of file being analysed. |
|
55 | - public $fp; // Filepointer to file being analysed. |
|
56 | - public $info; // Result array. |
|
54 | + public $filename; // Filename of file being analysed. |
|
55 | + public $fp; // Filepointer to file being analysed. |
|
56 | + public $info; // Result array. |
|
57 | 57 | |
58 | 58 | // Protected variables |
59 | - protected $include_path; // getid3 include path. |
|
60 | - protected $warnings = array (); |
|
59 | + protected $include_path; // getid3 include path. |
|
60 | + protected $warnings = array(); |
|
61 | 61 | protected $iconv_present; |
62 | 62 | |
63 | 63 | // Class constants |
64 | 64 | const VERSION = '2.0.0b4'; |
65 | - const FREAD_BUFFER_SIZE = 16384; // Read buffer size in bytes. |
|
65 | + const FREAD_BUFFER_SIZE = 16384; // Read buffer size in bytes. |
|
66 | 66 | const ICONV_TEST_STRING = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~�������������������������������� �����������������������������������������������������������������������������������������������'; |
67 | 67 | |
68 | 68 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | // Get include_path |
90 | - $this->include_path = $include_path = dirname(__FILE__) . '/'; |
|
90 | + $this->include_path = $include_path = dirname(__FILE__).'/'; |
|
91 | 91 | |
92 | 92 | // Check for presence of iconv() and make sure it works (simpel test only). |
93 | 93 | if (function_exists('iconv') && @iconv('UTF-16LE', 'ISO-8859-1', @iconv('ISO-8859-1', 'UTF-16LE', getid3::ICONV_TEST_STRING)) == getid3::ICONV_TEST_STRING) { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | |
125 | 125 | // Check safe_mode off |
126 | - if ((bool)ini_get('safe_mode')) { |
|
126 | + if ((bool) ini_get('safe_mode')) { |
|
127 | 127 | $this->warning('Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbis/flac tag writing disabled.'); |
128 | 128 | } |
129 | 129 | |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | |
138 | 138 | // Init and save values |
139 | 139 | $this->filename = $filename; |
140 | - $this->warnings = array (); |
|
140 | + $this->warnings = array(); |
|
141 | 141 | |
142 | 142 | // Init result array and set parameters |
143 | - $this->info = array (); |
|
143 | + $this->info = array(); |
|
144 | 144 | $this->info['GETID3_VERSION'] = getid3::VERSION; |
145 | 145 | |
146 | 146 | // Remote files not supported |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | fseek($this->fp, 0, SEEK_SET); |
181 | 181 | $header = fread($this->fp, 10); |
182 | - if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) { |
|
182 | + if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) { |
|
183 | 183 | $this->info['id3v2']['header'] = true; |
184 | 184 | $this->info['id3v2']['majorversion'] = ord($header{3}); |
185 | 185 | $this->info['id3v2']['minorversion'] = ord($header{4}); |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | |
190 | 190 | |
191 | 191 | // Handle tags |
192 | - foreach (array ("id3v2", "id3v1", "apetag", "lyrics3") as $tag_name) { |
|
192 | + foreach (array("id3v2", "id3v1", "apetag", "lyrics3") as $tag_name) { |
|
193 | 193 | |
194 | - $option_tag = 'option_tag_' . $tag_name; |
|
194 | + $option_tag = 'option_tag_'.$tag_name; |
|
195 | 195 | if ($this->$option_tag) { |
196 | 196 | $this->include_module('tag.'.$tag_name); |
197 | 197 | try { |
198 | - $tag_class = 'getid3_' . $tag_name; |
|
198 | + $tag_class = 'getid3_'.$tag_name; |
|
199 | 199 | $tag = new $tag_class($this); |
200 | 200 | $tag->Analyze(); |
201 | 201 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | return $this->info; |
232 | 232 | } |
233 | 233 | |
234 | - $determined_format = $info; // copy $info deleted by foreach() |
|
234 | + $determined_format = $info; // copy $info deleted by foreach() |
|
235 | 235 | continue; |
236 | 236 | } |
237 | 237 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | |
342 | 342 | // Set playtime string |
343 | 343 | if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) { |
344 | - $this->info['playtime_string'] = floor(round($this->info['playtime_seconds']) / 60) . ':' . str_pad(floor(round($this->info['playtime_seconds']) % 60), 2, 0, STR_PAD_LEFT);; |
|
344 | + $this->info['playtime_string'] = floor(round($this->info['playtime_seconds']) / 60).':'.str_pad(floor(round($this->info['playtime_seconds']) % 60), 2, 0, STR_PAD_LEFT); ; |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | if (@$this->info['video'] && @$this->info['video']['resolution_x'] && @$this->info['video']['resolution_y'] && @$this->info['video']['bits_per_sample']) { |
350 | 350 | |
351 | 351 | // From static image formats |
352 | - if (in_array($this->info['video']['dataformat'], array ('bmp', 'gif', 'jpeg', 'jpg', 'png', 'tiff'))) { |
|
352 | + if (in_array($this->info['video']['dataformat'], array('bmp', 'gif', 'jpeg', 'jpg', 'png', 'tiff'))) { |
|
353 | 353 | $frame_rate = 1; |
354 | 354 | $bitrate_compressed = $this->info['filesize'] * 8; |
355 | 355 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | // Clear all warnings when cloning |
472 | 472 | public function __clone() { |
473 | 473 | |
474 | - $this->warnings = array (); |
|
474 | + $this->warnings = array(); |
|
475 | 475 | |
476 | 476 | // Copy info array, otherwise it will be a reference. |
477 | 477 | $temp = $this->info; |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | return $result; |
504 | 504 | } |
505 | 505 | |
506 | - $this->warning('iconv() was unable to convert the string: "' . $string . '" from ' . $in_charset . ' to ' . $out_charset); |
|
506 | + $this->warning('iconv() was unable to convert the string: "'.$string.'" from '.$in_charset.' to '.$out_charset); |
|
507 | 507 | return $string; |
508 | 508 | } |
509 | 509 | |
@@ -534,12 +534,12 @@ discard block |
||
534 | 534 | // Return array containing information about all supported formats |
535 | 535 | public static function GetFileFormatArray() { |
536 | 536 | |
537 | - static $format_info = array ( |
|
537 | + static $format_info = array( |
|
538 | 538 | |
539 | 539 | // Audio formats |
540 | 540 | |
541 | 541 | // AC-3 - audio - Dolby AC-3 / Dolby Digital |
542 | - 'ac3' => array ( |
|
542 | + 'ac3' => array( |
|
543 | 543 | 'pattern' => '^\x0B\x77', |
544 | 544 | 'group' => 'audio', |
545 | 545 | 'module' => 'ac3', |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | ), |
548 | 548 | |
549 | 549 | // AAC - audio - Advanced Audio Coding (AAC) - ADIF format |
550 | - 'adif' => array ( |
|
550 | + 'adif' => array( |
|
551 | 551 | 'pattern' => '^ADIF', |
552 | 552 | 'group' => 'audio', |
553 | 553 | 'module' => 'aac_adif', |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | |
558 | 558 | |
559 | 559 | // AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3) |
560 | - 'adts' => array ( |
|
560 | + 'adts' => array( |
|
561 | 561 | 'pattern' => '^\xFF[\xF0-\xF1\xF8-\xF9]', |
562 | 562 | 'group' => 'audio', |
563 | 563 | 'module' => 'aac_adts', |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | |
568 | 568 | |
569 | 569 | // AU - audio - NeXT/Sun AUdio (AU) |
570 | - 'au' => array ( |
|
570 | + 'au' => array( |
|
571 | 571 | 'pattern' => '^\.snd', |
572 | 572 | 'group' => 'audio', |
573 | 573 | 'module' => 'au', |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | ), |
576 | 576 | |
577 | 577 | // AVR - audio - Audio Visual Research |
578 | - 'avr' => array ( |
|
578 | + 'avr' => array( |
|
579 | 579 | 'pattern' => '^2BIT', |
580 | 580 | 'group' => 'audio', |
581 | 581 | 'module' => 'avr', |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | ), |
584 | 584 | |
585 | 585 | // BONK - audio - Bonk v0.9+ |
586 | - 'bonk' => array ( |
|
586 | + 'bonk' => array( |
|
587 | 587 | 'pattern' => '^\x00(BONK|INFO|META| ID3)', |
588 | 588 | 'group' => 'audio', |
589 | 589 | 'module' => 'bonk', |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | ), |
600 | 600 | |
601 | 601 | // FLAC - audio - Free Lossless Audio Codec |
602 | - 'flac' => array ( |
|
602 | + 'flac' => array( |
|
603 | 603 | 'pattern' => '^fLaC', |
604 | 604 | 'group' => 'audio', |
605 | 605 | 'module' => 'xiph', |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | ), |
608 | 608 | |
609 | 609 | // LA - audio - Lossless Audio (LA) |
610 | - 'la' => array ( |
|
610 | + 'la' => array( |
|
611 | 611 | 'pattern' => '^LA0[2-4]', |
612 | 612 | 'group' => 'audio', |
613 | 613 | 'module' => 'la', |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | ), |
616 | 616 | |
617 | 617 | // LPAC - audio - Lossless Predictive Audio Compression (LPAC) |
618 | - 'lpac' => array ( |
|
618 | + 'lpac' => array( |
|
619 | 619 | 'pattern' => '^LPAC', |
620 | 620 | 'group' => 'audio', |
621 | 621 | 'module' => 'lpac', |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | ), |
624 | 624 | |
625 | 625 | // MIDI - audio - MIDI (Musical Instrument Digital Interface) |
626 | - 'midi' => array ( |
|
626 | + 'midi' => array( |
|
627 | 627 | 'pattern' => '^MThd', |
628 | 628 | 'group' => 'audio', |
629 | 629 | 'module' => 'midi', |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | ), |
632 | 632 | |
633 | 633 | // MAC - audio - Monkey's Audio Compressor |
634 | - 'mac' => array ( |
|
634 | + 'mac' => array( |
|
635 | 635 | 'pattern' => '^MAC ', |
636 | 636 | 'group' => 'audio', |
637 | 637 | 'module' => 'monkey', |
@@ -639,31 +639,31 @@ discard block |
||
639 | 639 | ), |
640 | 640 | |
641 | 641 | // MOD - audio - MODule (assorted sub-formats) |
642 | - 'mod' => array ( |
|
642 | + 'mod' => array( |
|
643 | 643 | 'pattern' => '^.{1080}(M.K.|[5-9]CHN|[1-3][0-9]CH)', |
644 | 644 | 'mime_type' => 'audio/mod', |
645 | 645 | ), |
646 | 646 | |
647 | 647 | // MOD - audio - MODule (Impulse Tracker) |
648 | - 'it' => array ( |
|
648 | + 'it' => array( |
|
649 | 649 | 'pattern' => '^IMPM', |
650 | 650 | 'mime_type' => 'audio/it', |
651 | 651 | ), |
652 | 652 | |
653 | 653 | // MOD - audio - MODule (eXtended Module, various sub-formats) |
654 | - 'xm' => array ( |
|
654 | + 'xm' => array( |
|
655 | 655 | 'pattern' => '^Extended Module', |
656 | 656 | 'mime_type' => 'audio/xm', |
657 | 657 | ), |
658 | 658 | |
659 | 659 | // MOD - audio - MODule (ScreamTracker) |
660 | - 's3m' => array ( |
|
660 | + 's3m' => array( |
|
661 | 661 | 'pattern' => '^.{44}SCRM', |
662 | 662 | 'mime_type' => 'audio/s3m', |
663 | 663 | ), |
664 | 664 | |
665 | 665 | // MPC - audio - Musepack / MPEGplus SV7+ |
666 | - 'mpc' => array ( |
|
666 | + 'mpc' => array( |
|
667 | 667 | 'pattern' => '^(MP\+)', |
668 | 668 | 'group' => 'audio', |
669 | 669 | 'module' => 'mpc', |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | ), |
672 | 672 | |
673 | 673 | // MPC - audio - Musepack / MPEGplus SV4-6 |
674 | - 'mpc_old' => array ( |
|
674 | + 'mpc_old' => array( |
|
675 | 675 | 'pattern' => '^([\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])', |
676 | 676 | 'group' => 'audio', |
677 | 677 | 'module' => 'mpc_old', |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | |
681 | 681 | |
682 | 682 | // MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS) |
683 | - 'mp3' => array ( |
|
683 | + 'mp3' => array( |
|
684 | 684 | 'pattern' => '^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]', |
685 | 685 | 'group' => 'audio', |
686 | 686 | 'module' => 'mp3', |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | ), |
689 | 689 | |
690 | 690 | // OFR - audio - OptimFROG |
691 | - 'ofr' => array ( |
|
691 | + 'ofr' => array( |
|
692 | 692 | 'pattern' => '^(\*RIFF|OFR)', |
693 | 693 | 'group' => 'audio', |
694 | 694 | 'module' => 'optimfrog', |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | ), |
697 | 697 | |
698 | 698 | // RKAU - audio - RKive AUdio compressor |
699 | - 'rkau' => array ( |
|
699 | + 'rkau' => array( |
|
700 | 700 | 'pattern' => '^RKA', |
701 | 701 | 'group' => 'audio', |
702 | 702 | 'module' => 'rkau', |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | ), |
705 | 705 | |
706 | 706 | // SHN - audio - Shorten |
707 | - 'shn' => array ( |
|
707 | + 'shn' => array( |
|
708 | 708 | 'pattern' => '^ajkg', |
709 | 709 | 'group' => 'audio', |
710 | 710 | 'module' => 'shorten', |
@@ -714,15 +714,15 @@ discard block |
||
714 | 714 | ), |
715 | 715 | |
716 | 716 | // TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org) |
717 | - 'tta' => array ( |
|
718 | - 'pattern' => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)' |
|
717 | + 'tta' => array( |
|
718 | + 'pattern' => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)' |
|
719 | 719 | 'group' => 'audio', |
720 | 720 | 'module' => 'tta', |
721 | 721 | 'mime_type' => 'application/octet-stream', |
722 | 722 | ), |
723 | 723 | |
724 | 724 | // VOC - audio - Creative Voice (VOC) |
725 | - 'voc' => array ( |
|
725 | + 'voc' => array( |
|
726 | 726 | 'pattern' => '^Creative Voice File', |
727 | 727 | 'group' => 'audio', |
728 | 728 | 'module' => 'voc', |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | ), |
731 | 731 | |
732 | 732 | // VQF - audio - transform-domain weighted interleave Vector Quantization Format (VQF) |
733 | - 'vqf' => array ( |
|
733 | + 'vqf' => array( |
|
734 | 734 | 'pattern' => '^TWIN', |
735 | 735 | 'group' => 'audio', |
736 | 736 | 'module' => 'vqf', |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | // Audio-Video formats |
750 | 750 | |
751 | 751 | // ASF - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio |
752 | - 'asf' => array ( |
|
752 | + 'asf' => array( |
|
753 | 753 | 'pattern' => '^\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C', |
754 | 754 | 'group' => 'audio-video', |
755 | 755 | 'module' => 'asf', |
@@ -771,13 +771,13 @@ discard block |
||
771 | 771 | ), |
772 | 772 | |
773 | 773 | // MKAV - audio/video - Mastroka |
774 | - 'matroska' => array ( |
|
774 | + 'matroska' => array( |
|
775 | 775 | 'pattern' => '^\x1A\x45\xDF\xA3', |
776 | 776 | 'mime_type' => 'application/octet-stream', |
777 | 777 | ), |
778 | 778 | |
779 | 779 | // MPEG - audio/video - MPEG (Moving Pictures Experts Group) |
780 | - 'mpeg' => array ( |
|
780 | + 'mpeg' => array( |
|
781 | 781 | 'pattern' => '^\x00\x00\x01(\xBA|\xB3)', |
782 | 782 | 'group' => 'audio-video', |
783 | 783 | 'module' => 'mpeg', |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | ), |
786 | 786 | |
787 | 787 | // NSV - audio/video - Nullsoft Streaming Video (NSV) |
788 | - 'nsv' => array ( |
|
788 | + 'nsv' => array( |
|
789 | 789 | 'pattern' => '^NSV[sf]', |
790 | 790 | 'group' => 'audio-video', |
791 | 791 | 'module' => 'nsv', |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | ), |
794 | 794 | |
795 | 795 | // Ogg - audio/video - Ogg (Ogg Vorbis, OggFLAC, Speex, Ogg Theora(*), Ogg Tarkin(*)) |
796 | - 'ogg' => array ( |
|
796 | + 'ogg' => array( |
|
797 | 797 | 'pattern' => '^OggS', |
798 | 798 | 'group' => 'audio', |
799 | 799 | 'module' => 'xiph', |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | ), |
804 | 804 | |
805 | 805 | // QT - audio/video - Quicktime |
806 | - 'quicktime' => array ( |
|
806 | + 'quicktime' => array( |
|
807 | 807 | 'pattern' => '^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)', |
808 | 808 | 'group' => 'audio-video', |
809 | 809 | 'module' => 'quicktime', |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | ), |
812 | 812 | |
813 | 813 | // 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) |
814 | - 'riff' => array ( |
|
814 | + 'riff' => array( |
|
815 | 815 | 'pattern' => '^(RIFF|SDSS|FORM)', |
816 | 816 | 'group' => 'audio-video', |
817 | 817 | 'module' => 'riff', |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | ), |
821 | 821 | |
822 | 822 | // Real - audio/video - RealAudio, RealVideo |
823 | - 'real' => array ( |
|
823 | + 'real' => array( |
|
824 | 824 | 'pattern' => '^(\.RMF|.ra)', |
825 | 825 | 'group' => 'audio-video', |
826 | 826 | 'module' => 'real', |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | ), |
829 | 829 | |
830 | 830 | // SWF - audio/video - ShockWave Flash |
831 | - 'swf' => array ( |
|
831 | + 'swf' => array( |
|
832 | 832 | 'pattern' => '^(F|C)WS', |
833 | 833 | 'group' => 'audio-video', |
834 | 834 | 'module' => 'swf', |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | // Still-Image formats |
840 | 840 | |
841 | 841 | // BMP - still image - Bitmap (Windows, OS/2; uncompressed, RLE8, RLE4) |
842 | - 'bmp' => array ( |
|
842 | + 'bmp' => array( |
|
843 | 843 | 'pattern' => '^BM', |
844 | 844 | 'group' => 'graphic', |
845 | 845 | 'module' => 'bmp', |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | ), |
850 | 850 | |
851 | 851 | // GIF - still image - Graphics Interchange Format |
852 | - 'gif' => array ( |
|
852 | + 'gif' => array( |
|
853 | 853 | 'pattern' => '^GIF', |
854 | 854 | 'group' => 'graphic', |
855 | 855 | 'module' => 'gif', |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | ), |
860 | 860 | |
861 | 861 | // JPEG - still image - Joint Photographic Experts Group (JPEG) |
862 | - 'jpeg' => array ( |
|
862 | + 'jpeg' => array( |
|
863 | 863 | 'pattern' => '^\xFF\xD8\xFF', |
864 | 864 | 'group' => 'graphic', |
865 | 865 | 'module' => 'jpeg', |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | ), |
870 | 870 | |
871 | 871 | // PCD - still image - Kodak Photo CD |
872 | - 'pcd' => array ( |
|
872 | + 'pcd' => array( |
|
873 | 873 | 'pattern' => '^.{2048}PCD_IPI\x00', |
874 | 874 | 'group' => 'graphic', |
875 | 875 | 'module' => 'pcd', |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | |
881 | 881 | |
882 | 882 | // PNG - still image - Portable Network Graphics (PNG) |
883 | - 'png' => array ( |
|
883 | + 'png' => array( |
|
884 | 884 | 'pattern' => '^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A', |
885 | 885 | 'group' => 'graphic', |
886 | 886 | 'module' => 'png', |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | |
901 | 901 | |
902 | 902 | // TIFF - still image - Tagged Information File Format (TIFF) |
903 | - 'tiff' => array ( |
|
903 | + 'tiff' => array( |
|
904 | 904 | 'pattern' => '^(II\x2A\x00|MM\x00\x2A)', |
905 | 905 | 'group' => 'graphic', |
906 | 906 | 'module' => 'tiff', |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | ), |
921 | 921 | |
922 | 922 | // ISO - data - International Standards Organization (ISO) CD-ROM Image |
923 | - 'iso' => array ( |
|
923 | + 'iso' => array( |
|
924 | 924 | 'pattern' => '^.{32769}CD001', |
925 | 925 | 'group' => 'misc', |
926 | 926 | 'module' => 'iso', |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | ), |
939 | 939 | |
940 | 940 | // SZIP - audio - SZIP compressed data |
941 | - 'szip' => array ( |
|
941 | + 'szip' => array( |
|
942 | 942 | 'pattern' => '^SZ\x0A\x04', |
943 | 943 | 'group' => 'archive', |
944 | 944 | 'module' => 'szip', |
@@ -969,7 +969,7 @@ discard block |
||
969 | 969 | |
970 | 970 | |
971 | 971 | // ZIP - data - ZIP compressed data |
972 | - 'zip' => array ( |
|
972 | + 'zip' => array( |
|
973 | 973 | 'pattern' => '^PK\x03\x04', |
974 | 974 | 'group' => 'archive', |
975 | 975 | 'module' => 'zip', |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | |
981 | 981 | |
982 | 982 | // PAR2 - data - Parity Volume Set Specification 2.0 |
983 | - 'par2' => array ( |
|
983 | + 'par2' => array( |
|
984 | 984 | 'pattern' => '^PAR2\x00PKT', |
985 | 985 | 'mime_type' => 'application/octet-stream', |
986 | 986 | 'fail_id3' => 'ERROR', |
@@ -1039,22 +1039,22 @@ discard block |
||
1039 | 1039 | protected function HandleAllTags() { |
1040 | 1040 | |
1041 | 1041 | // Key name => array (tag name, character encoding) |
1042 | - static $tags = array ( |
|
1043 | - 'asf' => array ('asf', 'UTF-16LE'), |
|
1044 | - 'midi' => array ('midi', 'ISO-8859-1'), |
|
1045 | - 'nsv' => array ('nsv', 'ISO-8859-1'), |
|
1046 | - 'ogg' => array ('vorbiscomment', 'UTF-8'), |
|
1047 | - 'png' => array ('png', 'UTF-8'), |
|
1048 | - 'tiff' => array ('tiff', 'ISO-8859-1'), |
|
1049 | - 'quicktime' => array ('quicktime', 'ISO-8859-1'), |
|
1050 | - 'real' => array ('real', 'ISO-8859-1'), |
|
1051 | - 'vqf' => array ('vqf', 'ISO-8859-1'), |
|
1052 | - 'zip' => array ('zip', 'ISO-8859-1'), |
|
1053 | - 'riff' => array ('riff', 'ISO-8859-1'), |
|
1054 | - 'lyrics3' => array ('lyrics3', 'ISO-8859-1'), |
|
1055 | - 'id3v1' => array ('id3v1', ''), // change below - cannot assign variable to static array |
|
1056 | - 'id3v2' => array ('id3v2', 'UTF-8'), // module converts all frames to UTF-8 |
|
1057 | - 'ape' => array ('ape', 'UTF-8') |
|
1042 | + static $tags = array( |
|
1043 | + 'asf' => array('asf', 'UTF-16LE'), |
|
1044 | + 'midi' => array('midi', 'ISO-8859-1'), |
|
1045 | + 'nsv' => array('nsv', 'ISO-8859-1'), |
|
1046 | + 'ogg' => array('vorbiscomment', 'UTF-8'), |
|
1047 | + 'png' => array('png', 'UTF-8'), |
|
1048 | + 'tiff' => array('tiff', 'ISO-8859-1'), |
|
1049 | + 'quicktime' => array('quicktime', 'ISO-8859-1'), |
|
1050 | + 'real' => array('real', 'ISO-8859-1'), |
|
1051 | + 'vqf' => array('vqf', 'ISO-8859-1'), |
|
1052 | + 'zip' => array('zip', 'ISO-8859-1'), |
|
1053 | + 'riff' => array('riff', 'ISO-8859-1'), |
|
1054 | + 'lyrics3' => array('lyrics3', 'ISO-8859-1'), |
|
1055 | + 'id3v1' => array('id3v1', ''), // change below - cannot assign variable to static array |
|
1056 | + 'id3v2' => array('id3v2', 'UTF-8'), // module converts all frames to UTF-8 |
|
1057 | + 'ape' => array('ape', 'UTF-8') |
|
1058 | 1058 | ); |
1059 | 1059 | $tags['id3v1'][1] = $this->encoding_id3v1; |
1060 | 1060 | |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | list($tag_name, $encoding) = $tag_name_encoding_array; |
1064 | 1064 | |
1065 | 1065 | // Fill in default encoding type if not already present |
1066 | - @$this->info[$comment_name] and $this->info[$comment_name]['encoding'] = $encoding; |
|
1066 | + @$this->info[$comment_name] and $this->info[$comment_name]['encoding'] = $encoding; |
|
1067 | 1067 | |
1068 | 1068 | // Copy comments if key name set |
1069 | 1069 | if (@$this->info[$comment_name]['comments']) { |
@@ -1142,11 +1142,11 @@ discard block |
||
1142 | 1142 | abstract class getid3_handler |
1143 | 1143 | { |
1144 | 1144 | |
1145 | - protected $getid3; // pointer |
|
1145 | + protected $getid3; // pointer |
|
1146 | 1146 | |
1147 | - protected $data_string_flag = false; // analyzing filepointer or string |
|
1148 | - protected $data_string; // string to analyze |
|
1149 | - protected $data_string_position = 0; // seek position in string |
|
1147 | + protected $data_string_flag = false; // analyzing filepointer or string |
|
1148 | + protected $data_string; // string to analyze |
|
1149 | + protected $data_string_position = 0; // seek position in string |
|
1150 | 1150 | |
1151 | 1151 | |
1152 | 1152 | public function __construct(getID3 $getid3) { |
@@ -1247,20 +1247,20 @@ discard block |
||
1247 | 1247 | public function __construct($filename) { |
1248 | 1248 | |
1249 | 1249 | if (!file_exists($filename)) { |
1250 | - throw new getid3_exception('File does not exist: "' . $filename . '"'); |
|
1250 | + throw new getid3_exception('File does not exist: "'.$filename.'"'); |
|
1251 | 1251 | } |
1252 | 1252 | |
1253 | 1253 | if (!is_writeable($filename)) { |
1254 | - throw new getid3_exception('File is not writeable: "' . $filename . '"'); |
|
1254 | + throw new getid3_exception('File is not writeable: "'.$filename.'"'); |
|
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | if (!is_writeable(dirname($filename))) { |
1258 | - throw new getid3_exception('Directory is not writeable: ' . dirname($filename) . ' (need to write lock file).'); |
|
1258 | + throw new getid3_exception('Directory is not writeable: '.dirname($filename).' (need to write lock file).'); |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | $this->user_abort = ignore_user_abort(true); |
1262 | 1262 | |
1263 | - $this->fp_lock = fopen($filename . '.getid3.lock', 'w'); |
|
1263 | + $this->fp_lock = fopen($filename.'.getid3.lock', 'w'); |
|
1264 | 1264 | flock($this->fp_lock, LOCK_EX); |
1265 | 1265 | |
1266 | 1266 | $this->filename = $filename; |
@@ -1271,7 +1271,7 @@ discard block |
||
1271 | 1271 | |
1272 | 1272 | flock($this->fp_lock, LOCK_UN); |
1273 | 1273 | fclose($this->fp_lock); |
1274 | - unlink($this->filename . '.getid3.lock'); |
|
1274 | + unlink($this->filename.'.getid3.lock'); |
|
1275 | 1275 | |
1276 | 1276 | ignore_user_abort($this->user_abort); |
1277 | 1277 | } |
@@ -1325,7 +1325,7 @@ discard block |
||
1325 | 1325 | |
1326 | 1326 | |
1327 | 1327 | // Convert number to Little Endian byte string |
1328 | - public static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) { |
|
1328 | + public static function LittleEndian2String($number, $minbytes = 1, $synchsafe = false) { |
|
1329 | 1329 | $intstring = ''; |
1330 | 1330 | while ($number > 0) { |
1331 | 1331 | if ($synchsafe) { |
@@ -1485,7 +1485,7 @@ discard block |
||
1485 | 1485 | } |
1486 | 1486 | |
1487 | 1487 | |
1488 | - public static function PrintHexBytes($string, $hex=true, $spaces=true, $html_safe=true) { |
|
1488 | + public static function PrintHexBytes($string, $hex = true, $spaces = true, $html_safe = true) { |
|
1489 | 1489 | |
1490 | 1490 | $return_string = ''; |
1491 | 1491 | for ($i = 0; $i < strlen($string); $i++) { |
@@ -1545,7 +1545,7 @@ discard block |
||
1545 | 1545 | |
1546 | 1546 | public static function NameLookup($name_code) { |
1547 | 1547 | |
1548 | - static $lookup = array ( |
|
1548 | + static $lookup = array( |
|
1549 | 1549 | 0 => 'not set', |
1550 | 1550 | 1 => 'Track Gain Adjustment', |
1551 | 1551 | 2 => 'Album Gain Adjustment' |
@@ -1558,7 +1558,7 @@ discard block |
||
1558 | 1558 | |
1559 | 1559 | public static function OriginatorLookup($originator_code) { |
1560 | 1560 | |
1561 | - static $lookup = array ( |
|
1561 | + static $lookup = array( |
|
1562 | 1562 | 0 => 'unspecified', |
1563 | 1563 | 1 => 'pre-set by artist/producer/mastering engineer', |
1564 | 1564 | 2 => 'set by user', |
@@ -1572,7 +1572,7 @@ discard block |
||
1572 | 1572 | |
1573 | 1573 | public static function AdjustmentLookup($raw_adjustment, $sign_bit) { |
1574 | 1574 | |
1575 | - return (float)$raw_adjustment / 10 * ($sign_bit == 1 ? -1 : 1); |
|
1575 | + return (float) $raw_adjustment / 10 * ($sign_bit == 1 ? -1 : 1); |
|
1576 | 1576 | } |
1577 | 1577 | |
1578 | 1578 |
@@ -198,8 +198,7 @@ discard block |
||
198 | 198 | $tag_class = 'getid3_' . $tag_name; |
199 | 199 | $tag = new $tag_class($this); |
200 | 200 | $tag->Analyze(); |
201 | - } |
|
202 | - catch (getid3_exception $e) { |
|
201 | + } catch (getid3_exception $e) { |
|
203 | 202 | throw $e; |
204 | 203 | } |
205 | 204 | } |
@@ -243,9 +242,7 @@ discard block |
||
243 | 242 | // use assume format on these if format detection failed |
244 | 243 | if (preg_match('/\.mp[123a]$/i', $filename)) { |
245 | 244 | $determined_format = $file_format_array['mp3']; |
246 | - } |
|
247 | - |
|
248 | - else { |
|
245 | + } else { |
|
249 | 246 | fclose($this->fp); |
250 | 247 | throw new getid3_exception('Unable to determine file format'); |
251 | 248 | } |
@@ -259,8 +256,7 @@ discard block |
||
259 | 256 | if ($determined_format['fail_id3'] === 'ERROR') { |
260 | 257 | fclose($this->fp); |
261 | 258 | throw new getid3_exception('ID3 tags not allowed on this file type.'); |
262 | - } |
|
263 | - elseif ($determined_format['fail_id3'] === 'WARNING') { |
|
259 | + } elseif ($determined_format['fail_id3'] === 'WARNING') { |
|
264 | 260 | @$this->info['id3v1'] and $this->warning('ID3v1 tags not allowed on this file type.'); |
265 | 261 | @$this->info['id3v2'] and $this->warning('ID3v2 tags not allowed on this file type.'); |
266 | 262 | } |
@@ -301,11 +297,9 @@ discard block |
||
301 | 297 | |
302 | 298 | try { |
303 | 299 | $this->option_analyze and $class->Analyze(); |
304 | - } |
|
305 | - catch (getid3_exception $e) { |
|
300 | + } catch (getid3_exception $e) { |
|
306 | 301 | throw $e; |
307 | - } |
|
308 | - catch (Exception $e) { |
|
302 | + } catch (Exception $e) { |
|
309 | 303 | throw new getid3_exception('Corrupt file.'); |
310 | 304 | } |
311 | 305 | |
@@ -460,8 +454,7 @@ discard block |
||
460 | 454 | |
461 | 455 | if (is_array($message)) { |
462 | 456 | $this->warnings = array_merge($this->warnings, $message); |
463 | - } |
|
464 | - else { |
|
457 | + } else { |
|
465 | 458 | $this->warnings[] = $message; |
466 | 459 | } |
467 | 460 | } |
@@ -1101,8 +1094,7 @@ discard block |
||
1101 | 1094 | if (empty($this->info['comments'][$tag_name])) { |
1102 | 1095 | |
1103 | 1096 | // fall through and append value |
1104 | - } |
|
1105 | - elseif ($tag_type == 'id3v1') { |
|
1097 | + } elseif ($tag_type == 'id3v1') { |
|
1106 | 1098 | |
1107 | 1099 | $new_value_length = strlen(trim($value)); |
1108 | 1100 | foreach ($this->info['comments'][$tag_name] as $existing_key => $existing_value) { |
@@ -1112,8 +1104,7 @@ discard block |
||
1112 | 1104 | break 2; |
1113 | 1105 | } |
1114 | 1106 | } |
1115 | - } |
|
1116 | - else { |
|
1107 | + } else { |
|
1117 | 1108 | |
1118 | 1109 | $new_value_length = strlen(trim($value)); |
1119 | 1110 | foreach ($this->info['comments'][$tag_name] as $existing_key => $existing_value) { |
@@ -276,6 +276,9 @@ discard block |
||
276 | 276 | public $pos; |
277 | 277 | |
278 | 278 | |
279 | + /** |
|
280 | + * @param string $bytes |
|
281 | + */ |
|
279 | 282 | public function AMFStream($bytes) { |
280 | 283 | |
281 | 284 | $this->bytes = $bytes; |
@@ -389,6 +392,9 @@ discard block |
||
389 | 392 | { |
390 | 393 | public $stream; |
391 | 394 | |
395 | + /** |
|
396 | + * @param AMFStream $stream |
|
397 | + */ |
|
392 | 398 | public function __construct($stream) { |
393 | 399 | |
394 | 400 | $this->stream = $stream; |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | // |
40 | 40 | // $Id: module.audio-video.flv.php,v 1.7 2006/11/10 11:20:12 ah Exp $ |
41 | 41 | /** |
42 | - * @package chamilo.include.flv |
|
43 | - */ |
|
42 | + * @package chamilo.include.flv |
|
43 | + */ |
|
44 | 44 | /** |
45 | - * Class |
|
46 | - * @package chamilo.include.flv |
|
47 | - */ |
|
45 | + * Class |
|
46 | + * @package chamilo.include.flv |
|
47 | + */ |
|
48 | 48 | class getid3_flv extends getid3_handler { |
49 | 49 | |
50 | 50 | const TAG_AUDIO = 8; |
@@ -56,522 +56,522 @@ discard block |
||
56 | 56 | const VIDEO_VP6 = 4; |
57 | 57 | |
58 | 58 | |
59 | - public function Analyze() |
|
60 | - { |
|
61 | - $info = &$this->getid3->info; |
|
59 | + public function Analyze() |
|
60 | + { |
|
61 | + $info = &$this->getid3->info; |
|
62 | 62 | |
63 | - $info['flv'] = array (); |
|
64 | - $info_flv = &$info['flv']; |
|
63 | + $info['flv'] = array (); |
|
64 | + $info_flv = &$info['flv']; |
|
65 | 65 | |
66 | - fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET); |
|
66 | + fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET); |
|
67 | 67 | |
68 | - $flv_data_length = $info['avdataend'] - $info['avdataoffset']; |
|
69 | - $flv_header = fread($this->getid3->fp, 5); |
|
70 | - |
|
71 | - $info['fileformat'] = 'flv'; |
|
72 | - $info_flv['header']['signature'] = substr($flv_header, 0, 3); |
|
73 | - $info_flv['header']['version'] = getid3_lib::BigEndian2Int(substr($flv_header, 3, 1)); |
|
74 | - $type_flags = getid3_lib::BigEndian2Int(substr($flv_header, 4, 1)); |
|
68 | + $flv_data_length = $info['avdataend'] - $info['avdataoffset']; |
|
69 | + $flv_header = fread($this->getid3->fp, 5); |
|
70 | + |
|
71 | + $info['fileformat'] = 'flv'; |
|
72 | + $info_flv['header']['signature'] = substr($flv_header, 0, 3); |
|
73 | + $info_flv['header']['version'] = getid3_lib::BigEndian2Int(substr($flv_header, 3, 1)); |
|
74 | + $type_flags = getid3_lib::BigEndian2Int(substr($flv_header, 4, 1)); |
|
75 | 75 | |
76 | - $info_flv['header']['hasAudio'] = (bool) ($type_flags & 0x04); |
|
77 | - $info_flv['header']['hasVideo'] = (bool) ($type_flags & 0x01); |
|
76 | + $info_flv['header']['hasAudio'] = (bool) ($type_flags & 0x04); |
|
77 | + $info_flv['header']['hasVideo'] = (bool) ($type_flags & 0x01); |
|
78 | 78 | |
79 | - $frame_size_data_length = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 4)); |
|
80 | - $flv_header_frame_length = 9; |
|
81 | - if ($frame_size_data_length > $flv_header_frame_length) { |
|
82 | - fseek($this->getid3->fp, $frame_size_data_length - $flv_header_frame_length, SEEK_CUR); |
|
83 | - } |
|
84 | - |
|
85 | - $duration = 0; |
|
86 | - while ((ftell($this->getid3->fp) + 1) < $info['avdataend']) { |
|
87 | - |
|
88 | - $this_tag_header = fread($this->getid3->fp, 16); |
|
89 | - |
|
90 | - $previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 0, 4)); |
|
91 | - $tag_type = getid3_lib::BigEndian2Int(substr($this_tag_header, 4, 1)); |
|
92 | - $data_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 5, 3)); |
|
93 | - $timestamp = getid3_lib::BigEndian2Int(substr($this_tag_header, 8, 3)); |
|
94 | - $last_header_byte = getid3_lib::BigEndian2Int(substr($this_tag_header, 15, 1)); |
|
95 | - $next_offset = ftell($this->getid3->fp) - 1 + $data_length; |
|
96 | - |
|
97 | - switch ($tag_type) { |
|
98 | - |
|
99 | - case getid3_flv::TAG_AUDIO: |
|
100 | - if (!isset($info_flv['audio']['audioFormat'])) { |
|
101 | - $info_flv['audio']['audioFormat'] = $last_header_byte & 0x07; |
|
102 | - $info_flv['audio']['audioRate'] = ($last_header_byte & 0x30) / 0x10; |
|
103 | - $info_flv['audio']['audioSampleSize'] = ($last_header_byte & 0x40) / 0x40; |
|
104 | - $info_flv['audio']['audioType'] = ($last_header_byte & 0x80) / 0x80; |
|
105 | - } |
|
106 | - break; |
|
107 | - |
|
108 | - |
|
109 | - case getid3_flv::TAG_VIDEO: |
|
110 | - if (!isset($info_flv['video']['videoCodec'])) { |
|
111 | - $info_flv['video']['videoCodec'] = $last_header_byte & 0x07; |
|
112 | - |
|
113 | - $flv_video_header = fread($this->getid3->fp, 11); |
|
114 | - |
|
115 | - if ($info_flv['video']['videoCodec'] != getid3_flv::VIDEO_VP6) { |
|
116 | - |
|
117 | - $picture_size_type = (getid3_lib::BigEndian2Int(substr($flv_video_header, 3, 2))) >> 7; |
|
118 | - $picture_size_type = $picture_size_type & 0x0007; |
|
119 | - $info_flv['header']['videoSizeType'] = $picture_size_type; |
|
120 | - |
|
121 | - switch ($picture_size_type) { |
|
122 | - case 0: |
|
123 | - $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 2)); |
|
124 | - $picture_size_enc <<= 1; |
|
125 | - $info['video']['resolution_x'] = ($picture_size_enc & 0xFF00) >> 8; |
|
126 | - $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 6, 2)); |
|
127 | - $picture_size_enc <<= 1; |
|
128 | - $info['video']['resolution_y'] = ($picture_size_enc & 0xFF00) >> 8; |
|
129 | - break; |
|
130 | - |
|
131 | - case 1: |
|
132 | - $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 4)); |
|
133 | - $picture_size_enc <<= 1; |
|
134 | - $info['video']['resolution_x'] = ($picture_size_enc & 0xFFFF0000) >> 16; |
|
135 | - |
|
136 | - $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 7, 4)); |
|
137 | - $picture_size_enc <<= 1; |
|
138 | - $info['video']['resolution_y'] = ($picture_size_enc & 0xFFFF0000) >> 16; |
|
139 | - break; |
|
140 | - |
|
141 | - case 2: |
|
142 | - $info['video']['resolution_x'] = 352; |
|
143 | - $info['video']['resolution_y'] = 288; |
|
144 | - break; |
|
145 | - |
|
146 | - case 3: |
|
147 | - $info['video']['resolution_x'] = 176; |
|
148 | - $info['video']['resolution_y'] = 144; |
|
149 | - break; |
|
150 | - |
|
151 | - case 4: |
|
152 | - $info['video']['resolution_x'] = 128; |
|
153 | - $info['video']['resolution_y'] = 96; |
|
154 | - break; |
|
155 | - |
|
156 | - case 5: |
|
157 | - $info['video']['resolution_x'] = 320; |
|
158 | - $info['video']['resolution_y'] = 240; |
|
159 | - break; |
|
160 | - |
|
161 | - case 6: |
|
162 | - $info['video']['resolution_x'] = 160; |
|
163 | - $info['video']['resolution_y'] = 120; |
|
164 | - break; |
|
165 | - |
|
166 | - default: |
|
167 | - $info['video']['resolution_x'] = 0; |
|
168 | - $info['video']['resolution_y'] = 0; |
|
169 | - break; |
|
170 | - } |
|
171 | - } |
|
172 | - } |
|
173 | - break; |
|
174 | - |
|
175 | - |
|
176 | - // Meta tag |
|
177 | - case getid3_flv::TAG_META: |
|
178 | - |
|
179 | - fseek($this->getid3->fp, -1, SEEK_CUR); |
|
180 | - $reader = new AMFReader(new AMFStream(fread($this->getid3->fp, $data_length))); |
|
181 | - $event_name = $reader->readData(); |
|
182 | - $info['meta'][$event_name] = $reader->readData(); |
|
183 | - unset($reader); |
|
184 | - |
|
185 | - $info['video']['frame_rate'] = @$info['meta']['onMetaData']['framerate']; |
|
186 | - $info['video']['resolution_x'] = @$info['meta']['onMetaData']['width']; |
|
187 | - $info['video']['resolution_y'] = @$info['meta']['onMetaData']['height']; |
|
188 | - break; |
|
189 | - |
|
190 | - default: |
|
191 | - // noop |
|
192 | - break; |
|
193 | - } |
|
194 | - |
|
195 | - if ($timestamp > $duration) { |
|
196 | - $duration = $timestamp; |
|
197 | - } |
|
198 | - |
|
199 | - fseek($this->getid3->fp, $next_offset, SEEK_SET); |
|
200 | - } |
|
201 | - |
|
202 | - if ($info['playtime_seconds'] = $duration / 1000) { |
|
203 | - $info['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']; |
|
204 | - } |
|
205 | - |
|
206 | - if ($info_flv['header']['hasAudio']) { |
|
207 | - $info['audio']['codec'] = $this->FLVaudioFormat($info_flv['audio']['audioFormat']); |
|
208 | - $info['audio']['sample_rate'] = $this->FLVaudioRate($info_flv['audio']['audioRate']); |
|
209 | - $info['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($info_flv['audio']['audioSampleSize']); |
|
210 | - |
|
211 | - $info['audio']['channels'] = $info_flv['audio']['audioType'] + 1; // 0=mono,1=stereo |
|
212 | - $info['audio']['lossless'] = ($info_flv['audio']['audioFormat'] ? false : true); // 0=uncompressed |
|
213 | - $info['audio']['dataformat'] = 'flv'; |
|
214 | - } |
|
215 | - if (@$info_flv['header']['hasVideo']) { |
|
216 | - $info['video']['codec'] = $this->FLVvideoCodec($info_flv['video']['videoCodec']); |
|
217 | - $info['video']['dataformat'] = 'flv'; |
|
218 | - $info['video']['lossless'] = false; |
|
219 | - } |
|
220 | - |
|
221 | - return true; |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - public static function FLVaudioFormat($id) { |
|
226 | - |
|
227 | - static $lookup = array( |
|
228 | - 0 => 'uncompressed', |
|
229 | - 1 => 'ADPCM', |
|
230 | - 2 => 'mp3', |
|
231 | - 5 => 'Nellymoser 8kHz mono', |
|
232 | - 6 => 'Nellymoser', |
|
233 | - ); |
|
234 | - return (@$lookup[$id] ? @$lookup[$id] : false); |
|
235 | - } |
|
236 | - |
|
237 | - |
|
238 | - public static function FLVaudioRate($id) { |
|
239 | - |
|
240 | - static $lookup = array( |
|
241 | - 0 => 5500, |
|
242 | - 1 => 11025, |
|
243 | - 2 => 22050, |
|
244 | - 3 => 44100, |
|
245 | - ); |
|
246 | - return (@$lookup[$id] ? @$lookup[$id] : false); |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - public static function FLVaudioBitDepth($id) { |
|
251 | - |
|
252 | - static $lookup = array( |
|
253 | - 0 => 8, |
|
254 | - 1 => 16, |
|
255 | - ); |
|
256 | - return (@$lookup[$id] ? @$lookup[$id] : false); |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - public static function FLVvideoCodec($id) { |
|
261 | - |
|
262 | - static $lookup = array( |
|
263 | - getid3_flv::VIDEO_H263 => 'Sorenson H.263', |
|
264 | - getid3_flv::VIDEO_SCREEN => 'Screen video', |
|
265 | - getid3_flv::VIDEO_VP6 => 'On2 VP6', |
|
266 | - ); |
|
267 | - return (@$lookup[$id] ? @$lookup[$id] : false); |
|
268 | - } |
|
79 | + $frame_size_data_length = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 4)); |
|
80 | + $flv_header_frame_length = 9; |
|
81 | + if ($frame_size_data_length > $flv_header_frame_length) { |
|
82 | + fseek($this->getid3->fp, $frame_size_data_length - $flv_header_frame_length, SEEK_CUR); |
|
83 | + } |
|
84 | + |
|
85 | + $duration = 0; |
|
86 | + while ((ftell($this->getid3->fp) + 1) < $info['avdataend']) { |
|
87 | + |
|
88 | + $this_tag_header = fread($this->getid3->fp, 16); |
|
89 | + |
|
90 | + $previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 0, 4)); |
|
91 | + $tag_type = getid3_lib::BigEndian2Int(substr($this_tag_header, 4, 1)); |
|
92 | + $data_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 5, 3)); |
|
93 | + $timestamp = getid3_lib::BigEndian2Int(substr($this_tag_header, 8, 3)); |
|
94 | + $last_header_byte = getid3_lib::BigEndian2Int(substr($this_tag_header, 15, 1)); |
|
95 | + $next_offset = ftell($this->getid3->fp) - 1 + $data_length; |
|
96 | + |
|
97 | + switch ($tag_type) { |
|
98 | + |
|
99 | + case getid3_flv::TAG_AUDIO: |
|
100 | + if (!isset($info_flv['audio']['audioFormat'])) { |
|
101 | + $info_flv['audio']['audioFormat'] = $last_header_byte & 0x07; |
|
102 | + $info_flv['audio']['audioRate'] = ($last_header_byte & 0x30) / 0x10; |
|
103 | + $info_flv['audio']['audioSampleSize'] = ($last_header_byte & 0x40) / 0x40; |
|
104 | + $info_flv['audio']['audioType'] = ($last_header_byte & 0x80) / 0x80; |
|
105 | + } |
|
106 | + break; |
|
107 | + |
|
108 | + |
|
109 | + case getid3_flv::TAG_VIDEO: |
|
110 | + if (!isset($info_flv['video']['videoCodec'])) { |
|
111 | + $info_flv['video']['videoCodec'] = $last_header_byte & 0x07; |
|
112 | + |
|
113 | + $flv_video_header = fread($this->getid3->fp, 11); |
|
114 | + |
|
115 | + if ($info_flv['video']['videoCodec'] != getid3_flv::VIDEO_VP6) { |
|
116 | + |
|
117 | + $picture_size_type = (getid3_lib::BigEndian2Int(substr($flv_video_header, 3, 2))) >> 7; |
|
118 | + $picture_size_type = $picture_size_type & 0x0007; |
|
119 | + $info_flv['header']['videoSizeType'] = $picture_size_type; |
|
120 | + |
|
121 | + switch ($picture_size_type) { |
|
122 | + case 0: |
|
123 | + $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 2)); |
|
124 | + $picture_size_enc <<= 1; |
|
125 | + $info['video']['resolution_x'] = ($picture_size_enc & 0xFF00) >> 8; |
|
126 | + $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 6, 2)); |
|
127 | + $picture_size_enc <<= 1; |
|
128 | + $info['video']['resolution_y'] = ($picture_size_enc & 0xFF00) >> 8; |
|
129 | + break; |
|
130 | + |
|
131 | + case 1: |
|
132 | + $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 4)); |
|
133 | + $picture_size_enc <<= 1; |
|
134 | + $info['video']['resolution_x'] = ($picture_size_enc & 0xFFFF0000) >> 16; |
|
135 | + |
|
136 | + $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 7, 4)); |
|
137 | + $picture_size_enc <<= 1; |
|
138 | + $info['video']['resolution_y'] = ($picture_size_enc & 0xFFFF0000) >> 16; |
|
139 | + break; |
|
140 | + |
|
141 | + case 2: |
|
142 | + $info['video']['resolution_x'] = 352; |
|
143 | + $info['video']['resolution_y'] = 288; |
|
144 | + break; |
|
145 | + |
|
146 | + case 3: |
|
147 | + $info['video']['resolution_x'] = 176; |
|
148 | + $info['video']['resolution_y'] = 144; |
|
149 | + break; |
|
150 | + |
|
151 | + case 4: |
|
152 | + $info['video']['resolution_x'] = 128; |
|
153 | + $info['video']['resolution_y'] = 96; |
|
154 | + break; |
|
155 | + |
|
156 | + case 5: |
|
157 | + $info['video']['resolution_x'] = 320; |
|
158 | + $info['video']['resolution_y'] = 240; |
|
159 | + break; |
|
160 | + |
|
161 | + case 6: |
|
162 | + $info['video']['resolution_x'] = 160; |
|
163 | + $info['video']['resolution_y'] = 120; |
|
164 | + break; |
|
165 | + |
|
166 | + default: |
|
167 | + $info['video']['resolution_x'] = 0; |
|
168 | + $info['video']['resolution_y'] = 0; |
|
169 | + break; |
|
170 | + } |
|
171 | + } |
|
172 | + } |
|
173 | + break; |
|
174 | + |
|
175 | + |
|
176 | + // Meta tag |
|
177 | + case getid3_flv::TAG_META: |
|
178 | + |
|
179 | + fseek($this->getid3->fp, -1, SEEK_CUR); |
|
180 | + $reader = new AMFReader(new AMFStream(fread($this->getid3->fp, $data_length))); |
|
181 | + $event_name = $reader->readData(); |
|
182 | + $info['meta'][$event_name] = $reader->readData(); |
|
183 | + unset($reader); |
|
184 | + |
|
185 | + $info['video']['frame_rate'] = @$info['meta']['onMetaData']['framerate']; |
|
186 | + $info['video']['resolution_x'] = @$info['meta']['onMetaData']['width']; |
|
187 | + $info['video']['resolution_y'] = @$info['meta']['onMetaData']['height']; |
|
188 | + break; |
|
189 | + |
|
190 | + default: |
|
191 | + // noop |
|
192 | + break; |
|
193 | + } |
|
194 | + |
|
195 | + if ($timestamp > $duration) { |
|
196 | + $duration = $timestamp; |
|
197 | + } |
|
198 | + |
|
199 | + fseek($this->getid3->fp, $next_offset, SEEK_SET); |
|
200 | + } |
|
201 | + |
|
202 | + if ($info['playtime_seconds'] = $duration / 1000) { |
|
203 | + $info['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']; |
|
204 | + } |
|
205 | + |
|
206 | + if ($info_flv['header']['hasAudio']) { |
|
207 | + $info['audio']['codec'] = $this->FLVaudioFormat($info_flv['audio']['audioFormat']); |
|
208 | + $info['audio']['sample_rate'] = $this->FLVaudioRate($info_flv['audio']['audioRate']); |
|
209 | + $info['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($info_flv['audio']['audioSampleSize']); |
|
210 | + |
|
211 | + $info['audio']['channels'] = $info_flv['audio']['audioType'] + 1; // 0=mono,1=stereo |
|
212 | + $info['audio']['lossless'] = ($info_flv['audio']['audioFormat'] ? false : true); // 0=uncompressed |
|
213 | + $info['audio']['dataformat'] = 'flv'; |
|
214 | + } |
|
215 | + if (@$info_flv['header']['hasVideo']) { |
|
216 | + $info['video']['codec'] = $this->FLVvideoCodec($info_flv['video']['videoCodec']); |
|
217 | + $info['video']['dataformat'] = 'flv'; |
|
218 | + $info['video']['lossless'] = false; |
|
219 | + } |
|
220 | + |
|
221 | + return true; |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + public static function FLVaudioFormat($id) { |
|
226 | + |
|
227 | + static $lookup = array( |
|
228 | + 0 => 'uncompressed', |
|
229 | + 1 => 'ADPCM', |
|
230 | + 2 => 'mp3', |
|
231 | + 5 => 'Nellymoser 8kHz mono', |
|
232 | + 6 => 'Nellymoser', |
|
233 | + ); |
|
234 | + return (@$lookup[$id] ? @$lookup[$id] : false); |
|
235 | + } |
|
236 | + |
|
237 | + |
|
238 | + public static function FLVaudioRate($id) { |
|
239 | + |
|
240 | + static $lookup = array( |
|
241 | + 0 => 5500, |
|
242 | + 1 => 11025, |
|
243 | + 2 => 22050, |
|
244 | + 3 => 44100, |
|
245 | + ); |
|
246 | + return (@$lookup[$id] ? @$lookup[$id] : false); |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + public static function FLVaudioBitDepth($id) { |
|
251 | + |
|
252 | + static $lookup = array( |
|
253 | + 0 => 8, |
|
254 | + 1 => 16, |
|
255 | + ); |
|
256 | + return (@$lookup[$id] ? @$lookup[$id] : false); |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + public static function FLVvideoCodec($id) { |
|
261 | + |
|
262 | + static $lookup = array( |
|
263 | + getid3_flv::VIDEO_H263 => 'Sorenson H.263', |
|
264 | + getid3_flv::VIDEO_SCREEN => 'Screen video', |
|
265 | + getid3_flv::VIDEO_VP6 => 'On2 VP6', |
|
266 | + ); |
|
267 | + return (@$lookup[$id] ? @$lookup[$id] : false); |
|
268 | + } |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | |
272 | 272 | |
273 | 273 | class AMFStream |
274 | 274 | { |
275 | - public $bytes; |
|
276 | - public $pos; |
|
275 | + public $bytes; |
|
276 | + public $pos; |
|
277 | 277 | |
278 | 278 | |
279 | - public function AMFStream($bytes) { |
|
279 | + public function AMFStream($bytes) { |
|
280 | 280 | |
281 | - $this->bytes = $bytes; |
|
282 | - $this->pos = 0; |
|
283 | - } |
|
281 | + $this->bytes = $bytes; |
|
282 | + $this->pos = 0; |
|
283 | + } |
|
284 | 284 | |
285 | 285 | |
286 | - public function readByte() { |
|
286 | + public function readByte() { |
|
287 | 287 | |
288 | - return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1)); |
|
289 | - } |
|
288 | + return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1)); |
|
289 | + } |
|
290 | 290 | |
291 | 291 | |
292 | - public function readInt() { |
|
292 | + public function readInt() { |
|
293 | 293 | |
294 | - return ($this->readByte() << 8) + $this->readByte(); |
|
295 | - } |
|
294 | + return ($this->readByte() << 8) + $this->readByte(); |
|
295 | + } |
|
296 | 296 | |
297 | 297 | |
298 | - public function readLong() { |
|
298 | + public function readLong() { |
|
299 | 299 | |
300 | - return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte(); |
|
301 | - } |
|
300 | + return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte(); |
|
301 | + } |
|
302 | 302 | |
303 | 303 | |
304 | - public function readDouble() { |
|
304 | + public function readDouble() { |
|
305 | 305 | |
306 | - return getid3_lib::BigEndian2Float($this->read(8)); |
|
307 | - } |
|
306 | + return getid3_lib::BigEndian2Float($this->read(8)); |
|
307 | + } |
|
308 | 308 | |
309 | 309 | |
310 | - public function readUTF() { |
|
310 | + public function readUTF() { |
|
311 | 311 | |
312 | - $length = $this->readInt(); |
|
313 | - return $this->read($length); |
|
314 | - } |
|
312 | + $length = $this->readInt(); |
|
313 | + return $this->read($length); |
|
314 | + } |
|
315 | 315 | |
316 | 316 | |
317 | - public function readLongUTF() { |
|
317 | + public function readLongUTF() { |
|
318 | 318 | |
319 | - $length = $this->readLong(); |
|
320 | - return $this->read($length); |
|
321 | - } |
|
319 | + $length = $this->readLong(); |
|
320 | + return $this->read($length); |
|
321 | + } |
|
322 | 322 | |
323 | 323 | |
324 | - public function read($length) { |
|
324 | + public function read($length) { |
|
325 | 325 | |
326 | - $val = substr($this->bytes, $this->pos, $length); |
|
327 | - $this->pos += $length; |
|
328 | - return $val; |
|
329 | - } |
|
326 | + $val = substr($this->bytes, $this->pos, $length); |
|
327 | + $this->pos += $length; |
|
328 | + return $val; |
|
329 | + } |
|
330 | 330 | |
331 | 331 | |
332 | - public function peekByte() { |
|
332 | + public function peekByte() { |
|
333 | 333 | |
334 | - $pos = $this->pos; |
|
335 | - $val = $this->readByte(); |
|
336 | - $this->pos = $pos; |
|
337 | - return $val; |
|
338 | - } |
|
334 | + $pos = $this->pos; |
|
335 | + $val = $this->readByte(); |
|
336 | + $this->pos = $pos; |
|
337 | + return $val; |
|
338 | + } |
|
339 | 339 | |
340 | 340 | |
341 | - public function peekInt() { |
|
341 | + public function peekInt() { |
|
342 | 342 | |
343 | - $pos = $this->pos; |
|
344 | - $val = $this->readInt(); |
|
345 | - $this->pos = $pos; |
|
346 | - return $val; |
|
347 | - } |
|
343 | + $pos = $this->pos; |
|
344 | + $val = $this->readInt(); |
|
345 | + $this->pos = $pos; |
|
346 | + return $val; |
|
347 | + } |
|
348 | 348 | |
349 | 349 | |
350 | - public function peekLong() { |
|
350 | + public function peekLong() { |
|
351 | 351 | |
352 | - $pos = $this->pos; |
|
353 | - $val = $this->readLong(); |
|
354 | - $this->pos = $pos; |
|
355 | - return $val; |
|
356 | - } |
|
352 | + $pos = $this->pos; |
|
353 | + $val = $this->readLong(); |
|
354 | + $this->pos = $pos; |
|
355 | + return $val; |
|
356 | + } |
|
357 | 357 | |
358 | 358 | |
359 | - public function peekDouble() { |
|
359 | + public function peekDouble() { |
|
360 | 360 | |
361 | - $pos = $this->pos; |
|
362 | - $val = $this->readDouble(); |
|
363 | - $this->pos = $pos; |
|
364 | - return $val; |
|
365 | - } |
|
361 | + $pos = $this->pos; |
|
362 | + $val = $this->readDouble(); |
|
363 | + $this->pos = $pos; |
|
364 | + return $val; |
|
365 | + } |
|
366 | 366 | |
367 | 367 | |
368 | - public function peekUTF() { |
|
368 | + public function peekUTF() { |
|
369 | 369 | |
370 | - $pos = $this->pos; |
|
371 | - $val = $this->readUTF(); |
|
372 | - $this->pos = $pos; |
|
373 | - return $val; |
|
374 | - } |
|
370 | + $pos = $this->pos; |
|
371 | + $val = $this->readUTF(); |
|
372 | + $this->pos = $pos; |
|
373 | + return $val; |
|
374 | + } |
|
375 | 375 | |
376 | 376 | |
377 | - public function peekLongUTF() { |
|
377 | + public function peekLongUTF() { |
|
378 | 378 | |
379 | - $pos = $this->pos; |
|
380 | - $val = $this->readLongUTF(); |
|
381 | - $this->pos = $pos; |
|
382 | - return $val; |
|
383 | - } |
|
379 | + $pos = $this->pos; |
|
380 | + $val = $this->readLongUTF(); |
|
381 | + $this->pos = $pos; |
|
382 | + return $val; |
|
383 | + } |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
387 | 387 | |
388 | 388 | class AMFReader |
389 | 389 | { |
390 | - public $stream; |
|
390 | + public $stream; |
|
391 | 391 | |
392 | - public function __construct($stream) { |
|
392 | + public function __construct($stream) { |
|
393 | 393 | |
394 | - $this->stream = $stream; |
|
395 | - } |
|
394 | + $this->stream = $stream; |
|
395 | + } |
|
396 | 396 | |
397 | 397 | |
398 | - public function readData() { |
|
398 | + public function readData() { |
|
399 | 399 | |
400 | - $value = null; |
|
400 | + $value = null; |
|
401 | 401 | |
402 | - $type = $this->stream->readByte(); |
|
402 | + $type = $this->stream->readByte(); |
|
403 | 403 | |
404 | - switch($type) { |
|
405 | - // Double |
|
406 | - case 0: |
|
407 | - $value = $this->readDouble(); |
|
408 | - break; |
|
404 | + switch($type) { |
|
405 | + // Double |
|
406 | + case 0: |
|
407 | + $value = $this->readDouble(); |
|
408 | + break; |
|
409 | 409 | |
410 | - // Boolean |
|
411 | - case 1: |
|
412 | - $value = $this->readBoolean(); |
|
413 | - break; |
|
410 | + // Boolean |
|
411 | + case 1: |
|
412 | + $value = $this->readBoolean(); |
|
413 | + break; |
|
414 | 414 | |
415 | - // String |
|
416 | - case 2: |
|
417 | - $value = $this->readString(); |
|
418 | - break; |
|
415 | + // String |
|
416 | + case 2: |
|
417 | + $value = $this->readString(); |
|
418 | + break; |
|
419 | 419 | |
420 | - // Object |
|
421 | - case 3: |
|
422 | - $value = $this->readObject(); |
|
423 | - break; |
|
420 | + // Object |
|
421 | + case 3: |
|
422 | + $value = $this->readObject(); |
|
423 | + break; |
|
424 | 424 | |
425 | - // null |
|
426 | - case 6: |
|
427 | - return null; |
|
428 | - break; |
|
425 | + // null |
|
426 | + case 6: |
|
427 | + return null; |
|
428 | + break; |
|
429 | 429 | |
430 | - // Mixed array |
|
431 | - case 8: |
|
432 | - $value = $this->readMixedArray(); |
|
433 | - break; |
|
430 | + // Mixed array |
|
431 | + case 8: |
|
432 | + $value = $this->readMixedArray(); |
|
433 | + break; |
|
434 | 434 | |
435 | - // Array |
|
436 | - case 10: |
|
437 | - $value = $this->readArray(); |
|
438 | - break; |
|
435 | + // Array |
|
436 | + case 10: |
|
437 | + $value = $this->readArray(); |
|
438 | + break; |
|
439 | 439 | |
440 | - // Date |
|
441 | - case 11: |
|
442 | - $value = $this->readDate(); |
|
443 | - break; |
|
440 | + // Date |
|
441 | + case 11: |
|
442 | + $value = $this->readDate(); |
|
443 | + break; |
|
444 | 444 | |
445 | - // Long string |
|
446 | - case 13: |
|
447 | - $value = $this->readLongString(); |
|
448 | - break; |
|
445 | + // Long string |
|
446 | + case 13: |
|
447 | + $value = $this->readLongString(); |
|
448 | + break; |
|
449 | 449 | |
450 | - // XML (handled as string) |
|
451 | - case 15: |
|
452 | - $value = $this->readXML(); |
|
453 | - break; |
|
450 | + // XML (handled as string) |
|
451 | + case 15: |
|
452 | + $value = $this->readXML(); |
|
453 | + break; |
|
454 | 454 | |
455 | - // Typed object (handled as object) |
|
456 | - case 16: |
|
457 | - $value = $this->readTypedObject(); |
|
458 | - break; |
|
455 | + // Typed object (handled as object) |
|
456 | + case 16: |
|
457 | + $value = $this->readTypedObject(); |
|
458 | + break; |
|
459 | 459 | |
460 | - // Long string |
|
461 | - default: |
|
462 | - $value = '(unknown or unsupported data type)'; |
|
463 | - break; |
|
464 | - } |
|
460 | + // Long string |
|
461 | + default: |
|
462 | + $value = '(unknown or unsupported data type)'; |
|
463 | + break; |
|
464 | + } |
|
465 | 465 | |
466 | - return $value; |
|
467 | - } |
|
466 | + return $value; |
|
467 | + } |
|
468 | 468 | |
469 | 469 | |
470 | - public function readDouble() { |
|
470 | + public function readDouble() { |
|
471 | 471 | |
472 | - return $this->stream->readDouble(); |
|
473 | - } |
|
472 | + return $this->stream->readDouble(); |
|
473 | + } |
|
474 | 474 | |
475 | 475 | |
476 | - public function readBoolean() { |
|
476 | + public function readBoolean() { |
|
477 | 477 | |
478 | - return $this->stream->readByte() == 1; |
|
479 | - } |
|
478 | + return $this->stream->readByte() == 1; |
|
479 | + } |
|
480 | 480 | |
481 | 481 | |
482 | - public function readString() { |
|
482 | + public function readString() { |
|
483 | 483 | |
484 | - return $this->stream->readUTF(); |
|
485 | - } |
|
484 | + return $this->stream->readUTF(); |
|
485 | + } |
|
486 | 486 | |
487 | 487 | |
488 | - public function readObject() { |
|
488 | + public function readObject() { |
|
489 | 489 | |
490 | - // Get highest numerical index - ignored |
|
491 | - $highestIndex = $this->stream->readLong(); |
|
490 | + // Get highest numerical index - ignored |
|
491 | + $highestIndex = $this->stream->readLong(); |
|
492 | 492 | |
493 | - $data = array(); |
|
493 | + $data = array(); |
|
494 | 494 | |
495 | - while ($key = $this->stream->readUTF()) { |
|
496 | - // Mixed array record ends with empty string (0x00 0x00) and 0x09 |
|
497 | - if (($key == '') && ($this->stream->peekByte() == 0x09)) { |
|
498 | - // Consume byte |
|
499 | - $this->stream->readByte(); |
|
500 | - break; |
|
501 | - } |
|
495 | + while ($key = $this->stream->readUTF()) { |
|
496 | + // Mixed array record ends with empty string (0x00 0x00) and 0x09 |
|
497 | + if (($key == '') && ($this->stream->peekByte() == 0x09)) { |
|
498 | + // Consume byte |
|
499 | + $this->stream->readByte(); |
|
500 | + break; |
|
501 | + } |
|
502 | 502 | |
503 | - $data[$key] = $this->readData(); |
|
504 | - } |
|
503 | + $data[$key] = $this->readData(); |
|
504 | + } |
|
505 | 505 | |
506 | - return $data; |
|
507 | - } |
|
506 | + return $data; |
|
507 | + } |
|
508 | 508 | |
509 | 509 | |
510 | - public function readMixedArray() { |
|
510 | + public function readMixedArray() { |
|
511 | 511 | |
512 | - // Get highest numerical index - ignored |
|
513 | - $highestIndex = $this->stream->readLong(); |
|
512 | + // Get highest numerical index - ignored |
|
513 | + $highestIndex = $this->stream->readLong(); |
|
514 | 514 | |
515 | - $data = array(); |
|
515 | + $data = array(); |
|
516 | 516 | |
517 | - while ($key = $this->stream->readUTF()) { |
|
518 | - // Mixed array record ends with empty string (0x00 0x00) and 0x09 |
|
519 | - if (($key == '') && ($this->stream->peekByte() == 0x09)) { |
|
520 | - // Consume byte |
|
521 | - $this->stream->readByte(); |
|
522 | - break; |
|
523 | - } |
|
517 | + while ($key = $this->stream->readUTF()) { |
|
518 | + // Mixed array record ends with empty string (0x00 0x00) and 0x09 |
|
519 | + if (($key == '') && ($this->stream->peekByte() == 0x09)) { |
|
520 | + // Consume byte |
|
521 | + $this->stream->readByte(); |
|
522 | + break; |
|
523 | + } |
|
524 | 524 | |
525 | - if (is_numeric($key)) { |
|
526 | - $key = (float) $key; |
|
527 | - } |
|
525 | + if (is_numeric($key)) { |
|
526 | + $key = (float) $key; |
|
527 | + } |
|
528 | 528 | |
529 | - $data[$key] = $this->readData(); |
|
530 | - } |
|
529 | + $data[$key] = $this->readData(); |
|
530 | + } |
|
531 | 531 | |
532 | - return $data; |
|
533 | - } |
|
532 | + return $data; |
|
533 | + } |
|
534 | 534 | |
535 | 535 | |
536 | - public function readArray() { |
|
536 | + public function readArray() { |
|
537 | 537 | |
538 | - $length = $this->stream->readLong(); |
|
538 | + $length = $this->stream->readLong(); |
|
539 | 539 | |
540 | - $data = array(); |
|
540 | + $data = array(); |
|
541 | 541 | |
542 | - for ($i = 0; $i < count($length); $i++) { |
|
543 | - $data[] = $this->readData(); |
|
544 | - } |
|
542 | + for ($i = 0; $i < count($length); $i++) { |
|
543 | + $data[] = $this->readData(); |
|
544 | + } |
|
545 | 545 | |
546 | - return $data; |
|
547 | - } |
|
546 | + return $data; |
|
547 | + } |
|
548 | 548 | |
549 | 549 | |
550 | - public function readDate() { |
|
550 | + public function readDate() { |
|
551 | 551 | |
552 | - $timestamp = $this->stream->readDouble(); |
|
553 | - $timezone = $this->stream->readInt(); |
|
554 | - return $timestamp; |
|
555 | - } |
|
552 | + $timestamp = $this->stream->readDouble(); |
|
553 | + $timezone = $this->stream->readInt(); |
|
554 | + return $timestamp; |
|
555 | + } |
|
556 | 556 | |
557 | 557 | |
558 | - public function readLongString() { |
|
558 | + public function readLongString() { |
|
559 | 559 | |
560 | - return $this->stream->readLongUTF(); |
|
561 | - } |
|
560 | + return $this->stream->readLongUTF(); |
|
561 | + } |
|
562 | 562 | |
563 | 563 | |
564 | - public function readXML() { |
|
564 | + public function readXML() { |
|
565 | 565 | |
566 | - return $this->stream->readLongUTF(); |
|
567 | - } |
|
566 | + return $this->stream->readLongUTF(); |
|
567 | + } |
|
568 | 568 | |
569 | 569 | |
570 | - public function readTypedObject() { |
|
570 | + public function readTypedObject() { |
|
571 | 571 | |
572 | - $className = $this->stream->readUTF(); |
|
573 | - return $this->readObject(); |
|
574 | - } |
|
572 | + $className = $this->stream->readUTF(); |
|
573 | + return $this->readObject(); |
|
574 | + } |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | ?> |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | */ |
48 | 48 | class getid3_flv extends getid3_handler { |
49 | 49 | |
50 | - const TAG_AUDIO = 8; |
|
51 | - const TAG_VIDEO = 9; |
|
50 | + const TAG_AUDIO = 8; |
|
51 | + const TAG_VIDEO = 9; |
|
52 | 52 | const TAG_META = 18; |
53 | 53 | |
54 | 54 | const VIDEO_H263 = 2; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | $info = &$this->getid3->info; |
62 | 62 | |
63 | - $info['flv'] = array (); |
|
63 | + $info['flv'] = array(); |
|
64 | 64 | $info_flv = &$info['flv']; |
65 | 65 | |
66 | 66 | fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $flv_header = fread($this->getid3->fp, 5); |
70 | 70 | |
71 | 71 | $info['fileformat'] = 'flv'; |
72 | - $info_flv['header']['signature'] = substr($flv_header, 0, 3); |
|
72 | + $info_flv['header']['signature'] = substr($flv_header, 0, 3); |
|
73 | 73 | $info_flv['header']['version'] = getid3_lib::BigEndian2Int(substr($flv_header, 3, 1)); |
74 | 74 | $type_flags = getid3_lib::BigEndian2Int(substr($flv_header, 4, 1)); |
75 | 75 | |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | |
88 | 88 | $this_tag_header = fread($this->getid3->fp, 16); |
89 | 89 | |
90 | - $previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 0, 4)); |
|
91 | - $tag_type = getid3_lib::BigEndian2Int(substr($this_tag_header, 4, 1)); |
|
92 | - $data_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 5, 3)); |
|
93 | - $timestamp = getid3_lib::BigEndian2Int(substr($this_tag_header, 8, 3)); |
|
90 | + $previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 0, 4)); |
|
91 | + $tag_type = getid3_lib::BigEndian2Int(substr($this_tag_header, 4, 1)); |
|
92 | + $data_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 5, 3)); |
|
93 | + $timestamp = getid3_lib::BigEndian2Int(substr($this_tag_header, 8, 3)); |
|
94 | 94 | $last_header_byte = getid3_lib::BigEndian2Int(substr($this_tag_header, 15, 1)); |
95 | 95 | $next_offset = ftell($this->getid3->fp) - 1 + $data_length; |
96 | 96 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | case getid3_flv::TAG_AUDIO: |
100 | 100 | if (!isset($info_flv['audio']['audioFormat'])) { |
101 | - $info_flv['audio']['audioFormat'] = $last_header_byte & 0x07; |
|
101 | + $info_flv['audio']['audioFormat'] = $last_header_byte & 0x07; |
|
102 | 102 | $info_flv['audio']['audioRate'] = ($last_header_byte & 0x30) / 0x10; |
103 | 103 | $info_flv['audio']['audioSampleSize'] = ($last_header_byte & 0x40) / 0x40; |
104 | 104 | $info_flv['audio']['audioType'] = ($last_header_byte & 0x80) / 0x80; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | |
402 | 402 | $type = $this->stream->readByte(); |
403 | 403 | |
404 | - switch($type) { |
|
404 | + switch ($type) { |
|
405 | 405 | // Double |
406 | 406 | case 0: |
407 | 407 | $value = $this->readDouble(); |