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

Last change on this file since 19804 was 19804, checked in by mistic100, 11 years ago

add plugin URL Uploader

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