PDA

View Full Version : Quick Sig Image Size Limiter


phlogiston
01-16-2004, 10:00 PM
A fairly quick and easy to install hack that attempts to check the pixel size of any images users place in their signatures. If the image is above admin set dimensions an error is given to the user explaining the valid dimensions.

I've not found a simple version of this for v3 - apologies if it's already out there somewhere!

- This is purely a BETA release as the getimagesize() function used seems to fail for certain images on one test install, unknown reason at present. This will not make the hack fail, simply some images on some servers will be allowed even if over the set size. To prevent this uncomment the five lines in the added code to give an invalid image message instead.


The options to set the size limits for signature images will be found in the admincp vBulletin Options --> User Profile Options


*****PLEASE NOTE*****
I am unable to provide any support at all for this hack - sometimes it works, sometimes it doesn't.
My knowledge dosn't reach far enough for me to understand or fix the reasons behind it failing on some installs, sorry.
If it works for you, I'm glad, if it doesn't then just revert everything and try looking at the other sig option hacks, sorry - best I can do :(

MindTrix
01-17-2004, 06:01 PM
Sounds great, im sure some boards will need this due to people abusing Sig's with pics. Nice one and thank you, Oh and congrats on your first release :)

magnus
01-17-2004, 06:08 PM
Nice hack, except there's a problem with the instructions. The 'settings' query is screwed up.

Replace:

INSERT INTO setting VALUES ('sigmaxwidth', '480', '', '141', 'user', '640', '0', '0');
INSERT INTO setting VALUES ('sigmaxheight', '120', '', '142', 'user', '480', '0', '0');


With:

INSERT INTO `setting` VALUES ('sigmaxwidth', 'user', '500', '500', '', 112, 0, 1);
INSERT INTO `setting` VALUES ('sigmaxheight', 'user', '150', '150', '', 111, 0, 1);


Or else it will not show up in the AdminCP. Other than that, it works like a charm! Great hack!

phlogiston
01-17-2004, 06:48 PM
Nice hack, except there's a problem with the instructions. The 'settings' query is screwed up.oops! thanks for pointing that out, I have updated the .txt file now with new queries for the settings which should work everywhere.

& glad it's working fine for you. :)

and MindTrix, thank you too, first release is rather nerve-racking!

FleaBag
01-17-2004, 06:55 PM
Nice to see this released, it'll come in handy for my site.

Koutaru
01-17-2004, 07:18 PM
Wow, thanks. I really need this one :) I'm really hoping this works!

Denz
01-18-2004, 07:22 PM
Installed on RC 2, Works Great, Thanks

Peace

Delacroix
01-22-2004, 05:09 PM
One more suggestion if it is even possible. I have one user (so far) that linked to a HUGE animated [img]. Is there a way to make this limit total file size as well?

Boofo
01-31-2004, 08:48 AM
Looks good. I'll give it a shot. Thank you. ;)

monstergamer
02-01-2004, 07:52 AM
works great, just what i wanted
/me clicks install

monstergamer
02-05-2004, 04:52 PM
now members have links insted of the pics

pucca
02-28-2004, 06:13 PM
Hmm.. it's not working for me at all. : ( I'm using RC4. When I update my signature, it doesn't show a warning. Can anyone help me? Thanks :D

btw - i'm not sure what you mean by "uncomment"? :x

milkmycow
02-28-2004, 11:40 PM
didnt work for me on rc2. when i submit a new sig, it just never refreshes the page. I put my origial profile.php back on server, and page loaded fine. did that 2-3 times.

87accordlxi
03-01-2004, 05:10 PM
This is great. It would definitely be a big help for it to also limit file sizes.

msimplay
03-11-2004, 08:01 PM
does not work on rc4 as i have found out :P

Pheonix
03-12-2004, 04:10 AM
I like the idea.. and may use the mod.. :) thanx

phlogiston
03-12-2004, 04:54 AM
I'm gonna wait till gold version comes out before updating this as it seems to still work fine for me so it's obviously a compatability issue that isn't showing itself on first glance - I'll also add filesize checking at the same time.

msimplay
03-15-2004, 04:40 PM
can u please do a quick one for rc4 because i won't be updating straight away :$
can't be that hard can it ?
its only 2 lines in the database

magnus
03-15-2004, 04:47 PM
This works perfectly fine in RC4. I've been using it since RC4 was released.

