source: extensions/url_uploader/include/functions.inc.php @ 26387

Last change on this file since 26387 was 26387, checked in by mistic100, 7 years ago

update for 2.6

File size: 1.2 KB
Line 
1<?php
2defined('URLUPLOADER_PATH') or die('Hacking attempt!');
3
4/**
5 * add a tab on photo properties page
6 */
7function urluploader_tabsheet_before_select($sheets, $id)
8{
9  if ($id == 'photos_add')
10  {
11    // insert new tab at 2nd position
12    $sheets = 
13      array_slice($sheets, 0, 1) +
14      array('url_uploader' => array(
15        'caption' => '<span class="icon-link"></span>' . l10n('URL Uploader'),
16        'url' => URLUPLOADER_ADMIN,
17        )) +
18      array_slice($sheets, 1);
19  }
20 
21  return $sheets;
22}
23
24/*
25 * try to get the mime-type of a file
26 * as no method is totally reliable we can fallback to a default mime
27 */
28function get_mime($file, $default="application/octet-stream")
29{
30  if (function_exists("mime_content_type"))
31  {
32    $mime = mime_content_type($file);
33    if (!empty($mime)) return $mime;
34  }
35 
36  if (function_exists("finfo_file"))
37  {
38    $finfo = finfo_open(FILEINFO_MIME_TYPE);
39    $mime = finfo_file($finfo, $file);
40    finfo_close($finfo);
41    if (!empty($mime)) return $mime;
42  }
43 
44  if (!stristr(ini_get("disable_functions"), "shell_exec"))
45  {
46    $file = escapeshellarg($file);
47    $mime = shell_exec("file -bi " . $file);
48    if (!empty($mime)) return $mime;
49  }
50 
51  return $default;
52}
Note: See TracBrowser for help on using the repository browser.