Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
Mod Name / Version: Restrict signatures

Description: This hack allows the administrators to restrict the users' signatures via the admin panel.
Possible restrictions:
- maximum height/width of an image
- number of images
- max. filesize of the images
- max. number of linebreaks

Working Under: UBB.Threads 6.3-6.4

Mod Status: Finished

Any pre-requisites: none

Author(s): Astaran

Date: 02/09/04

Credits: My moderators who requested it

Files Altered: changebasic.php, ubbt.inc.php, config.inc.php

New Files: none

Database Altered: no

Info/Instructions:

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
107486-restrict_signature.txt (0 Bytes, 334 downloads)

Last edited by Astaran; 02/11/2004 5:15 PM.
Sponsored Links
Joined: Mar 2001
Posts: 644
Member
Member
Offline
Joined: Mar 2001
Posts: 644
Awesome! A must have! No more HUUUUGE sig images on my forums. muahaha

Tossing this on my todo list, thanks Astaran!

Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
I forgot the language strings. Just grab the updated instructions.

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
Has this just plain not worked for anyone? I tested it by entered a sig with a bunch of line breaks, but it allows it.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Nice!

Sponsored Links
Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
[]DLWebmaestro said:
Has this just plain not worked for anyone? I tested it by entered a sig with a bunch of line breaks, but it allows it. [/]

You're right. I fixed it and updated the instructions.
Only this row changed:

$sigLines = preg_match_all("/\\n/",$Signature, $outLines);

Joined: Feb 2002
Posts: 950
Hacker
Hacker
Offline
Joined: Feb 2002
Posts: 950
Great mod!

Now all I need to do is write a script to check all the existing ones!

Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
I already did such a script.
It sends out an PM to all users who have a signature that don't fit to the new rules.

Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
Attached you'll find a script that checks all signatures if they match to your rules defined in the config file.
If the signature don't fit to the rules, the signature is deleted. Additionally, the user receives an PM with his old signature so that he can changed and reapply it.

Note: Change the Body of the private message and make a Backup of your database first!
Rename the attachement to .php and upload it to you ubbthreads main dir. Delete it after execution.
Attachments
107649-sigremove_en.txt (0 Bytes, 236 downloads)

Last edited by Astaran; 02/10/2004 7:30 PM.
Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
It works now! But where is that attached script you were talking about?

Sponsored Links
Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
Good question.
There it is.

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609

Joined: Feb 2002
Posts: 950
Hacker
Hacker
Offline
Joined: Feb 2002
Posts: 950
What is $imageSize = remoteFileSize($imageUrl); ?

Also, I'm getting some $imageUrl errors, its creating:

http://http://www.viperalley

Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
My fault, I didn't add that to the instructions.
Just add this function to your ubbt.inc.php (I updated the instructions to reflect this):

function remoteFileSize($remote_file)
{
$file = file_get_contents($remote_file);

return strlen($file);
}

[]
Also, I'm getting some $imageUrl errors, its creating:

http://http://www.viperalley [/]
Mhh, I just use the standard regexp. Maybe the user entered it that way?

Joined: Feb 2002
Posts: 950
Hacker
Hacker
Offline
Joined: Feb 2002
Posts: 950
Keep in mind file_get_contents() only works with PHP 4.3 and later...

Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
Yes, anyone who is using an older version can use this to make it compatible:

if (!function_exists("file_get_contents")) {
function file_get_contents($filename, $use_include_path = 0) {
$data = FALSE;
$file = fopen($filename, "rb", $use_include_path);
if ($file) {
while (!feof($file)) $data .= fread($file, 1024);
fclose($file);
}
return $data;
}
}

Joined: Apr 2003
Posts: 359
Enthusiast
Enthusiast
Joined: Apr 2003
Posts: 359
Interesting and a well needed mod! However, it's not working on my site after the applied changes.

I've gone in and created some huge signature images and they are still showing after the mod, changing the height and width, and making a new registered member with it.

Here's what I changed the fields to and it's still allowing huge sigs:

$config['sigMaxImages'] = '1';
$config['sigImageHeight'] = '150';
$config['sigImageWidth'] = '400';
$config['sigImageSize'] = '55000';
$config['sigMaxLines'] = '10';

Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
Any error messages?
What php version are you using?

Joined: Apr 2003
Posts: 359
Enthusiast
Enthusiast
Joined: Apr 2003
Posts: 359
[]Astaran said:
Any error messages?
What php version are you using? [/]

No, not picking up on visible errors...

I'm running PHP version 4.3.3.