CricketWeb
03-16-2004, 06:55 AM
Will this work with vBulletin 3.0 FINAL?

Christine
03-17-2004, 09:22 PM
phlogiston, Thanks for this -- my board is completely out of control with sigs. My mods will love you if this works! I am going to install it tonight.

:)

Edit to add: Installed and works like a charm. As written, it adds a link instead of the image for sizes that are too large. Uncommenting the allowimgsizefailure error message logic gives an error message when trying to submit a new sig with a pic too large. Perfect! :D

Oh, and a note for those who tried this and said it didn't work, before you give up -- make sure that you are going through your UserCP to change your sig and not the ACP or MCP. Sig limit checking by the profile.php file is only done in the UserCP.

:)

msimplay
03-21-2004, 04:07 PM
i can also confirm this works on vb3 gold

msimplay
03-21-2004, 04:12 PM
was just wondering if u could make the signature options more comprehensive
like for example this pic
i did try posting elsewhere but the thread got ignored but since this threads all about that kind of thing its best to ask here i guess

Pic (https://vborg.vbsupport.ru/attachment.php?attachmentid=16561)

robin_ge
03-29-2004, 07:42 PM
COOL~ works perfectly with gold

robin_ge clicks install

Indy
04-04-2004, 11:04 PM
Just download and installed with my vB3 Gold. Works great!

Nice addition would be to limit the number of images in a signature as well! That would be sweet!! Even if not, GREAT JOB and GREAT HACK!

ImportPassion
04-08-2004, 06:09 PM
I would like to see a weight check as well. most of my users have heavey images rather than too big.

Ecron Daemon
04-08-2004, 11:04 PM
Mmmhh... Great hak, but... Is it possible to add a feature to limit the number of images in a signature? For example:Select that User can insert in the signature only one image, or only two, depending by the value choosen by admin in admin cp.

Is it possible to make it? :)

Sven
04-13-2004, 09:45 AM
Installed ;)
Any Chance to see a check for imagesize in kb as well?

DS MrSinister
04-16-2004, 03:27 AM
kewl hack.. going to intsall it late.. thanks

hukgwai
04-17-2004, 02:54 AM
Keep up the good work! I hope this becomes final.

Oblivion Knight
04-17-2004, 08:37 PM
It appears to work for some images and not others..

Any idea why this is the case?

Boofo
05-05-2004, 12:41 PM
Which images are you having a problem with?

Christine
05-15-2004, 03:33 PM
Working great on 3.0.0 without any problems!

Any plans to take this out of Beta?

hogarth
05-16-2004, 10:46 PM
There's a problem with PHP's getimagesize(), I've run into it many times myself. I have no idea why this problem exists but some images, mainly ones I've found were saved from Photoshop, will fail to read corrently using PHP's imaging functions -- anything: getimagesize(), imagesx(), imagepng(), etc. Because of this "limitation," I've had to use X11's convert program to do my scaling, displaying, and image information. This is accomplished by a system() or exec() call and can be expensive but I've found it works 100% of the time no matter what's thrown at it. But, this is limited to a UNIX environment and assumes the vB installation has execute permission to the program convert.

Maybe a look into the ImageMagick PHP extension imagick (http://pecl.php.net/package/imagick) might be worth looking at to see if this problem goes away then. But then this hack ends up with a "requirements" list.

This hack works great on 3.0.1 perfect. But on my board I also have a problem with members putting too many images in their sigs as well. I've made a very small modification to the original source that limits the total number of images and attached it for others.

ImportPassion
05-18-2004, 10:54 AM
hogarth: does that include smilies too? if so, anyway that, that could be removed?

D

Boofo
05-18-2004, 11:00 AM
There's a problem with PHP's getimagesize(), I've run into it many times myself. I have no idea why this problem exists but some images, mainly ones I've found were saved from Photoshop, will fail to read corrently using PHP's imaging functions -- anything: getimagesize(), imagesx(), imagepng(), etc. Because of this "limitation," I've had to use X11's convert program to do my scaling, displaying, and image information. This is accomplished by a system() or exec() call and can be expensive but I've found it works 100% of the time no matter what's thrown at it. But, this is limited to a UNIX environment and assumes the vB installation has execute permission to the program convert.

Maybe a look into the ImageMagick PHP extension imagick (http://pecl.php.net/package/imagick) might be worth looking at to see if this problem goes away then. But then this hack ends up with a "requirements" list.

This hack works great on 3.0.1 perfect. But on my board I also have a problem with members putting too many images in their sigs as well. I've made a very small modification to the original source that limits the total number of images and attached it for others.
Can you please tell us which code was changed from the original hack so we can just upgrade what we already have? ;)

Oblivion Knight
05-18-2004, 11:10 AM
Which images are you having a problem with?
I think this was because one of the images I tested with was under a .htaccess protected directory.. The image wouldn't be displayed to the public anyway and would be prompted to enter the name and password.

I've tested several other possibilities and it keeps coming back to this.

ImportPassion
05-18-2004, 11:43 PM
Can you please tell us which code was changed from the original hack so we can just upgrade what we already have? ;)

