View Full Version : Quick Sig Image Size Limiter
phlogiston
17 Jan 2004, 19:39
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
17 Jan 2004, 20:01
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 :)
Nice hack, except there's a problem with the instructions. The 'settings' query is screwed up.
Replace:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
With:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Or else it will not show up in the AdminCP. Other than that, it works like a charm! Great hack!
phlogiston
17 Jan 2004, 20:48
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
17 Jan 2004, 20:55
Nice to see this released, it'll come in handy for my site.
Koutaru
17 Jan 2004, 21:18
Wow, thanks. I really need this one :) I'm really hoping this works!
Installed on RC 2, Works Great, Thanks
Peace
Delacroix
22 Jan 2004, 19:09
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?
Looks good. I'll give it a shot. Thank you. ;)
monstergamer
01 Feb 2004, 09:52
works great, just what i wanted
/me clicks install
monstergamer
05 Feb 2004, 18:52
now members have links insted of the pics
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
29 Feb 2004, 01:40
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
01 Mar 2004, 19:10
This is great. It would definitely be a big help for it to also limit file sizes.
msimplay
11 Mar 2004, 22:01
does not work on rc4 as i have found out :P
Pheonix
12 Mar 2004, 06:10
I like the idea.. and may use the mod.. :) thanx
phlogiston
12 Mar 2004, 06:54
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
15 Mar 2004, 18:40
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
This works perfectly fine in RC4. I've been using it since RC4 was released.
CricketWeb
16 Mar 2004, 08:55
Will this work with vBulletin 3.0 FINAL?
Christine
17 Mar 2004, 23:22
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
21 Mar 2004, 18:07
i can also confirm this works on vb3 gold
msimplay
21 Mar 2004, 18:12
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 (http://www.vbulletin.org/forum/attachment.php?attachmentid=16561)
robin_ge
29 Mar 2004, 21:42
COOL~ works perfectly with gold
robin_ge clicks install
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
08 Apr 2004, 20:09
I would like to see a weight check as well. most of my users have heavey images rather than too big.
Ecron Daemon
09 Apr 2004, 01:04
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? :)
Installed ;)
Any Chance to see a check for imagesize in kb as well?
DS MrSinister
16 Apr 2004, 05:27
kewl hack.. going to intsall it late.. thanks
hukgwai
17 Apr 2004, 04:54
Keep up the good work! I hope this becomes final.
Oblivion Knight
17 Apr 2004, 22:37
It appears to work for some images and not others..
Any idea why this is the case?
Which images are you having a problem with?
Christine
15 May 2004, 17:33
Working great on 3.0.0 without any problems!
Any plans to take this out of Beta?
hogarth
17 May 2004, 00:46
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
18 May 2004, 12:54
hogarth: does that include smilies too? if so, anyway that, that could be removed?
D
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
18 May 2004, 13:10
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
19 May 2004, 01:43
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.
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
19 May 2004, 04:13
figured it out all by myself.
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Ouch! Thank you, anyway. ;)
Someone forgot to make the query for this:
sig_image_too_many = The maximum number of images allowed is $vboptions[sigmaximages].
ImportPassion
22 May 2004, 02:07
i would really really like to see the weight check included in here.
ImportPassion
22 May 2004, 04:10
ok, i did it myself.
the weight check has been imlplemented.
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
30 May 2004, 12:08
Nice hack, but it is very important to limit the number of images allowed in the signiture, otherwise, this hack will be useless !!
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
07 Jun 2004, 04:37
Can all the addons and changes please be compiled into one install file and updated for the the latest version of VB.
n00belit3
07 Jun 2004, 05:37
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
07 Jun 2004, 05:39
How coud i modify this to make it work for images in a post not just in a sig?
Christine
19 Jun 2004, 18:33
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
01 Aug 2004, 07:10
Hmm, I installed this in 3.03 and it didn't do anything. :(
Works perfect in 3.0.1 :)
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
29 Sep 2004, 03:03
Any way to make it so the images auto-resize if they're too big?
Ymeaga1n
27 Oct 2004, 00:02
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 Nov 2004, 22:07
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
12 Nov 2004, 01:05
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
24 Jan 2005, 05:49
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
24 Jan 2005, 06:08
Oops, where's the :slap forehead: smiley? Misread of the image weight mod, didn't notice that where it says,
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
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
24 Jan 2005, 06:50
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.
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?
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
27 Jan 2005, 16:44
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:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Modify that to:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
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:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
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´ÀÉ`
28 Jan 2005, 21:19
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
06 Feb 2005, 20:57
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
this is what happened when i tried to run
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
*EDIT* this is me being stupid... didnt notice I could only run one at a time :-P
illusions
03 Apr 2005, 18:59
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
10 May 2005, 01:24
thanks, I really needed this.
dfaonxa
01 Jun 2005, 22:57
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
02 Jun 2005, 07:31
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.
Anyone tried to use the same code to scan the current signatures and remove any img tags which exceed the limits?
vBulletin® v3.6.12, Copyright ©2000-2012, Jelsoft Enterprises Ltd.