4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Fred on June 11, 2003, 11:09:26 PM
-
Hello,
i want to add my domain in download filenames. What is to change?
Thanks for your help!
-
Open download.php
At the very bottom, find this block of code:
if (!empty($file['file_data'])) {
if (get_user_os() == "MAC") {
header("Content-Type: application/x-unknown\n");
header("Content-Disposition: attachment; filename=\"".$file['file_name']."\"\n");
}
elseif (get_browser_info() == "MSIE") {
$disposition = (!eregi("\.zip$", $file['file_name']) && $action != "zip" && $action != "lightbox") ? 'attachment' : 'inline';
header("Content-Disposition: $disposition; filename=\"".$file['file_name']."\"\n");
header("Content-Type: application/x-ms-download\n");
}
elseif (get_browser_info() == "OPERA") {
header("Content-Disposition: attachment; filename=\"".$file['file_name']."\"\n");
header("Content-Type: application/octetstream\n");
}
else {
header("Content-Disposition: attachment; filename=\"".$file['file_name']."\"\n");
header("Content-Type: application/octet-stream\n");
}
header("Content-Length: ".$file['file_size']."\n\n");
echo $file['file_data'];
}
Replace it with:
if (!empty($file['file_data'])) {
if (get_user_os() == "MAC") {
header("Content-Type: application/x-unknown\n");
header("Content-Disposition: attachment; filename=\"".$_SERVER['HTTP_HOST']."_".$file['file_name']."\"\n");
}
elseif (get_browser_info() == "MSIE") {
$disposition = (!eregi("\.zip$", $file['file_name']) && $action != "zip" && $action != "lightbox") ? 'attachment' : 'inline';
header("Content-Disposition: $disposition; filename=\"".$_SERVER['HTTP_HOST']."_".$file['file_name']."\"\n");
header("Content-Type: application/x-ms-download\n");
}
elseif (get_browser_info() == "OPERA") {
header("Content-Disposition: attachment; filename=\"".$_SERVER['HTTP_HOST']."_".$file['file_name']."\"\n");
header("Content-Type: application/octetstream\n");
}
else {
header("Content-Disposition: attachment; filename=\"".$_SERVER['HTTP_HOST']."_".$file['file_name']."\"\n");
header("Content-Type: application/octet-stream\n");
}
header("Content-Length: ".$file['file_size']."\n\n");
echo $file['file_data'];
}
The names of all downloaded files will begin with "domain.com_"
-
Best thanks.
One question, can it be realised like "name_(domain.com).jpg"?
-
That's not so easy to do because $file['file_name'] stores "name.jpg" and you wouldn't want "name.jpg_(domain.com)". Besides, if someone downloads 10 images and then views them in a file manager, like windows explorer, they will all be grouped together since they start with the same prefix. This would make it easy to spot them amongst 100 other files in the same directory.
My advice would be to find all the places in download.php where $file_name is used and make adjustments as needed. This is hard because if the file is a remote file, retrieved via remote URL, you have to manually parse the name. It's also possible that some of those files might not have a file name extension. Good luck.
-
try this:
replace all$_SERVER['HTTP_HOST']."_".$file['file_name']
with:substr($file['file_name'],0,(strlen($file['file_name'])-strlen(strrchr($file['file_name'],"."))))."_(".$_SERVER['HTTP_HOST'].").".substr(strrchr($file['file_name'],"."), 1)
-
Genius, whoho!
Still one Question: Why is before the first *dot* this: "[1]" (without "")?
-
I think IE browser does it...dont know why though
-
V@no's right, it's IE specific. This doesn't happen with other browsers. Chalk up another one for Microsoft not playing by accepted rules of conduct.
-
This is just want I want, Although I'm completeley useless with PHP.
What parts do I change to make the download filename show:
{site_name}_filename.zip
instead of www[1].domain.com_filename.zip ?
Thanks
-
This is just want I want, Although I'm completeley useless with PHP.
What parts do I change to make the download filename show:
{site_name}_filename.zip
instead of www[1].domain.com_filename.zip ?
Thanks
I think the only fix for that is switch to another browser, other then IE... :?
-
Sorry, its not the fact that the [1] is in the filename I don't care about that.
I have a different domain name to my {site_name} and instead of adding domain I would like site name added or maybe some different custom text at a later date.
-
just change:
".$_SERVER['HTTP_HOST']."
with:blah_blah_blah
-
just change:".$_SERVER['HTTP_HOST']."
with:blah_blah_blah
Thanks...
-
You can also try:
".$config['site_name']."