PDA

View Full Version : [RELEASE] Custom User Titles


08-04-2000, 05:08 AM
- Allow User to Change their titles if they are a Mod
- Allow User to Change their title based on how many posts they have
- Allow User to change their title based on how long they have been registered
- Limit length of text the user can enter
- Censor words that a user can use in their title (separate from the cuss word censor)

[I hope it all works ok as I flew through it and it seems to work on my board :) lemme know what is broke and I will fix it]


I am creating these docs in the spirit of you probably having other hacks installed and so your lines
may not look like my lines.
Do not put the quotations surrounding the information unless I explicitly tell you to do so. Also do
case INSENSITIVE searches to better your chances of actually finding what it is you are looking for.
Lines that begin with a "-" are for you to read, do not copy those lines. Code between tilde's ~~~~~
is for you to copy just dont copy the tildes! ~~~~~

[showthread.php]
- Search for :
"$usertitle=$userinfo[usertitle];"
- Replace with:
"$usertitle = htmlspecialchars($userinfo[usertitle]);"

- This is so that any html that a person may try to enter as their custom title will be shown as text.

[member.php]
(1)

- Find the FIRST instace of "SELECT parentemail"
- add ",usertitle,posts,joindate" right after "parentemail" on that line

(2)
- Search for "$DB_site->query("UPDATE user SET password="
- Go to the end of that line where it says "WHERE userid=$userid");"
- Add ",usertitle='$customtext',customtitle=$customtitle " before the "WHERE", make sure there is a space in front of the "WHERE"
- Don't add any QUOTES but do add the apostrophes!

(3)
- Find any instances of "$usertitle=$userinfo[usertitle];"
- Change to "$usertitle=htmlspecialchars($userinfo[usertitle]);"

(4)
- Paste the following code right underneath "require("global.php")"
~~~~~~~~~
// ###################### Start censortext #######################
function customcensortext($text)
{
global $ctcensorwords,$censorchar;

$censorword=explode(" ",$ctcensorwords);
while (list($key,$val)=each($censorword))
{
if ($val!="")
{
if (substr($val,0,1)=="{")
{
$val=substr($val,1,-1);
$text=eregi_replace("([^A-Za-z])".$val."([^A-Za-z])","\\1".repeatchar($censorchar,strlen($val))."\\2",$text);
}
else
{
$text=eregi_replace($val,repeatchar($censorchar,st rlen($val)),$text);
}
}
}
return $text;
}
~~~~~~~~~

(5)
- find "$getusername=$DB_site->query_first("SELECT username FROM user WHERE userid=$userid");"
- Change to "$getusername=$DB_site->query_first("SELECT username,posts FROM user WHERE userid=$userid");"

(6)
- find "$userid=verifyusername($username,$oldpassword);"
- Add this after it : "$posts = $getusername[posts];"

(7)
- Find the SECOND instance of : $signature=censortext($signature);
- Put this on the next line:
~~~~~~~~~
// Begin Custom Hack
$customtext = censortext($customtext);
$customtext = customcensortext($customtext);

$group=$DB_site->query_first("SELECT usertitle FROM usergroup WHERE usergroupid=$bbusergroupid");
if ($group[usertitle]=="")
{
$gettitle=$DB_site->query_first("SELECT title FROM usertitle WHERE minposts<=$posts+1 ORDER BY minposts DESC LIMIT 1");
$usertitle=$gettitle[title];
}
else
{
$usertitle=$group[usertitle];
}
if ($customtext == "")
{ $customtext = $usertitle; }
if ($customtext == $usertitle)
{
$customtitle = 0;
}
else
{
$customtitle = 1;
}

$customtext = addslashes($customtext);
// End Custom hack

(8)
- find "eval("echo dovars(\"".gettemplate("modifyprofile")."\");");"
- Add this code before it:
~~~~~~~~~
// Begin Custom User Text hack
// Set Variables if admin "forgets" to set options in the CP
if ($ctLength == "" || (isset($ctLength))==0) // Max Length
{ $ctLength = 20; }
if ($ctMod == "" || (isset($ctMod))==0) // Mod use text at all times?
{ $ctMod = "1"; }
if ($ctPost == "" || (isset($ctPost))==0) // Post Requirement to use Custom Text
{ $ctPost = 100; }
if ($ctTime == "" || (isset($ctTime))==0) // Time in days that a user must be a member before using custom text.
{ $ctTime = 30; }

$usertext = htmlspecialchars($userinfo[usertitle]);
$userposts = $userinfo[posts];
$datejoined = $userinfo[joindate];
$ctIsMod = 0;
if (($bbusergroupid == 5)||($bbusergroupid == 6)) // We Have An Admin or SuperMod
{
eval("\$customtext.= \"".gettemplate("customtext")."\";");
$ctIsMod = 1;
}
else if ($bbusergroupid >= 7) // we *might* have a mod
{
$ctTitle = $DB_site->query_first("SELECT title from usergroup where usergroupid = $bbusergroupid");
if ((eregi("moderator",$ctTitle[title]))&&($ctMod=="1"))
{
eval("\$customtext.= \"".gettemplate("customtext")."\";");
$ctIsMod = 1;
}
else // Not a mod
{
$ctIsMod = 0;
}
}
if ($ctIsMod==0) // Regular old Joe Schmoe User
{
if ( ($userposts >= $ctPost) && ( ($datejoined <= (time()-($ctTime*86400))) || ($ctTime==0)) )
{ eval("\$customtext.= \"".gettemplate("customtext")."\";"); }
}
// End Custom User Hack
~~~~~~~~~

[announcement.php]
- find "$usertitle=$userinfo[usertitle];"
- Change to "$usertitle=htmlspecialchars($userinfo[usertitle]);"

[forumdisplay.php]
- find "$announceusertitle=$announceuser[usertitle];"
- replace with "$announceusertitle=htmlspecialchars($announceuser[usertitle]);"

[printthread.php]
- find "$usertitle=$userinfo[usertitle];"
- replace with "$usertitle=htmlspecialchars($userinfo[usertitle]);"

[private.php] - Private Message Hack
- find "$usertitle=$userinfo[usertitle];"
- replace with "$usertitle=htmlspecialchars($userinfo[usertitle]);"

[admin/options.php]
- find "</ul>"
- Add Before that:
"<li><a href=\"#custom\">Custom User Title Options</a></li>"

-find
~~~~~~
</table>
<div align=\"center\"><center><table border=\"0\">
<tr>
~~~~~~
- Add this code Before the "</table>"
~~~~~~~~~~~~
<tr><td colspan=2><hr></td></tr>
<tr>
<td><a name=\"custom\"></a>
<b>ctLength</b></td>
<td> <input type=\"text\" size=\"35\" name=\"newoption[ctLength]\"
value=\"$ctLength\"></td>
</tr>
<tr><td colspan=2>Maximum amount of chars to allow users to enter for their
custom title</td></tr>
<tr><td>
<b>ctPost</b></td>
<td> <input type=\"text\" size=\"35\" name=\"newoption[ctPost]\"
value=\"$ctPost\"></td>
</tr>
<tr><td colspan=2>Number of posts a user must have before they can select
their own title</td></tr>
<tr><td>
<b>ctTime</b></td>
<td> <input type=\"text\" size=\"35\" name=\"newoption[ctTime]\"
value=\"$ctTime\"></td>
</tr>
<tr><td colspan=2>Number of days a user must be registered before they can
select their own title. Use 0 to disable this option.</td></tr>
<tr>
<td></a><b>ctMod</b></td>
<td>Yes<input type=\"radio\" name=\"newoption[ctMod]\" ".iif($ctMod==1,"checked","")." value=\"1\"> No <input type=\"radio\" name=
</tr>
<tr><td colspan=2>Allow Mods to change titles at all times?</td></tr>

<tr>
<td><b>censorwords</b></td>
<td><input type=\"text\" size=\"35\" name=\"newoption[ctcensorwords]\"
value=\"$ctcensorwords\"></td>
</tr>
<tr><td colspan=2>Type all words you want censored in the field below. Do
not use commas to separate words, just use spaces. For ex
<br>
Do not use quotation marks and make sure you use curly braces, not
parentheses, when specifying exact words. This takes the same options as the
censore words in the above sections.<br></td></tr>
<tr><td colspan=2><hr></td></tr>
~~~~~~~~~~~~~


(Templates)

[modifyprofile]
- Put "$customtext" where you want the field to show up. You will need to place it between an existing </tr> and
<tr>

[customtext]
- See post below for the code



[Edited by rangersfan on 08-04-2000 at 01:30 PM]

08-04-2000, 07:58 AM
wow!

that was FAST!

08-04-2000, 09:39 AM
um

what seems to be missing is the template for $customtext

it's called for several times in the code, but I don't see it anywhere.

I added this hack, couldn't figger out what was missing because it wouldn't show up and that seems to be what it is.

