Log in

View Full Version : Prevent Censored Words From Being Striped From Custom Fields?


yotsume
11-27-2010, 02:05 AM
Prevent Censored Words From Being Striped From Custom Not Visible Fields?

Is it possible to remove some code that strips the censored words we enter in the "Censored Words" field in the vbAdminCP. I need the censored words to NOT be stripped from our not visible custom fields.

Example:
I do not want my members to be able to post their last names. So I enter their last names in the Censored Words list and that works great. However... their last names are now lost in their custom fields in their profile that only admins were set to see.

How can I stop the censored words from striping none visible custom fields?

The site is running vb3.7x

yotsume
11-29-2010, 08:57 PM
BUMP! Lynn anyone please help. :)

BirdOPrey5
11-29-2010, 09:13 PM
I know there's a 3.8 mod to disable the word censor per user... I know this isn't what you need but you could probably look at the code and get a good idea of where to start.

There's also this old one to disable per forum: https://vborg.vbsupport.ru/showthread.php?t=98269

yotsume
11-29-2010, 09:23 PM
No sure that code helps at all. I have looked already. I need the censored words to not strip private fields. Nothing to do with forums or usergroups.

kh99
11-29-2010, 10:11 PM
I think you can edit includes/class_dm_user.pm. Around line 1208 or so, add the 'hidden' column to the query (scroll right to see what I changed):

// check extra profile fields
$profilefields = $this->dbobject->query_read_slave("
SELECT profilefieldid, required, size, maxlength, type, data, optional, regex, def, editable, hidden
FROM " . TABLE_PREFIX . "profilefield
$all_fields_sql
ORDER BY displayorder
");


Then just below that around line 1235, I added the first two red lines and made a change in the line below that:
if (in_array($profilefield['profilefieldid'], $field_ids) AND ($all_fields != 'register' OR $profilefield['editable']))
{
if (!$profilefield['hidden'])
$value = fetch_censored_text($value);
$value = trim(substr($value, 0, $profilefield['maxlength']));
$value = (empty($value) AND $value != '0') ? false : $value;
}


Of course this doesn't bring back any data that's already been censored.

yotsume
11-29-2010, 10:28 PM
Ok I am trying this right now... I will report back.... THANKS!

I am sure you meant to edit the file: class_dm_user.php
--------------- Added 29 Nov 2010 at 17:45 ---------------

My code is a little different on vb3.7x

if (in_array($profilefield['profilefieldid'], $field_ids) AND ($all_fields != 'register' OR $profilefield['editable']))
{
if (!$profilefield['hidden'])
$value = fetch_censored_text($value);
$value = trim($value, substr(fetch_censored_text($value), 0, $profilefield['maxlength']));
$value = (empty($value) AND $value != '0') ? false : $value;Above is how I made your second edit. Testing now...

--------------- Added 1291078374 at 1291078374 ---------------

BINGO it looks like it worked perfectly!

Added new censored word, rebuilt post cache, typed the word and its blocked but the private field still has the data!

I run a very large international classroom website. The kids are not allowed to post their last names anywhere on the site. We collect the last names at registration time and then add their last names to the censored words.

MUCH THANKS!

kh99
11-29-2010, 10:53 PM
It could be different because mine came from v3.8.3, but it could also be that I made it confusing by not including before/after code, just the "after". Here's before/after:

if (in_array($profilefield['profilefieldid'], $field_ids) AND ($all_fields != 'register' OR $profilefield['editable']))
{
$value = trim(substr(fetch_censored_text($value), 0, $profilefield['maxlength']));
$value = (empty($value) AND $value != '0') ? false : $value;
}

if (in_array($profilefield['profilefieldid'], $field_ids) AND ($all_fields != 'register' OR $profilefield['editable']))
{
if (!$profilefield['hidden'])
$value = fetch_censored_text($value);
$value = trim(substr($value, 0, $profilefield['maxlength']));
$value = (empty($value) AND $value != '0') ? false : $value;
}


ETA: Posted that before you repsonded. Kind of surprised that works - you may want to make sure it matches what I posted, I think your "trim" has too many params to it and might work by accident.

yotsume
11-29-2010, 11:03 PM
A larger chunk of my code around these lines is:

if (in_array($profilefield['profilefieldid'], $field_ids) AND ($all_fields != 'register' OR $profilefield['editable']))
{
if (!$profilefield['hidden'])
$value = fetch_censored_text($value);
$value = trim($value, substr(fetch_censored_text($value), 0, $profilefield['maxlength']));
$value = (empty($value) AND $value != '0') ? false : $value;
}
else if ($all_fields == 'register' AND $profilefield['data'] !== '')
{
$value = unhtmlspecialchars($profilefield['data']);
}
else
{
continue;
}
$customfields .= "$profilefield[title] : $value\n";
$regex_check = true;

I think were looking at altered files already due to version differences. But... its works... so no sure what might go wrong or now here.

You said:
I think your "trim" has too many params to it and might work by accident.

What do you see wrong in my code and where?

kh99
11-29-2010, 11:09 PM
I think this line:

$value = trim($value, substr(fetch_censored_text($value), 0, $profilefield['maxlength']));


Should be:

$value = trim(substr($value, 0, $profilefield['maxlength']));

I think what you have works because trim() only looks at the first argument, but the value doesn't go through substr() to make sure it's no longer than the max length.

ETA: ...but it's not a big deal, I'm pretty sure it will be OK the way it is.

yotsume
11-29-2010, 11:42 PM
I think this line:

$value = trim($value, substr(fetch_censored_text($value), 0, $profilefield['maxlength']));
Should be:

$value = trim(substr($value, 0, $profilefield['maxlength']));I think what you have works because trim() only looks at the first argument, but the value doesn't go through substr() to make sure it's no longer then the max length.

ETA: ...but it's not a big deal, I'm pretty sure it will be OK the way it is.

Well I am using your edit here and still seems to work fine with no noticeable errors.

The Next Step:

My next step that I have to get solved is how to code a php file so I can pull from my database that one private field which would generate a list of my members last names... any takers on this one???

kh99
11-29-2010, 11:50 PM
Something to go in an existing php file, a custom vBulletin page, or a completely separate php program? (Just asking - if no one's helped you by Wednesday I can probably help).

yotsume
11-30-2010, 12:02 AM
Something to go in an existing php file, a custom vBulletin page, or a completely separate php program? (Just asking - if no one's helped you by Wednesday I can probably help).

I would like it in its own php file that I could upload to my server and then just link to it to generate the list.

Example:
www.my-domain.com/lastnames.php

Once Im done collecting the last names I would delete the php file back off my server for security.

kh99
12-01-2010, 12:07 AM
Would you need any other data with the last name (like user name, user id, whatever)? Or just a list of last names?

What would you think of a plugin using misc.php so that you could use www.my-domain.com/misc.php?do=lastnames? The plugin could check your user id or a user group to limit who can see it, and it could be disabled from the acp if you want.

If you really want a separate page that's not really a lot harder. In fact if you want to get started, you could read this: https://vborg.vbsupport.ru/showthread.php?t=62164

yotsume
12-01-2010, 01:54 AM
I am altering a vbadvanced block to do what I need it to do. It shows the members avatar or none since they are new members, shows any field I pick, shows the title of the field I can label. All with adjustable permissions.

I just have one problem to overcome. The new members with no avatar are not showing up. So I have to find the code in the templates it calls and the php file that seems to be filtering out members with no avatar and then I am all setup!

Here is a screen shot of what I have done.

kh99
12-01-2010, 01:55 AM
Well done - looks good. :)

yotsume
12-01-2010, 02:06 AM
Well will be well done if it works.... but I can't find the way to make it list all new members no matter if they have an avatar or not. UGGGGGGGGGGG! LOL