Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
***~~~ Version 1.0 ~~~*** Download

***~~~ Version 2.0 ~~~*** Download

In version 2.0, if an image is to large you are redirected back to the post preview page and a red border arround the image that is too large is displayed.

Mod Name / Version: Restrict Images 2.0

Description: The mod checks the images contained within the image tags in a post for width, height, filesize and image count.

The admin can specify the maximum amount of images per post, the maximum image width, height and size.

If one of the criteria is not within the limits, an error message is displayed, example:
[]http://img148.exs.cx/img148/4148/clipboard017ys.gif[/]

Working Under: UBB.Threads 6.4-6.5

Mod Status: Beta

Any pre-requisites: none

Author(s): Anno

Date: 01/04/05

Credits:

Files Altered:
addpost.php
modifypost.php

New Files:
checkimages.php

Datebase Altered: no

Info/Instructions: Instructions within the checkimages.php file.

In order for the getimagesizes() function to work on remote files, the PHP version has to be > 4.0.5 .


Disclaimer: Please backup every file that you intend to modify.
If the modification modifies the database, it's a good idea to backup your database before doing so.

Note: If you modify your UBB.Threads code, you may be giving up your right for "official" support from Infopop.If you need official support, you'll need to restore unmodified files.
Attachments
124272-checkimages1.0.zip (0 Bytes, 45 downloads)

Last edited by Anno; 01/06/2005 4:40 AM.
Sponsored Links
Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
Thx! This one was also on my list.
A suggestion that might be more comfortable for the users:
If an image is to large, redirect to the post preview page and display a red border arround the image that is too large.
This way they don't have to go back and they can see which one is too large.

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
>If an image is to large, redirect to the post preview page and display a red
>border arround the image that is too large.

This is a good suggestion, I will look into this.

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
Version 2.0 in the attachment.
Attachments
124297-RestrictImages2.0.zip (0 Bytes, 68 downloads)

Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
[]Anno said:
Version 2.0 in the attachment. [/]

And what's in version 2.0?

Sponsored Links
Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
>If an image is to large, redirect to the post preview page and display a red
>border arround the image that is too large.

Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
I have a question, Anno. I am having my site redone, and I am going to use this mod so that the new layout, which includes graphics on the right side of the page, doesn't get stretched. The maximum allowable width would be about 740 pixels.

My question is, what if I have a user puts two, let's say 500 pixel-wide, images in a post without using a linebreak in between. Will this mod split them up, putting them on different lines, so that they don't break up the layout?

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550

Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
[]Anno said:
The images are put in the next line automatically by the browser.
The following images are all placed in one line.
[/]

Is that a function of this mod, or the browser? Because the last thing I want is images stetching and breaking my new layout? However it is the case, this mod will be a nice addition for my board when 6.5.1 goes final

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
Browser.

Sponsored Links
Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
Would it be possible to make it so this also checks the sizes of images used in private messages?

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
You would apply the includes accordingly to sendmessage.php and mess_reply.php .
Try it, and if you fail I'll take a closer look.

Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
I'm sure it's not hard to figure out. Thanks!

Joined: Jun 2001
Posts: 356
Junior Member
Junior Member
Offline
Joined: Jun 2001
Posts: 356
Just a side note here.
I'm running threads 6.5b6.

I can install version 1.0 ok, but not 2.0
In addpost.php I dont have that first line;

in addpost.php
search for:
$PrintBody = str_replace("\n","<br />",$PrintBody);

insert underneath:
$part2 = 1;
include("remotefilesize.php");
include("checkimages.php");


Thought i'd raise it FYI.

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
Search for a line that is similar to this, something along

$PrintBody = str_replace("....something....",$PrintBody);

Joined: Mar 2005
Posts: 11
Newbie
Newbie
Offline
Joined: Mar 2005
Posts: 11
I am helping a forum resolve an issue with your mod, maybe you can help. This is the error recieved when the image is to large

Warning: getimagesize(http://test.haastylcalls.com/images/test.jpg) [function.getimagesize]: failed to open stream: HTTP request failed! ÔÜþ¿ì[ÜÜþ¿t»W1 in /home/.sites/28/site1/web/ubbthreads/checkimages.php on line 88


It also take a very long time for the post to appear, if at all when the image is under or at the required size. It seems to just hang. I think they are using 2.0 but not 100% sure.

Thanks

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
What version of PHP is the server running?

Joined: Mar 2005
Posts: 11
Newbie
Newbie
Offline
Joined: Mar 2005
Posts: 11
They are not sure, I gave them a utility php file that will tell them, and or they will contact the host if they are unable to execute the file.

I figured it would have somthing to do with the version due to the code being unable to compile on line 88.
I looked at the code and it stalls on this line of code $imagehw = getimagesize($imageUrl); So I would bet that the php version does not support getimagesize.

Of course I could be wrong

Last edited by Elkaholic; 03/15/2005 2:13 AM.
Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
JPEG 2000 support was added in 4.3.2, so if they have earlier than that, this MAY be the problem. I'm just making a stab in the dark, though.

An easy way to get information on a PHP install is to make a PHP file that consists of:
Code
<br /><?<br />phpinfo();<br />?><br />


Call the file from your browser and it'll give you all kinds of goodies about the server's PHP install.

Joined: Mar 2005
Posts: 11
Newbie
Newbie
Offline
Joined: Mar 2005
Posts: 11
Ya I know, but from what I understand they do not have access to the server in a manner at wich they can upload stuff and not sure they trust me yet,
this is the first thing I have helped them with and don't blame them,
but we will get there. That's exactly what I sent them

BTW Thanks for your time

Last edited by Elkaholic; 03/15/2005 2:31 AM.
Joined: Oct 2003
Posts: 2,305
Old Hand
Old Hand
Joined: Oct 2003
Posts: 2,305
also keep in mind getimagesize() is part of the image module of php and is NOT loaded by default on alot of systems. BUT you said you can run small images and it works so its probably loaded....

Joined: Aug 2000
Posts: 3,590
Moderator
Moderator
Offline
Joined: Aug 2000
Posts: 3,590
keep in mind getimagesize() downloads the image to your server first, which means it could timeout on a large image

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
>keep in mind getimagesize() downloads the image to your server first

It doesn't actually. It only request the first few bytes of the image.

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
> keep in mind getimagesize() is part of the image module of php

Actually "The getimagesize() function does not require the GD image library."
http://www.php.net/getimagesize

Joined: Mar 2005
Posts: 11
Newbie
Newbie
Offline
Joined: Mar 2005
Posts: 11
They are on version 5.0 of php so now what? seems to be hanging on line 88 of checkimages.php any suggestions?

Joined: Mar 2005
Posts: 11
Newbie
Newbie
Offline
Joined: Mar 2005
Posts: 11
What is happening now is it just takes a very long time to have the post happen when an image is involved. It hangs and then never really does anything. No errors now just no image checking and posts

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
If this function is not working, then you can't get the image dimensions via this way thus you can not use this mod, sorry.

Joined: Mar 2005
Posts: 11
Newbie
Newbie
Offline
Joined: Mar 2005
Posts: 11
Nope they are on version 5.0 of PHP and it does not work. They are running UBB 6.5 and I fixed (seemed to fix) the berror, but it does not function properly. It hangs forever and then does not ever bring you back to the red square part or say anything about posting an image that is not within the settings.

Joined: Mar 2005
Posts: 11
Newbie
Newbie
Offline
Joined: Mar 2005
Posts: 11
Here is the URl for the phpinfo file, see for yourself, maybe you can tell whats up. PM PHP Info
Also this is a test link
PM Test getimagesize

Here is a test link on my site for comparison. It works on my site!

Other Test getimagesize

I think the problem is elsewhere, in the config of PHP or in the Server Config, but can not find it. Still looking though.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Posts: 70
Joined: January 2007
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)