also, a coupla things in your instructions that don't seem to be quite right (or at least they are giving *me* trouble):

there are 2 calls to replace the same thing in both showthread.php and announcement.php
you seem to be missing the ">" that the end of the code to add in admin/options.php
Steps 3 and 8 in the member.php both ask for something to be added to "$DB_site->query("UPDATE user SET password". I can only find one instance of this in member.php so I assume both are added to that same instance. Does the order matter?

I think that about covers it. It's gonna be great once I can use it. Thank you for all the hard work :)

08-04-2000, 02:09 PM
Oh yeah I said I did it fast and I was tired when I posted :( I did forget to inculde the template. oops.

Here is the template "customtext"
http://www.hedgehogwheels.com/customtext.txt

I have fixed the anomolies in the instructions.

The ">" was missing in options.php

Step 3 and Step 8 both refer to the same line and I put both changes in Step 3 and Deleted 8.

Second call to change showthread was a duplicate change, ignore it. The anouncement.php and forumdisplay.php changes are not correct. Verify yours and let me know if it works now?

08-04-2000, 03:20 PM
absolutely perfect!

thanx for a great hack!

08-04-2000, 03:53 PM
okay, one small thing that will apply to only certain people.

If you, like me, had the star ranks (or any other image code) set up in the user titles rather than by using the star hack that's buried deep in here somewhere, do NOT replace all the "$usertitle=$userinfo[usertitle];" strings in your files, elsewise any html you have in your user titles will be stripped, too.

The way I'm keeping bad code out is by changing the text box in the customtext template to accept a max of 25 characters.

08-04-2000, 04:10 PM
As i said before, the stars in titles kinda has to leave.

If you dont put in the htmlspecialchars function people can still fit a <img src=> line in under 25 chars.

08-04-2000, 04:25 PM
Originally posted by rangersfan
[usertext]
- See post below for the codeI think that you mean:[customtext]Right?

08-04-2000, 04:30 PM
Yeah :)

08-04-2000, 04:36 PM
You replied even before I have finished cutting and pasting the hack!

08-04-2000, 05:13 PM
You could always add htmlspecialchars() when the user INSERTS the custom title, rather then waiting for it to be displayed. This would allow us admins to use HTML via the CP if we needed to. Or, you could add some sort of flag... (allowhtmlstatus)

Nice job on the hack though, saved me some time! :)

08-04-2000, 05:56 PM
well, the 25 caharacters works great for me:)

<img src=http://www.m.com

that's 25 characters.

08-04-2000, 07:25 PM
Originally posted by Stallion
You could always add htmlspecialchars() when the user INSERTS the custom title, rather then waiting for it to be displayed. This would allow us admins to use HTML via the CP if we needed to. Or, you could add some sort of flag... (allowhtmlstatus)

Nice job on the hack though, saved me some time! :)

Stallion yes you could do this but then that would be going against the way John handles the other fields, like "username" so I chose to try to be consistent. Doing that way means you wouldn't have to edit all the files also.

[Edited by rangersfan on 08-04-2000 at 04:26 PM]

08-05-2000, 04:54 AM
damn it, there are SOO many hacks I want to install, but for some reason I've actually had a life this week, not sure how that happened, but it did. I WILL get these damned things in!

08-05-2000, 11:37 AM
okay, how would I switch this line to an "or" instead of an "and" statement?


if ( ($userposts >= $ctPost) && ( ($datejoined <= (time()-($ctTime*86400))) || ($ctTime==0)) )

08-05-2000, 04:36 PM
So you want it to be ok for a user to change their title if they have say 100 posts or they have been registered 30 days but may have only 1 post?


if ( ($userposts >= $ctPost) || ( ($datejoined <= (time()-($ctTime*86400))) || ($ctTime==0)) )


Just change the '&&' to a '||'

in php you can actually use th word 'and' if you want but I stick to C style..

08-05-2000, 05:47 PM
actually, I was thinking 1000 posts or 365 days

I have a lot of very active posters and a lot who read everything but post infrequently.

They are as valued as members as the ones who post like the board will die tomorrow:)

08-24-2000, 04:58 PM
what part of code did i obviously forget to put in.I mean it doesn't remember the custom user title when i set it,so obviously it doesn't display it eather.It still shows the default one :)

08-24-2000, 05:01 PM
You need to look at all the code that gets added to member.php and verify that it is correct.

08-25-2000, 04:04 AM
that's where i screwed up
thnk you :)