Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
c705e1d9
Commit
c705e1d9
authored
Aug 3, 2008
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Fix: mime type
parent
7233f8ef
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
htdocs/document.php
+18
-12
18 additions, 12 deletions
htdocs/document.php
htdocs/lib/files.lib.php
+27
-0
27 additions, 0 deletions
htdocs/lib/files.lib.php
htdocs/lib/functions.lib.php
+1
-1
1 addition, 1 deletion
htdocs/lib/functions.lib.php
with
46 additions
and
13 deletions
htdocs/document.php
+
18
−
12
View file @
c705e1d9
...
@@ -54,6 +54,7 @@ else
...
@@ -54,6 +54,7 @@ else
require
(
"./main.inc.php"
);
require
(
"./main.inc.php"
);
// master.inc.php is included in main.inc.php
// master.inc.php is included in main.inc.php
}
}
require_once
(
DOL_DOCUMENT_ROOT
.
'/lib/files.lib.php'
);
// C'est un wrapper, donc header vierge
// C'est un wrapper, donc header vierge
...
@@ -64,19 +65,24 @@ $action = $_GET["action"];
...
@@ -64,19 +65,24 @@ $action = $_GET["action"];
$original_file
=
urldecode
(
$_GET
[
"file"
]);
$original_file
=
urldecode
(
$_GET
[
"file"
]);
$modulepart
=
urldecode
(
$_GET
[
"modulepart"
]);
$modulepart
=
urldecode
(
$_GET
[
"modulepart"
]);
$urlsource
=
urldecode
(
$_GET
[
"urlsource"
]);
$urlsource
=
urldecode
(
$_GET
[
"urlsource"
]);
// Define type (attachment=1 to force popup 'save as')
$type
=
urldecode
(
$_GET
[
"type"
]);
// Define mime type
$type
=
'application/octet-stream'
;
if
(
!
empty
(
$_GET
[
"type"
]))
$type
=
urldecode
(
$_GET
[
"type"
]);
else
$type
=
dol_mimetype
(
$original_file
);
// Define attachment (attachment=1 to force popup 'save as')
$attachment
=
true
;
$attachment
=
true
;
if
(
eregi
(
'\.sql$'
,
$original_file
))
{
$type
=
'text/plain'
;
$attachment
=
true
;
}
if
(
eregi
(
'\.sql$'
,
$original_file
))
{
$attachment
=
true
;
}
if
(
eregi
(
'\.html$'
,
$original_file
))
{
$type
=
'text/html'
;
$attachment
=
false
;
}
if
(
eregi
(
'\.html$'
,
$original_file
))
{
$attachment
=
false
;
}
if
(
eregi
(
'\.csv$'
,
$original_file
))
{
$type
=
'text/csv'
;
$attachment
=
true
;
}
if
(
eregi
(
'\.csv$'
,
$original_file
))
{
$attachment
=
true
;
}
if
(
eregi
(
'\.pdf$'
,
$original_file
))
{
$type
=
'application/pdf'
;
$attachment
=
true
;
}
if
(
eregi
(
'\.pdf$'
,
$original_file
))
{
$attachment
=
true
;
}
if
(
eregi
(
'\.xls$'
,
$original_file
))
{
$type
=
'application/x-msexcel'
;
$attachment
=
true
;
}
if
(
eregi
(
'\.xls$'
,
$original_file
))
{
$attachment
=
true
;
}
if
(
eregi
(
'\.jpg$'
,
$original_file
))
{
$type
=
'image/jpeg'
;
$attachment
=
true
;
}
if
(
eregi
(
'\.jpg$'
,
$original_file
))
{
$attachment
=
true
;
}
if
(
eregi
(
'\.png$'
,
$original_file
))
{
$type
=
'image/jpeg'
;
$attachment
=
true
;
}
if
(
eregi
(
'\.png$'
,
$original_file
))
{
$attachment
=
true
;
}
if
(
eregi
(
'\.tiff$'
,
$original_file
))
{
$type
=
'image/tiff'
;
$attachment
=
true
;
}
if
(
eregi
(
'\.tiff$'
,
$original_file
))
{
$attachment
=
true
;
}
if
(
eregi
(
'\.vcs$'
,
$original_file
))
{
$type
=
'text/calendar'
;
$attachment
=
true
;
}
if
(
eregi
(
'\.vcs$'
,
$original_file
))
{
$attachment
=
true
;
}
if
(
eregi
(
'\.ics$'
,
$original_file
))
{
$type
=
'text/calendar'
;
$attachment
=
true
;
}
if
(
eregi
(
'\.ics$'
,
$original_file
))
{
$attachment
=
true
;
}
// Suppression de la chaine de caractere ../ dans $original_file
// Suppression de la chaine de caractere ../ dans $original_file
$original_file
=
str_replace
(
"../"
,
"/"
,
"
$original_file
"
);
$original_file
=
str_replace
(
"../"
,
"/"
,
"
$original_file
"
);
...
...
This diff is collapsed.
Click to expand it.
htdocs/lib/files.lib.php
+
27
−
0
View file @
c705e1d9
...
@@ -153,4 +153,31 @@ function dol_compare_file($a, $b)
...
@@ -153,4 +153,31 @@ function dol_compare_file($a, $b)
}
}
}
}
/**
* \brief Return mime type of a file
* \param file Filename
* \return string Return mime type
*/
function
dol_mimetype
(
$file
)
{
$mime
=
'application/octet-stream'
;
if
(
eregi
(
'\.txt'
,
$file
))
$mime
=
'text/plain'
;
if
(
eregi
(
'\.sql$'
,
$file
))
$mime
=
'text/plain'
;
if
(
eregi
(
'\.(html|htm)$'
,
$file
))
$mime
=
'text/html'
;
if
(
eregi
(
'\.csv$'
,
$file
))
$mime
=
'text/csv'
;
if
(
eregi
(
'\.pdf$'
,
$file
))
$mime
=
'application/pdf'
;
if
(
eregi
(
'\.xls$'
,
$file
))
$mime
=
'application/x-msexcel'
;
if
(
eregi
(
'\.jpg$'
,
$file
))
$mime
=
'image/jpeg'
;
if
(
eregi
(
'\.jpeg$'
,
$file
))
$mime
=
'image/jpeg'
;
if
(
eregi
(
'\.png$'
,
$file
))
$mime
=
'image/png'
;
if
(
eregi
(
'\.gif$'
,
$file
))
$mime
=
'image/gif'
;
if
(
eregi
(
'\.bmp$'
,
$file
))
$mime
=
'image/bmp'
;
if
(
eregi
(
'\.tiff$'
,
$file
))
$mime
=
'image/tiff'
;
if
(
eregi
(
'\.vcs$'
,
$file
))
$mime
=
'text/calendar'
;
if
(
eregi
(
'\.ics$'
,
$file
))
$mime
=
'text/calendar'
;
if
(
eregi
(
'\.(mp3|ogg|au)$'
,
$file
))
$mime
=
'audio'
;
if
(
eregi
(
'\.(avi|mvw|divx|xvid)$'
,
$file
))
$mime
=
'video'
;
if
(
eregi
(
'\.(zip|rar|gz|tgz|z|cab|bz2)$'
,
$file
))
$mime
=
'archive'
;
return
$mime
;
}
?>
?>
This diff is collapsed.
Click to expand it.
htdocs/lib/functions.lib.php
+
1
−
1
View file @
c705e1d9
...
@@ -1220,7 +1220,7 @@ function img_mime($file,$alt='')
...
@@ -1220,7 +1220,7 @@ function img_mime($file,$alt='')
if
(
eregi
(
'\.(png|bmp|jpg|jpeg|gif)'
,
$file
))
$mime
=
'image'
;
if
(
eregi
(
'\.(png|bmp|jpg|jpeg|gif)'
,
$file
))
$mime
=
'image'
;
if
(
eregi
(
'\.(mp3|ogg|au)'
,
$file
))
$mime
=
'audio'
;
if
(
eregi
(
'\.(mp3|ogg|au)'
,
$file
))
$mime
=
'audio'
;
if
(
eregi
(
'\.(avi|mvw|divx|xvid)'
,
$file
))
$mime
=
'video'
;
if
(
eregi
(
'\.(avi|mvw|divx|xvid)'
,
$file
))
$mime
=
'video'
;
if
(
eregi
(
'\.(zip|rar|gz|tgz|z|cab)'
,
$file
))
$mime
=
'archive'
;
if
(
eregi
(
'\.(zip|rar|gz|tgz|z|cab
|bz2
)'
,
$file
))
$mime
=
'archive'
;
if
(
empty
(
$alt
))
$alt
=
'Mime type: '
.
$mime
;
if
(
empty
(
$alt
))
$alt
=
'Mime type: '
.
$mime
;
$mime
.
=
'.png'
;
$mime
.
=
'.png'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment