6 |
kaklik |
1 |
<?php
|
|
|
2 |
/*************************
|
|
|
3 |
Coppermine Photo Gallery
|
|
|
4 |
************************
|
|
|
5 |
Copyright (c) 2003-2005 Coppermine Dev Team
|
|
|
6 |
v1.1 originaly written by Gregory DEMAR
|
|
|
7 |
|
|
|
8 |
This program is free software; you can redistribute it and/or modify
|
|
|
9 |
it under the terms of the GNU General Public License as published by
|
|
|
10 |
the Free Software Foundation; either version 2 of the License, or
|
|
|
11 |
(at your option) any later version.
|
|
|
12 |
********************************************
|
|
|
13 |
Coppermine version: 1.3.3
|
|
|
14 |
$Source: /cvsroot/coppermine/stable/include/media.functions.inc.php,v $
|
|
|
15 |
$Revision: 1.4 $
|
|
|
16 |
$Author: gaugau $
|
|
|
17 |
$Date: 2005/04/19 03:17:11 $
|
|
|
18 |
**********************************************/
|
|
|
19 |
|
|
|
20 |
// REQUIRES GLOBAL VAR: CONFIG
|
|
|
21 |
// REQUIRES GLOBAL FUNCTION: db_query
|
|
|
22 |
|
|
|
23 |
global $FILE_TYPES;
|
|
|
24 |
|
|
|
25 |
// Map content types to corresponding user parameters
|
|
|
26 |
$content_types_to_vars = array('image'=>'allowed_img_types','audio'=>'allowed_snd_types','movie'=>'allowed_mov_types','document'=>'allowed_doc_types');
|
|
|
27 |
$CONFIG['allowed_file_extensions'] = '';
|
|
|
28 |
|
|
|
29 |
if (count($FILE_TYPES)==0) {
|
|
|
30 |
$result = db_query('SELECT extension, mime, content FROM '.$CONFIG['TABLE_FILETYPES'].';');
|
|
|
31 |
while ($row = mysql_fetch_array($result)) {
|
|
|
32 |
// Only add types that are in both the database and user defined parameter
|
|
|
33 |
if ($CONFIG[$content_types_to_vars[$row['content']]]=='ALL' || is_int(strpos('/'.$CONFIG[$content_types_to_vars[$row['content']]].'/','/'.$row['extension'].'/')))
|
|
|
34 |
{
|
|
|
35 |
$FILE_TYPES[$row['extension']] = $row;
|
|
|
36 |
$CONFIG['allowed_file_extensions'].= '/'.$row['extension'];
|
|
|
37 |
} }
|
|
|
38 |
mysql_free_result($result);
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
$CONFIG['allowed_file_extensions'] = substr($CONFIG['allowed_file_extensions'],1);
|
|
|
42 |
|
|
|
43 |
function get_type($filename,$filter=null)
|
|
|
44 |
{
|
|
|
45 |
global $FILE_TYPES;
|
|
|
46 |
if (!is_array($filename))
|
|
|
47 |
$filename = explode('.',$filename);
|
|
|
48 |
$EOA = count($filename)-1;
|
|
|
49 |
$filename[$EOA] = strtolower($filename[$EOA]);
|
|
|
50 |
|
|
|
51 |
if (!is_null($filter) && $FILE_TYPES[$filename[$EOA]]['content']==$filter)
|
|
|
52 |
return $FILE_TYPES[$filename[$EOA]];
|
|
|
53 |
elseif (is_null($filter))
|
|
|
54 |
return $FILE_TYPES[$filename[$EOA]];
|
|
|
55 |
else
|
|
|
56 |
return null;
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
function is_image(&$file)
|
|
|
60 |
{
|
|
|
61 |
return get_type($file,'image');
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
function is_movie(&$file)
|
|
|
65 |
{
|
|
|
66 |
return get_type($file,'movie');
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
function is_audio(&$file)
|
|
|
70 |
{
|
|
|
71 |
return get_type($file,'audio');
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
function is_document(&$file)
|
|
|
75 |
{
|
|
|
76 |
return get_type($file,'document');
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
function is_known_filetype($file)
|
|
|
80 |
{
|
|
|
81 |
return is_image($file) || is_movie($file) || is_audio($file) || is_document($file);
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
// Not implemented yet--will be implemented by Chris
|
|
|
85 |
/*
|
|
|
86 |
function cpg_file_html(&$file,$type='thumb',$file_title='')
|
|
|
87 |
{
|
|
|
88 |
global $CONFIG, $pic_title;
|
|
|
89 |
|
|
|
90 |
$mime_content = get_type($file['filename']);
|
|
|
91 |
$extension = file_exists("images/thumb_{$mime_content['extension']}.jpg") ? $mime_content['extension']:$mime_content['content'];
|
|
|
92 |
|
|
|
93 |
if ($mime_content['content']=='image' && $type=='thumb') {
|
|
|
94 |
$file['pwidth'] = 100;
|
|
|
95 |
$file['pheight'] = 100;
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
if ($type=='thumb')
|
|
|
99 |
$file_url = get_pic_url($file, 'thumb',$file_title='');
|
|
|
100 |
elseif ($CONFIG['make_intermediate'] && max($file['pwidth'], $file['pheight']) > $CONFIG['picture_width'])
|
|
|
101 |
$file_url = get_pic_url($file, 'normal');
|
|
|
102 |
else
|
|
|
103 |
$file_url = get_pic_url($file, 'fullsize');
|
|
|
104 |
|
|
|
105 |
$image_size = compute_img_size($file['pwidth'], $file['pheight'], $CONFIG['alb_list_thumb_size']);
|
|
|
106 |
if (($file['pwidth']==0 || $file['pheight']==0) && $type!='thumb')
|
|
|
107 |
$image_size['geom']='';
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
if ($mime_content['content']=='image') {
|
|
|
111 |
if (isset($image_size['reduced'])) {
|
|
|
112 |
$file_html = "<a href=\"javascript:;\" onClick=\"MM_openBrWindow('displayimage.php?pid=$pid&fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=yes,status=yes,resizable=yes,width=" . $file['pwidth']+16 . ",height=" . $file['pheight']+16 . "')\">"
|
|
|
113 |
$file_title = ""
|
|
|
114 |
}
|
|
|
115 |
return "<img src=\"" . $file_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$file['filename']}\" title=\"$pic_title\">";
|
|
|
116 |
}
|
|
|
117 |
elseif ($type=='thumb')
|
|
|
118 |
return "<img src=\"images/thumb_{$extension}.jpg\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$file['filename']}\" title=\"$pic_title\">";
|
|
|
119 |
elseif ($mime_content['content']=='movie')
|
|
|
120 |
return "<object {$image_size['geom']}><param name=\"movie\" value=\"". $file_url . "\"><embed {$image_size['geom']} src=\"". $file_url . "\"></embed></object>\n";
|
|
|
121 |
elseif ($mime_content['content']=='audio')
|
|
|
122 |
return "<object {$image_size['geom']}><param name=\"movie\" value=\"". $file_url . "\"><embed {$image_size['geom']} src=\"". $file_url . "\"></embed></object>\n";
|
|
|
123 |
elseif ($mime_content['content']=='document')
|
|
|
124 |
return "<a href=\"{$file_url}\" target=\"_blank\" class=\"document_link\"><img src=\"images/thumb_$extension.jpg\" border=\"0\" class=\"image\" /></a>\n";
|
|
|
125 |
}*/
|
|
|
126 |
?>
|