Joined: Jul 2003
Posts: 9
Junior Member
Junior Member
Offline
Joined: Jul 2003
Posts: 9
Hi all,
I'm not too familar with php yet (I'm still stuck in the perl days )but a user reported the following error and it is able to be reproduced by attempting to change the basic profile.
Code
 <br />Fatal error: Call to undefined function: remotefilesize() in /home/xganon/www/forums/ubbt.inc.php on line 739<br /> 

I am using mysql 4.0.16, php 4.1.2, Redhat ES 2.3(or so).
I added the function to the bottom of ubbt.inc.php but stil no go (It was the code for php versions that aren't 4.3)

Any ideas?
Line 739 of that file is:
Code
 739 $imageSize = remoteFileSize($imageUrl);<br />            740                    if ($imageSize > $config['sigImageSize']) {<br />                                   741     $this -> not_right ($ubbt_lang['SIGMAX_SIZE'],$Cat);<br />                               

Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
Have you added the function remoteFileSize as stated in the instructions and the the function that is needed for older php versions?

Joined: Jul 2003
Posts: 9
Junior Member
Junior Member
Offline
Joined: Jul 2003
Posts: 9
[]Astaran said:
Have you added the function remoteFileSize as stated in the instructions and the the function that is needed for older php versions? [/]

I must be blind, I added the function for the older php versions but didn't add the function for remoteFileSize, unfortunatly I had installed this before that was added to the instructions and wasn't made aware of it until this weekend.
Thanks for the help!

Joined: Aug 2002
Posts: 32
User
User
Offline
Joined: Aug 2002
Posts: 32
I would love to implemente this in 6.5 and run the check script for all those who have to big allready....

Whats needed for this to work in 6.5???


Organizer
Joined: Aug 2002
Posts: 32
User
User
Offline
Joined: Aug 2002
Posts: 32
works fine in 6.5, but there are some lines that must be changed manually, as it have been a few small changes in them by Infopop... anyway, kinda logic!


Organizer
Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
I have updated the instruction to work with 6.5 and have attached them to this post. So far, so good over at my site.
Attachments
123623-restrict_signature.txt (0 Bytes, 209 downloads)

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
There is something missing in that code, only the first image found is checked for the size and other parameters, all others are not.
A for loop is missing so to say.

Also, I found a remote file size check that doesn't download the images to check the filesize but checks the headers instead.

http://www.php-editors.com/contest/1/33-read.html

Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
[]Anno said:
There is something missing in that code, only the first image found is checked for the size and other parameters, all others are not.
A for loop is missing so to say.
[/]

In my original code or the updated one?

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
In the one in your first post.

This part:

elseif ($images != 0) {
$imageUrl = "http" . $out['0']['2'] . "." . $out['0']['3'];

Should be included in a loop, the way it is now it only checks the first image found.

Also, you might check the function I use for the remote file size checking without the need to downlod the file to the server.

Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
Thx!
Didn't notice, because I allow only one image in signatures, but I'll update the mod here.

Joined: Nov 2000
Posts: 1,271
Kahuna
Kahuna
Joined: Nov 2000
Posts: 1,271
how much more difficult would it be to additionally force users to upload their signature images to my server? in a similar fashion as the user avatar's current upload setting.

this way, i could (1) better monitor the content of the images and (2) ensure there's no page drag because a sig image is hosted on a slower server

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
very easy, you would simply check if the image is hosted on your domain and give them an error message otherwise.

Joined: Nov 2000
Posts: 1,271
Kahuna
Kahuna
Joined: Nov 2000
Posts: 1,271
in addition, i'd also prefer to have a little upload field, too, for the users to upload their sig images (which would help enforce the idea that they'd have to be hosted on my server)

any chance on whippin all this up for the codily handicapped?

Joined: Jan 2006
Posts: 8
Lurker
Lurker
Offline
Joined: Jan 2006
Posts: 8
Hi, please help....

I am using 6.3.2 and have gone into the admin panel - edit config settings. Where exactly do I add these variables? There isnt anywhere obvious to put them. can they be added to the php file manually?


Code
##################<br />Open your admin panel -> config settings and add these variables:<br />###################<br /><br />$config['sigMaxImages'] =	'1';<br />$config['sigImageHeight'] =	'80';<br />$config['sigImageWidth'] =	'400';<br />$config['sigImageSize'] =	'30720';<br />$config['sigMaxLines'] =	'10';

Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
If I remember right there should be at the bottom a box that says something like "extra config settings" - just add those in there


- Allen wavey
- What Drives You?

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
Gizmo
Gizmo
Portland, OR, USA
Posts: 5,833
Joined: January 2000
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
WebGuy 2
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)