coppermine-gallery.com/forum

Support => Older/other versions => cpg1.3.x Support => Topic started by: AlphaAddict on October 03, 2005, 06:51:03 PM

Title: Uploading .exes through url
Post by: AlphaAddict on October 03, 2005, 06:51:03 PM
is there any way to get Coppermine Photo Gallery to accpet url .exe uploads?
it works with rar,zip etc

i can upload images etc but not .exes through the url

My gallery is here (http://tinyurl.com/d8mhq)
Title: Re: Uploading .exes through url
Post by: Nibbler on October 03, 2005, 06:52:07 PM
You'd need to manually add the new filetype into the filetypes table in the database.
Title: Re: Uploading .exes through url
Post by: Tranz on October 03, 2005, 08:29:30 PM
It might be easier to zip the .exe since the browser might display a warning message when someone tries to download an .exe.
Title: Re: Uploading .exes through url
Post by: Joachim Müller on October 04, 2005, 07:49:56 AM
also, make sure that only you as admin can upload at all, you wouldn't want others to upload harmful executables to your website.
Title: Re: Uploading .exes through url
Post by: AlphaAddict on October 04, 2005, 01:23:34 PM
Quote from: Nibbler on October 03, 2005, 06:52:07 PM
You'd need to manually add the new filetype into the filetypes table in the database.
how exactly would i do that?
Title: Re: Uploading .exes through url
Post by: Stramm on October 04, 2005, 02:07:55 PM
with a tool like phpmyadmin you have a look at your filetypes table, view it's contents and add a new line
Title: Re: Uploading .exes through url
Post by: AlphaAddict on October 04, 2005, 02:12:54 PM
im not sure..
if i give you the login would you do it?
Title: Re: Uploading .exes through url
Post by: Stramm on October 04, 2005, 02:32:00 PM
no, I don't like it to much having logins for others servers. If something goes wrong now or in a few weeks you may point your finger at me... no ;)

but create a file addsql.php or whatever you like in your cpg main dir and add the following content

<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');
if (!
GALLERY_ADMIN_MODE) die('Access denied');
pageheader("SQL");
if (
db_query("INSERT INTO {$CONFIG['TABLE_FILETYPES']} (extension, mime, content ) VALUES('exe' ,'application/x-msdownload', 'executable')")) {
echo 
'OK';
} else {
echo 
'Hmmmm.... nope';
}
pagefooter();
?>



call that file, and after that delete it. You need to be logged into CPG and you need to be in admin mode

Title: Re: Uploading .exes through url
Post by: AlphaAddict on October 04, 2005, 02:37:39 PM
when you say "call" it what do you mean?
Title: Re: Uploading .exes through url
Post by: Stramm on October 04, 2005, 02:43:19 PM
you type the file's URL in the browser's address bar
Title: Re: Uploading .exes through url
Post by: AlphaAddict on October 04, 2005, 02:43:57 PM
now i get


Notice: Undefined index: executable in /home/alphaadd/public_html/Gallery/include/media.functions.inc.php on line 33

Notice: Undefined index: in /home/alphaadd/public_html/Gallery/include/media.functions.inc.php on line 33

Notice: Undefined index: executable in /home/alphaadd/public_html/Gallery/include/media.functions.inc.php on line 33

Notice: Undefined index: in /home/alphaadd/public_html/Gallery/include/media.functions.inc.php on line 33
Title: Re: Uploading .exes through url
Post by: Nibbler on October 04, 2005, 02:49:49 PM
Do the same as you just did, but use the following code instead:


<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');
if (!
GALLERY_ADMIN_MODE) die('Access denied');
pageheader("SQL");
if (
db_query("UPDATE {$CONFIG['TABLE_FILETYPES']} SET content = 'document' WHERE extension = 'exe'")) {
echo 
'OK';
} else {
echo 
'Hmmmm.... nope';
}
pagefooter();
?>

Title: Re: Uploading .exes through url
Post by: Stramm on October 04, 2005, 02:56:11 PM
If you want to know more about notices just do a search. Has been answered hundreds of times.

As you see it's in media.functions.inc.php. This function checks media files cause coppermine is a program to handle media files and documents. Not executables. So you have three options. Turn notices off (as you already knw cause you did the search as suggested), edit media.functions.inc.php to support executable or delete the just added sql and re add it but with content=document (just an example). You can expect flaws here and there

edit: Ok, has already been answered ;)
Title: Re: Uploading .exes through url
Post by: AlphaAddict on October 04, 2005, 02:58:59 PM
now the errors at the page top are gone but the bottom says
Error Report
The following uploads encountered errors: 
URI/URL Uploads: 
File Name/URL Error Message
1. http://www.heaventools.com/download/pexsetup.exe HTTP/1.1 302 Found
Title: Re: Uploading .exes through url
Post by: Nibbler on October 04, 2005, 03:01:01 PM
That's because the actual URL is http://www.heaventools.com/files/dwnlnd/PE.Explorer_setup.exe apparently coppermine can't handle the redirection.
Title: Re: Uploading .exes through url
Post by: AlphaAddict on October 04, 2005, 03:40:02 PM
ok now i get
Error Report
The following uploads encountered errors: 
URI/URL Uploads: 
File Name/URL Error Message
1. http://www.heaventools.com/files/dwnlnd/PE.Explorer_setup.exe Unknown MIME type
Title: Re: Uploading .exes through url
Post by: Nibbler on October 04, 2005, 03:43:59 PM
OK, the correct MIME type is application/octet-stream, so upload and run the following code:


<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');
if (!
GALLERY_ADMIN_MODE) die('Access denied');
pageheader("SQL");
if (
db_query("UPDATE {$CONFIG['TABLE_FILETYPES']} SET mime = 'application/octet-stream' WHERE extension = 'exe'")) {
echo 
'OK';
} else {
echo 
'Hmmmm.... nope';
}
pagefooter();
?>

Title: Re: Uploading .exes through url
Post by: AlphaAddict on October 04, 2005, 03:49:24 PM
 :D works