it's 30 lines, just paste over it.

Boofo
05-19-2004, 02:11 AM
it's 30 lines, just paste over it.
That part wasn't worrying me. The extra queries we need to run is what I want to know about. ;)

ImportPassion
05-19-2004, 02:13 AM
figured it out all by myself.


INSERT INTO phrase VALUES('', '0', 'setting_sigmaximages_title', 'Total Number of Images In Signature', '5000');
INSERT INTO phrase VALUES('', '0', 'setting_sigmaximagest_desc', 'The total number of images in signatures.', '5000');
INSERT INTO phrase VALUES('', '0', 'sig_image_too_many', 'The total number of images in signatures is limited to $vboptions[sigmaximages].', '1000');
INSERT INTO `setting` (varname, value, optioncode, displayorder, grouptitle, defaultvalue, advanced, volatile) VALUES ('sigmaximages', '3', '', 143, 'user', '3', 0, 0);

Boofo
05-19-2004, 02:22 AM
Ouch! Thank you, anyway. ;)

Boofo
05-19-2004, 02:32 AM
Someone forgot to make the query for this:

sig_image_too_many = The maximum number of images allowed is $vboptions[sigmaximages].

ImportPassion
05-22-2004, 12:07 AM
i would really really like to see the weight check included in here.

ImportPassion
05-22-2004, 02:10 AM
ok, i did it myself.

the weight check has been imlplemented.

Acido
05-30-2004, 06:55 AM
ok, i did it myself.

the weight check has been imlplemented.The only thing that it hack needs to be perfect, is limit LINES in signatures. :)

alsakher
05-30-2004, 10:08 AM
Nice hack, but it is very important to limit the number of images allowed in the signiture, otherwise, this hack will be useless !!

Prince
06-01-2004, 03:15 AM
this has nothing to do with this hack, but here is an alternative sig "limiter", one simple template edit:

postbit:
<div align="left" style="width:99%;height:125px;overflow:auto;"><normalfont>$post[signature]</normalfont></div>

dniMTheory
06-07-2004, 02:37 AM
Can all the addons and changes please be compiled into one install file and updated for the the latest version of VB.

n00belit3
06-07-2004, 03:37 AM
this has nothing to do with this hack, but here is an alternative sig "limiter", one simple template edit:

postbit:
<div align="left" style="width:99%;height:125px;overflow:auto;"><normalfont>$post[signature]</normalfont></div>
ownt?

n00belit3
06-07-2004, 03:39 AM
How coud i modify this to make it work for images in a post not just in a sig?

Christine
06-19-2004, 04:33 PM
I just found a problem with this. If sig limits are on (example 400 characters) and the sig is text only, then the system adheres to the 400 character limit. If there are images in the signature, than it ignores the limit, and allows sigs of any length to be posted, so by adding a single image to the sig, the member can override the character limit function.

Anyone have any ideas on this one?

Code Monkey
08-01-2004, 05:10 AM
Hmm, I installed this in 3.03 and it didn't do anything. :(

tHe Rk
08-24-2004, 12:20 AM
Works perfect in 3.0.1 :)

tHe Rk
08-24-2004, 07:58 PM
Hmm, I installed this in 3.03 and it didn't do anything. :(
Did you run the Queries? Because it's not like you replace any code for this, its simply added code, so I would think it should work with every version, which leads me to believe you didn't do the queries. :ermm:

I just found a problem with this. If sig limits are on (example 400 characters) and the sig is text only, then the system adheres to the 400 character limit. If there are images in the signature, than it ignores the limit, and allows sigs of any length to be posted, so by adding a single image to the sig, the member can override the character limit function.

