How I can disable uploading for other formats such as ...

josephp

Joined: 2002-10-03
Posts: 172
Posted: Mon, 2002-10-21 02:43

How I can disable:

.mov
.avi
.ram
.bmp
.psd

I only want allow:

.jpg
.jepg
.gif

How?

 
psg11

Joined: 2002-09-07
Posts: 54
Posted: Mon, 2002-10-21 23:12

Hi,

open util.php

find (approx line 208 )

function acceptableFormatList() {
return array("jpg", "jpe", "gif", "png", "avi", "mpg", "mpeg","wmv", "mov");

take off what you don't need

then find just after

function isImage($tag) {
global $gallery;

return (!strcmp($tag, "jpg") ||
!strcmp($tag, "jpeg") ||
!strcmp($tag, "jpe") ||
!strcmp($tag, "gif") ||
!strcmp($tag, "png"));
}

function isMovie($tag) {
return (!strcmp($tag, "avi") ||
!strcmp($tag, "mpg") ||
!strcmp($tag, "mpeg") ||
!strcmp($tag, "mov") ||
!strcmp($tag, "wmv"));

make the change you need

ex: for jpeg, gif only it should look like this :

function isImage($tag) {
global $gallery;

return (!strcmp($tag, "jpg") ||
!strcmp($tag, "jpeg") ||
!strcmp($tag, "gif"));
}

there is some more code that you could delete to clean up the code,
but this should do the trick.

phil

 
josephp

Joined: 2002-10-03
Posts: 172
Posted: Mon, 2002-10-21 23:51

The code you provided it gives me error, it wont work at all

I only want to disable all movies and .png

I dont want users upload videos anmd go crazy and crash my machine ...

Thanks!

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Tue, 2002-10-22 01:29

You shouldn't be getting any errors... this is straightforward.
<!-- BBCode Start --><A HREF="http://gallery.menalto.com/user.php?op=userinfo&amp;uname=psg11" TARGET="_blank">psg11</A><!-- BBCode End --> was guiding you... he didn't intend you to blindly copy and paste the code there.

Change the following exactly in util.php:

Lines 208-210: function acceptableFormatList() { ... }
becomes
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>function acceptableFormatList() {
return array("jpg", "gif");
}</TD></TR></TABLE><!-- BBCode End -->

Lines 212-219: function isImage() { ... }
becomes
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>function isImage() {
global $gallery;

return(!strcmp($tag, "jpg") ||
!strcmp($tag, "jpeg") ||
!strcmp($tag, "gif"));
}</TD></TR></TABLE><!-- BBCode End -->

Lines 221-226: function isMovie() { ... }
becomes
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>function isMovie() {
return false;
}</TD></TR></TABLE><!-- BBCode End -->

As a side note, why restrict pngs? They're a now widely-accepted and used free image format, useful as a replacement for gifs. :roll:

Good luck!
-Beckett (beck@beckettmw.com)

 
josephp

Joined: 2002-10-03
Posts: 172
Posted: Tue, 2002-10-22 05:34

See?

he didnt explain it clear! That is why I am lost :roll:

 
josephp

Joined: 2002-10-03
Posts: 172
Posted: Tue, 2002-10-22 05:42

And YET, your updated code doesnt work either

This is getting useless ....

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Tue, 2002-10-22 06:56

Hi again.
Well... no one can help you if we don't know what's wrong. If you want, privately e-mail me a copy of your util.php file and I'll have a look. As I mentioned, this ought to be a simple fix. Also, telling us what happens when it doesn't work would be helpful in figuring out the problem.

-Beckett (beck@beckettmw.com)

 
josephp

Joined: 2002-10-03
Posts: 172
Posted: Tue, 2002-10-22 07:42

If you have ICQ or AIM, please contact me

or PM me then we can go from there...

The reason with my new gallery hosting project, I dont want my gallery go crazy with all theses movies uploading, it will eat my bandwidth.

When I changed the code, I keep getting line 109 and 219 error...

Thanks, I ll be waiting ...

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Tue, 2002-10-22 07:55

Okay, I sent you a PM. We'll continue this over e-mail, AIM.

 
colinstephenson

Joined: 2002-10-22
Posts: 2
Posted: Tue, 2002-10-22 15:06

Probably worthwhile extracting this logic out to a config file so that valid extensions can be specifed. This might make it easier for those who do not come from a programming background to change what they want and don't want.

Though i would guess this will feature in a module in G2 (i have not looked at this, but would imagine this would be the case).

cheers,

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Tue, 2002-10-22 20:19

Be sure to suggest it in the suggestions forum! I agree this is a great idea! :cool:

 
psg11

Joined: 2002-09-07
Posts: 54
Posted: Thu, 2002-10-24 05:51

well......you're welcome !!

 
josephp

Joined: 2002-10-03
Posts: 172
Posted: Thu, 2002-10-24 06:09

Overall, it took me 2 days to fix this

Now it is working on my gallery

I am about 80% completion, not finished yet :sad: