Forums

Unfortunately no one can be told what FluxBB is - you have to see it for yourself.

You are not logged in.

#1 2013-02-08 23:00:29

raygene
Member
From: QC, Canada
Registered: 2012-11-02
Posts: 57
Website

How do I change the "Real name" field to a "About me" text area?

Hi,

Since the Real name field is already in core and in the database, how do I change the form to a plain text (no BBcode, hotlinks, etc.) input area, approximately the same size as the signature box but with a 500 character (more or less) limit which would show correctly in Profile -> Personal when saved?

Thanks!

Last edited by raygene (2013-02-08 23:23:26)


Never, under any circumstances, take a laxative and a sleeping pill on the same night...

Offline

#2 2013-02-10 23:29:48

raygene
Member
From: QC, Canada
Registered: 2012-11-02
Posts: 57
Website

Re: How do I change the "Real name" field to a "About me" text area?

OK, 35+ views and not a single reply? I'll assume that this can't be done...


Never, under any circumstances, take a laxative and a sleeping pill on the same night...

Offline

#3 2013-02-10 23:54:12

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 5,723
Website

Re: How do I change the "Real name" field to a "About me" text area?

We all have stuff to do. I actually still had this topic open in a browser tab, please be a little patient. smile

1. For a start, change the length of the realname field in the users table in the database.
2. Find this line in profile.php:

<label><?php echo $lang_profile['Realname'] ?><br /><input type="text" name="form[realname]" value="<?php echo pun_htmlspecialchars($user['realname']) ?>" size="40" maxlength="40" /><br /></label>

3. Replace it with this:

<label>About me<br /><textarea name="form[realname]"><?php echo pun_htmlspecialchars($user['realname']) ?></textarea><br /></label>

fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

#4 2013-02-11 00:04:56

raygene
Member
From: QC, Canada
Registered: 2012-11-02
Posts: 57
Website

Re: How do I change the "Real name" field to a "About me" text area?

Thanks, Franz, done...


Never, under any circumstances, take a laxative and a sleeping pill on the same night...

Offline

#5 2013-02-11 01:22:52

raygene
Member
From: QC, Canada
Registered: 2012-11-02
Posts: 57
Website

Re: How do I change the "Real name" field to a "About me" text area?

Cool, I modified the string to have a fixed width text box:

<label>About me<br /><textarea name="form[realname]" rows="6" cols="80"><?php echo pun_htmlspecialchars($user['realname']) ?></textarea><br /></label>

Only 2 problems remain:

1- If the text input is in several paragraphs (line breaks), the output comes out as one long paragraph in the profile view. Can I use nl2br() or pun_linebreaks to correct this and if so, where would I insert it?

2- Also, to avoid XSS attacks, would it be a good idea to insert unhtml and if so, where?

Thanks again!

p.s. I've changed VARCHAR to TEXT, was that the right thing to do?

Last edited by raygene (2013-02-11 23:54:53)


Never, under any circumstances, take a laxative and a sleeping pill on the same night...

Offline

#6 2013-02-11 09:44:40

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 158
Website

Re: How do I change the "Real name" field to a "About me" text area?

raygene wrote:

p.s. I've changed VARCHAR to TEXT, was that the right thing to do?

Not really, at least if you use MySQL. While CHAR and VARCHAR fields are read from the table, TEXT (and BLOB) fields are saved outside the table, so having these fields in a frequently-executed SELECT query (like the one fetching the current user) may be a significant performance hit. It would be better to fetch TEXT/BLOB fields only when required.

But this matters if your site has a fair number of visits per second.


gamezoo.org - serious gaming services for serious gamers.

Offline

#7 2013-02-11 18:47:13

raygene
Member
From: QC, Canada
Registered: 2012-11-02
Posts: 57
Website

Re: How do I change the "Real name" field to a "About me" text area?

frequently-executed SELECT query (like the one fetching the current user) may be a significant performance hit. It would be better to fetch TEXT/BLOB fields only when required

Thanks for the info, I'll revert it back to VARCHAR.

Only two questions remain (1 & 2) then I'll almost be ready to go online...

Last edited by raygene (2013-02-11 19:52:42)


Never, under any circumstances, take a laxative and a sleeping pill on the same night...

Offline

#8 2013-02-12 09:39:51

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 158
Website

Re: How do I change the "Real name" field to a "About me" text area?

I'd be using the same checks that are done in posts.php. That is, treating the "about me" field like a text with BBCodes.


gamezoo.org - serious gaming services for serious gamers.

Offline

#9 2013-02-12 20:35:53

raygene
Member
From: QC, Canada
Registered: 2012-11-02
Posts: 57
Website

Re: How do I change the "Real name" field to a "About me" text area?

seven wrote:

I'd be using the same checks that are done in posts.php. That is, treating the "about me" field like a text with BBCodes.

Although I have no use for BBcodes for that field, how would I go about about it? I have no problems applying mods but my PHP knowledge is quite limited and the only thing that bothers me is not having line breaks.

Thanks.

Last edited by raygene (2013-02-12 20:57:08)


Never, under any circumstances, take a laxative and a sleeping pill on the same night...

Offline

#10 2013-02-13 20:57:27

raygene
Member
From: QC, Canada
Registered: 2012-11-02
Posts: 57
Website

Re: How do I change the "Real name" field to a "About me" text area?

I commentated out the field for now until we find a solution for line breaks.

Any help would be appreciated...

Thanks


Never, under any circumstances, take a laxative and a sleeping pill on the same night...

Offline

#11 2013-02-13 21:50:47

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 158
Website

Re: How do I change the "Real name" field to a "About me" text area?

Put  nl2br after fetching the "about me" field from the database. But if that field is rendered into a textarea you have to NOT use nl2br. Strip away HTML entities before rendering, don't strip them away if the target is a textarea. Don't expect us gto do your work though smile

Cheers


gamezoo.org - serious gaming services for serious gamers.

Offline

#12 2013-02-13 23:03:09

raygene
Member
From: QC, Canada
Registered: 2012-11-02
Posts: 57
Website

Re: How do I change the "Real name" field to a "About me" text area?

As Franz suggested, it is a textarea:

<label>About me<br /><textarea name="form[realname]"><?php echo pun_htmlspecialchars($user['realname']) ?></textarea><br /></label>

Don't expect us gto do your work though

LOL, as I mentioned above, I can apply mods but I'm not PHP savvy and without concise instructions, I'm at a loss...

Thanks anyway...

Last edited by raygene (2013-02-13 23:03:58)


Never, under any circumstances, take a laxative and a sleeping pill on the same night...

Offline

#13 2013-02-13 23:22:13

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 158
Website

Re: How do I change the "Real name" field to a "About me" text area?

The owner of the profile will see it as a textarea because it will be editable, but other forum users will not see a textarea, because it will not be editable for them. So you need to search the code where 'realname' is used, find where it is displayed to others and apply nl2br there.


gamezoo.org - serious gaming services for serious gamers.

Offline

#14 2013-02-14 02:38:46

raygene
Member
From: QC, Canada
Registered: 2012-11-02
Posts: 57
Website

Re: How do I change the "Real name" field to a "About me" text area?

Thanks for trying to help out but all the instances of "realname" in profile.php are the following:

case 'personal':
		{
			$form = array(
				'realname'		=> isset($_POST['form']['realname']) ? pun_trim($_POST['form']['realname']) : '',
				'url'			=> isset($_POST['form']['url']) ? pun_trim($_POST['form']['url']) : '',
				'location'		=> isset($_POST['form']['location']) ? pun_trim($_POST['form']['location']) : '',
			);
if ($user['realname'] != '')
	{
		$user_personal[] = '<dt>'.$lang_profile['Realname'].'</dt>';
		$user_personal[] = '<dd>'.pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['realname']) : $user['realname']).'</dd>';
	}

And as mentioned in a previous post:

<label>About me<br /><textarea name="form[realname]"><?php echo pun_htmlspecialchars($user['realname']) ?></textarea><br /></label>

I can't seem to find how it is displayed to other forum users. neutral

I'll put this on the back burner for now...

Grazie

Last edited by raygene (2013-02-14 03:20:00)


Never, under any circumstances, take a laxative and a sleeping pill on the same night...

Offline

#15 2013-02-14 09:08:22

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 5,723
Website

Re: How do I change the "Real name" field to a "About me" text area?

You already found it!

	if ($user['realname'] != '')
	{
		$user_personal[] = '<dt>'.$lang_profile['Realname'].'</dt>';
		$user_personal[] = '<dd>'.pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['realname']) : $user['realname']).'</dd>';
	}

That's the code for guests and other users!


fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

#16 2013-02-14 15:53:34

seven
Member
From: Torino, Italy
Registered: 2010-08-19
Posts: 158
Website

Re: How do I change the "Real name" field to a "About me" text area?

And the edited code with nl2br would be:

	if ($user['realname'] != '')
	{
		$user_personal[] = '<dt>'.$lang_profile['Realname'].'</dt>';
		$user_personal[] = nl2br('<dd>'.pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['realname']) : $user['realname']).'</dd>');
	}

One more word: $lang_profile['Realname'] is the string that you can find in:

/lang/Italian/profile.php
/lang/English/profile.php

around line 81. You'll need to replace the string with "About me".

Last edited by seven (2013-02-14 16:03:22)


gamezoo.org - serious gaming services for serious gamers.

Offline

#17 2013-02-14 20:29:01

raygene
Member
From: QC, Canada
Registered: 2012-11-02
Posts: 57
Website

Re: How do I change the "Real name" field to a "About me" text area?

Thanks guys, it works like a charm!

I'm very grateful for your help.

Cheers!

Last edited by raygene (2013-02-14 20:37:49)


Never, under any circumstances, take a laxative and a sleeping pill on the same night...

Offline

Board footer

Powered by FluxBB 1.5.6