Anyone have any ideas on this one?
I didn't have that problem. The character limit was still working for me.

gwhooooey
09-29-2004, 01:03 AM
Any way to make it so the images auto-resize if they're too big?

Ymeaga1n
10-26-2004, 10:02 PM
I have a question about this hack, say I upload the file 123.jpg and use it as my sig. Your hack approves it becaues it is under the max size. After the image is displayed, I make a larger image and reupload it with same name overwritting 123.jpg. Correct me if I'm wrong but if only the UserCP can check the size again there is no way to limit someone from overwriting the file.

dfaonxa
11-11-2004, 08:07 PM
Alright, a couple of problems... I uploaded the hack to 3.03, if I try to upload a sig that's too big it gives me the error, but it didn't make any changes to the existing sigs that are too big. Any thoughts on why this is, what I can fix, or what a workaround is so I can get all my users to go change their sigs?

Also, when installing 7thgenCivic.Com's weight limit hack, I was returned the following error when I clicked on Edit Signature:

Parse error: parse error, unexpected T_IF in /home/file/public_html/bb/profile.php on line 1339

Which is the line:

if (!$image_size[2])

Any suggestions? Thanks!

ImportPassion
11-11-2004, 11:05 PM
i thinku got some messed up code somewhere. only thing i can suggest as it does work.

btw: only way to make all users comply is to delete everyones sig and make then start over.

BaconDelight
01-24-2005, 03:49 AM
Hi, quick help with this. I attempted to install this hack (my first hack) on a test board. I ran all the queries, added all the phrases, and added the code into profile.php, making sure to use the corrected and updated code, including the image weight option. The admincp options showed up, however, now signatures do not show up in threads at all. I noticed this while checking to see what affect installing the hack would have on an existing sig image that's too big, so I did not check to see if the hack actually limited the size of new sigs. Once I noticed that sigs were't showing up, the very next thing I did was replace the modified profile.php with the backup I made. But even after doing this, sigs still don't show up. What's going on?

Edit: Hmm, upon further testing, it seems that it might be working correctly afterall. I think it was a matter of one signature having an image that's too large, and anothe ID that didn't have a signature to begin with.

But it seems I'm having the same issue as dfaonxa above. If I install the image weight code, going into "Edit Signature" returns an error.

BaconDelight
01-24-2005, 04:08 AM
Oops, where's the :slap forehead: smiley? Misread of the image weight mod, didn't notice that where it says,

find

if (!$image_size[2])
{
eval('$errors[] = "' . fetch_phrase('attachnotimage', PHRASETYPEID_ERROR) . '";');
$preview = 'true';
}


that the "find" isn't code, but an instruction. It's all clear now. Well, just ignore me, unless you're dfaonxa, in which case, hopefully this will help you solve your issue. :)

BaconDelight
01-24-2005, 04:50 AM
Should I be worried that talking to myself is solving all my problems?

So anyway, I got it installed, everything seemed to be working, except the weight limit function didn't seem to be catching things correctly. I left it set at the 35840 bytes that the query given in the mod has. I then attempted to load a sig pic that is about 218kB....and it let me. That seemed odd. So after a bunch of experimenting, I discovered that the remote_file_size function is returning value that's off by a factor of exactly 10. So it thinks my image (which is 223,554 bytes) is only 22,355 bytes (so the actual size, divided by 10). In another test, an image of size 134,154 was only blocked once the limit was set to 13,415 or below.

Combing through the function, nothing is jumping out to my untrained eye, but something is definitely wrong. For now, I'm just going to use the work around of changing if (remote_file_size($checkimage) > $vboptions['sigmaxweight']) to if (remote_file_size($checkimage)*10 > $vboptions['sigmaxweight']). I've tested this, and it works. But if anyone would like to debug the function and see where it's losing this factor of 10, be my guest.

Jenta
01-25-2005, 07:47 AM
this has nothing to do with this hack, but here is an alternative sig "limiter", one simple template edit:

postbit:
<div align="left" style="width:99%;height:125px;overflow:auto;"><normalfont>$post[signature]</normalfont></div>

I love this simplistic approach and am using it for dimensions
The only problem is it ALWAYS makes the signature area that big. Even if its just a couple of words.

Probably impossible but any way to do some sort of if statement to check if the signature contains an image?

Jenta
01-25-2005, 09:09 PM
I've figured out a solution

disable [img] tags in signatures
create a new bb code called sig

Title: Signature Image
Tag: sig
Replacement: <div style="width:500px;height:140px;overflow:hidden;"><img src="{param}"></div> (change this as you see fit)
Example: http://www.yoursite.net/samplesig.gif
Description:This is similar to the [img] tag but is used for signatures only.

This way only images take up the full space. If someone has a smiley or a short piece of text it wont make the signature area bigger than it needs to be.

BaconDelight
01-27-2005, 02:44 PM
I've modified the hack so that smilies do not count against the limit of number of images in the signature. The way I did it was quick and dirty, I'm sure there's a more elegant solution, but this works and entails just adding one line and modifying one other. I'm still a php novice, so I went with what works. If someone wants to clean it up, be my guest. My solution has 2 steps:

1) In the Quick Sig Image Size Limiter code, find the conditional:

if( count($sigimages[2]) > $vboptions['sigmaximages'] )

Modify that to:

if( (count($sigimages[2])- fetch_character_count($parsedsig, '<img src="http://[your domain]/[your board's root directory]/images/smilies/"'))> $vboptions['sigmaximages'] )


Make sure you replace [your domain] and [your board's root directory] with the proper values for your board.

2) Directly above the line you just modified, add:

require_once('./includes/functions_misc.php');

You're done. Like I said, I'm sure this isn't the cleanest solution. Basically I just noticed a bit of existing code that uses a function call to parse the signature and check it agains the global post image limit. I used that and modified it to find images in the sig that are located in the smilie directory and subtracted it from the total images in the sig.

???`S?LV?R???`
01-28-2005, 07:19 PM
I've figured out a solution

disable [img] tags in signatures
create a new bb code called sig

Title: Signature Image
Tag: sig
Replacement: <div style="width:500px;height:140px;overflow:hidden;"><img src="{param}"></div> (change this as you see fit)
Example: http://www.yoursite.net/samplesig.gif
Description:This is similar to the [img] tag but is used for signatures only.

This way only images take up the full space. If someone has a smiley or a short piece of text it wont make the signature area bigger than it needs to be.

then people can post that sig bb code all over the forum, flooding it with images.

Slybone
02-06-2005, 06:57 PM
vBulletin Message
An error occurred while attempting to execute your query. The following information was returned.
error number: 1064
error desc: You have an error in your SQL syntax near ';
INSERT INTO `setting` (varname, value, optioncode, displayorder, grouptitle,' at line 1


this is what happened when i tried to run

INSERT INTO `setting` (varname, value, optioncode, displayorder, grouptitle, defaultvalue, advanced, volatile) VALUES ('sigmaxheight', '150', '', 141, 'user', '480', 0, 0);
INSERT INTO `setting` (varname, value, optioncode, displayorder, grouptitle, defaultvalue, advanced, volatile) VALUES ('sigmaxwidth', '400', '', 142, 'user', '640', 0, 0);

*EDIT* this is me being stupid... didnt notice I could only run one at a time :-P

illusions
04-03-2005, 04:59 PM
Okay i must be doing something wrong... because i followed the instruction to the T ...and its still not working.. meaning it allows me to add limitation to the size height n width..but does not validate it..when members go beyond the size of 500 X 125 ?? why?.. i must be doing something wrong...its still allowing members to have large images in their signitures... :ermm:

womensden
05-09-2005, 11:24 PM
thanks, I really needed this.

dfaonxa
06-01-2005, 08:57 PM
Alright, I'm trying to re-implement this hack on 3.0.7, and when I try to run the first query

INSERT INTO `setting` (varname, value, optioncode, displayorder, grouptitle, defaultvalue, advanced, volatile) VALUES ('sigmaxheight', '150', '', 141, 'user', '480', 0, 0);

it returns the following error:

An error occurred while attempting to execute your query. The following information was returned.
error number: 1062
error desc: Duplicate entry 'sigmaxheight' for key 1

Help? :nervous: Thanks!

Marco van Herwaarden
06-02-2005, 05:31 AM
IF you have installed it on a previous version of vB, you will probably only have to redo the file edits. You are now trying to insert a value into the database that already exit.

MPDev
06-06-2005, 12:24 PM
Anyone tried to use the same code to scan the current signatures and remove any img tags which exceed the limits?