vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Beta Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=5)
-   -   User Default Font/Color/Size hack (https://vborg.vbsupport.ru/showthread.php?t=49398)

TalkHardRandy 02-25-2003 10:00 PM

User Default Font/Color/Size hack
 
First hack... please be gentle :confused: :

WHAT IT DOES:

It allows the user to specify in their profile what size, color and font that they wish to use in all their posts. This is esentially the same as surrounding stuff with SIZE, COLOR, FONT, but makes it easier.

It also uses the vbcode templates already in the system, so users can select from any of the fonts & colors you have already defined. This avoids users inputing colors that don't exist and fonts that no one else has on their systems.

INSTALLABLES

3 file mods
4 template adds
3 template mods

PROPS

Palmer ofShinra inspired the original version here, so massive props to him. I wanted to take his idea and make it more user friendly (and was tired of trying to explain to people why 'puke green' didn't work as a color).

Also, every other hacker out here (Lesane, Erwin, FireFly, Xenon, C.Birch, futureal, and a hundred others) for busting their butts and putting hacks out and for saying that if you want to do something, learn to do it. Inspiration at its finest.

BUGS

If you run TomBot, TomBot has a problem with the FONT/COLOR/SIZE tags. The fix is two posts below

Okay... let me know

FIXES

1) Fixed Spelling of 'Verdana' - Thanks Vivi!
2) Fixed for Multiple Styles - Thanks Zelda!
3) Added & fixed user ability to use default via ON/OFF - Again, Thanks Zelda!
4) Added ability to remember defaults.

TalkHardRandy 02-26-2003 07:44 PM

What it looks like in the User CP...

TalkHardRandy 02-26-2003 07:50 PM

Okay, if you're like me your running TomBot & you've figured out that he/she doesn't like the color, font, size tags... especially if you're teaching to it.

In both newreply.php & newthread.php, find this section:

PHP Code:

// #####################  BEGIN FONT COLOR SIZE HACK ##################
    
if ($bbuserinfo[default_fcs]="0") {
        
$message "[color=".$bbuserinfo[post_color]."][font=".$bbuserinfo[post_font]."][size=".$bbuserinfo[post_size]."]".$message."[/size][/font][/color]";
    }
// #####################  END FONT COLOR SIZE HACK #################### 


Replace it with:

PHP Code:

// #####################  BEGIN FONT COLOR SIZE HACK ##################
    
if ($foruminfo['forumid']!=="FORUM#" || $bbuserinfo[default_fcs]="0") {
        
$message "[color=".$bbuserinfo[post_color]."][font=".$bbuserinfo[post_font]."][size=".$bbuserinfo[post_size]."]".$message."[/size][/font][/color]";
    }
// #####################  END FONT COLOR SIZE HACK #################### 

Where FORUM# is the forum where your TomBot is running. If you have multiples, and a ||. To figure out what forum you TomBot is running in, check the tomstalkerbot.php for the $ttb_forumid variable.

NOTE: If it doesn't look like this in your files, you need to go back to post #1 and reinstall the hack.

Vivi Ornitier 02-26-2003 09:23 PM

hey great job! been waitin for somethin like this but the queries don't wokr.

I thin it's too many ' and also u spelt Veranda instead of Verdana in the queries

TalkHardRandy 02-26-2003 09:30 PM

Okay... spelling bugs are fixed (which is why Notepad should have a spell checker :nods: )

As for the query, I don't know why it wouldn't work... I copied and pasted it out of MySQL and tried it again... :confused:

This is what my results look like... what about yours?

Disturbed 02-26-2003 11:40 PM

i will test this locally and report you the results :)

One-Team 02-27-2003 01:51 AM

Great Hack
I will Install it :banana: :banana:

Zelda-King 02-27-2003 10:03 AM

I'm trying this out on vB 2.2.9.

Good hack. One snag though. There are 16 of each option beside each other. Also the number of times the options are indicated goes up by 1 as you go along. So in the first size one it says 'small medium large' then in the next one it says 'small medium large small medium large' and so on. (I got rid of the LARGER font sizes. I don't like seeing posts in like size 5+ font or something personally. :D)

Here, I took a screenshot of the bug (see attachment).

It's something to do with the member.php because if I revert that file the templates work fine.

EDIT: I fixed it. Basically, instead of using
PHP Code:

eval("\$getfontcolor.= \"".gettemplate("vbcode_colorbits")."\";");
eval(
"\$getfontsize.= \"".gettemplate("vbcode_sizebits_mod")."\";");
eval(
"\$getfontfonts.= \"".gettemplate("vbcode_fontbits")."\";");

eval(
"\$postfontcolor.= \"".gettemplate("post_font_color")."\";");
eval(
"\$postfontsize.= \"".gettemplate("post_font_size")."\";");
eval(
"\$postfontfonts.= \"".gettemplate("post_font_fonts")."\";"); 

use
PHP Code:

eval("\$getfontcolor = \"".gettemplate("vbcode_colorbits")."\";");
eval(
"\$getfontsize = \"".gettemplate("vbcode_sizebits_mod")."\";");
eval(
"\$getfontfonts = \"".gettemplate("vbcode_fontbits")."\";");

eval(
"\$postfontcolor = \"".gettemplate("post_font_color")."\";");
eval(
"\$postfontsize = \"".gettemplate("post_font_size")."\";");
eval(
"\$postfontfonts = \"".gettemplate("post_font_fonts")."\";"); 

.

You just shouldn't have the '.'s before the '='s.

The trouble is this can pose problems for boards that have several styles. If the top 'default' option was truly 'default' and didn't insert any vB code that would be perfect.

I was thinking something along the lines of
PHP Code:

// #####################  BEGIN FONT COLOR SIZE HACK ##################
        
if($bbuserinfo[post_color] == "Default"){
$message "[font=".$bbuserinfo[post_font]."][size=".$bbuserinfo[post_size]."]".$message."[/size][/font]";
} else {
$message "[color=".$bbuserinfo[post_color]."][font=".$bbuserinfo[post_font]."][size=".$bbuserinfo[post_size]."]".$message."[/size][/font][/color]";
// #####################  END FONT COLOR SIZE HACK #################### 

but that is parsed wrong in the top line. Needs correcting. That code just gets me an unexpected T_DEFAULT.

TalkHardRandy 02-27-2003 03:25 PM

Okay... fixed the file with your first fix Zelda... danke.

As to the second part, I'm going to put an on/off button in there so people can select which features they wish to use. It'll double the options in the CP and make the newreply & newthread parts bigger, but you're right it is kinda a pain...

Dean C 02-27-2003 03:31 PM

Nice hack Randy. I saw this and thought you would have had a numeric field to enter for the font size. It's in dropdowns which i would have suggested anyway. Excellent hack pal :)

- miSt

Zelda-King 02-27-2003 03:34 PM

Quote:

I'm going to put an on/off button in there so people can select which features they wish to use.
As long as the default for the ON/OFF button is 'OFF' so people's posts don't override various theme colour defaults unless they actually update their profile to do so, then that'd suit me fine.

Actually my default theme text colour IS black so it's not much problem for me personally.

TalkHardRandy 02-27-2003 03:58 PM

Danke Mist...

For the sake of sanity, it's an either or deal... you can use the defaults or you can specify your own... default will be set to 'ON', so all it does is post the $message w/o the extras.

TalkHardRandy 02-27-2003 04:57 PM

Okay... I've updated the hack.

It now give an option to use the forum defaults via an ON/OFF. If you have multiple styles, this should clean it up. But, I don't run multiple styles, so I can't be 100% sure. Plus, I think I'm figuring out how to keep the default values from reseting...

Zelda-King 02-27-2003 05:31 PM

I'm getting this database error when I update my profile:

Database error in vBulletin 2.2.9:

Invalid SQL: UPDATE user SET birthday='0',signature='(Sig)',customtitle='1',use rtitle='(Rank)',email='(email)',parentemail='',cop pauser='0',homepage='homepage',icq='',aim='',yahoo ='',usergroupid='6',default_fcs='1',post_size='2', post_font='times new roman',post_color='black' WHERE userid='1'
mysql error: Unknown column 'default_fcs' in 'field list'

mysql error number: 1054

Date: Thursday 27th of February 2003 12:20:27 PM
Script: http://www.gamercrossfire.net/bb/bb/member.php
Referer:


Seems to be requesting the wrong URL. :/

Anyway, at least my posts were default colour before I updated it this time. :)

TalkHardRandy 02-27-2003 05:36 PM

The SQL query didn't take. It's because you already have three of the four fields in there. Run this query instead:
Code:

ALTER TABLE `user` ADD `default_fcs` INT( 1 ) DEFAULT '1' NOT NULL AFTER `inforum';

Zelda-King 02-27-2003 05:54 PM

OK, I fixed that.

Now everything stays on default regardless. Either I'm doing something wrong or your PHP code needs an } else { for the default_fcs in newreply.php/newthread.php

TalkHardRandy 02-27-2003 06:21 PM

Okay, you have to go into your profile, turn off the defaults, then select what you want it to change. Save your profile, then try it.

For some reason that I'm still working out, the user selections don't come back as the default values. I'm working on it, however.

Zelda-King 02-27-2003 06:26 PM

Yeah, whether I turn off the defaults or not now the posts come out default, though before you put the 'default' check in it worked fine.

Then again, if I edit the PHP to
PHP Code:

if ($bbuserinfo[default_fcs]="1") {
        
$message "[color=".$bbuserinfo[post_color]."][font=".$bbuserinfo[post_font]."][size=".$bbuserinfo[post_size]."]".$message."[/size][/font][/color]";


then I get the reverse situation.

I tried putting
PHP Code:

if ($bbuserinfo[default_fcs]="0") {
        
$message "[color=".$bbuserinfo[post_color]."][font=".$bbuserinfo[post_font]."][size=".$bbuserinfo[post_size]."]".$message."[/size][/font][/color]";
} else {
$message "$message";


in newthread/newreply.php but that didn't help.

Boofo 02-27-2003 07:44 PM

Would there be a way to have a testing box so you could compare the board defaults with whatever you picked to see how they look compared to one another? That way you wouldn't have to go all the way to make a post to see how it would look.

TalkHardRandy 02-27-2003 08:27 PM

He's right... it doesn't matter if its on or off, it uses whatever you have selected....

EDIT:

Okay, in the newreply & newthread:

change:

PHP Code:

    if ($bbuserinfo['default_fcs']="0") {
        
$message "[color=".$bbuserinfo[post_color]."][font=".$bbuserinfo[post_font]."][size=".$bbuserinfo[post_size]."]".$message."[/size][/font][/color]";
    } 

to

PHP Code:

$usingdefaults="$bbuserinfo[default_fcs]";
if (
$usingdefaults=="0") {
        
$message "[color=".$bbuserinfo[post_color]."][font=".$bbuserinfo[post_font]."][size=".$bbuserinfo[post_size]."]".$message."[/size][/font][/color]";


For some reason, it doesn't like using $bbuserinfo without a variable.

Text file updated... if that gets everyone working, I've got the fix to the defaults.

Zelda-King 02-27-2003 08:59 PM

I tested it. Works fine. Great work!

What'd be even better is if people could have custom fonts set but still use the default colours. Size/font isn't an issue but you really should be able to use two out of the three functions and still be able to keep to the default colour (unless you set it manually otherwise), for the sake of multiple forum styles.

Other than that, there's the matter of having to fix your settings every time you edit your profile.

Once that's all sorted out I'd say you're good to go. Also, the ON/OFF button stays as you set it (it doesn't revert) so that's good. :)

TalkHardRandy 02-27-2003 09:38 PM

DEFAULTS IS FIXED!!!

It's sloppy & I don't like it, but short of rewriting every template and dumping a bunch of extras into the member.php, it should work. Text file has been updated. Be sure to read through it as I change all the templates.

Let's see what breaks now, shall we?

TalkHardRandy 02-27-2003 09:56 PM

Quote:

Originally posted by Zelda-King
What'd be even better is if people could have custom fonts set but still use the default colours. Size/font isn't an issue but you really should be able to use two out of the three functions and still be able to keep to the default colour (unless you set it manually otherwise), for the sake of multiple forum styles.
You mean their own fonts that they use? It could be done, but it wouldn't be displayed for the others unless they had the same fonts installed.

I included font size because, I love Garamond, but set to 2 is too small... it needs to be set to 3. Other fonts are the same way.

Glad you guys like... definately good for the ol' ego...

Zelda-King 02-27-2003 10:05 PM

Yeah, I just mean people might want to use custom fonts in the default colours (which'd cause less of a clashing problem with themes unless they wanted to alter their colour). Like... I could select your 'times new roman' custom font, update the profile and the colour would be default so it goes with all the themes.

I installed the updates. I see why you don't like it. It's just a teensy bit odd when you change your customs and you see your old choice repeated at the top, but yeah, it works. You made pretty good progress today.

Link14716 02-27-2003 10:53 PM

This is actually a lot easier to do with custom profile fields and doing it that way gives your users the freedom to enter a HEX value, so that's how I'd do it. ;)

TalkHardRandy 02-27-2003 11:12 PM

Quote:

Originally posted by Link14716
This is actually a lot easier to do with custom profile fields and doing it that way gives your users the freedom to enter a HEX value, so that's how I'd do it. ;)
Agreed... it was easier that way.

The problem we kept coming across was the users would send PM's saying, "Why doesn't my color/font work?", only to find out that 'seafoam' isn't a real color (and don't ask about the HEX code problems) or someone would have 'Burton's Nightmare' loaded on their computer, but no one else did.

We wanted to make it easier on the users who use it.

TalkHardRandy 02-27-2003 11:22 PM

Quote:

Originally posted by Zelda-King
Like... I could select your 'times new roman' custom font, update the profile and the colour would be default so it goes with all the themes.
I see what you mean... an ON/OFF per option.

I tried it originally and discovered it makes a whole bunch of extra code in the newthread & newreply. Each would have a SELECT statement with six options, as opposed to a single on/off. If you only want to user one part of it, Palmer's hack is much simplier, except, like I said, you have to input manually what you want. I never figured out a way to tie it into the vbcode_bits.

Quote:


You made pretty good progress today.

Thanks a lot Z... you help muchos. I'm just waiting to see if anyone else installs and has problems/suggestions. One of my users suggested adding a glow option to it, but I told him to use the GLOW tags instead. Hurts my eyes :laugh:

nnjj.net 02-28-2003 11:41 AM

exe. is't ok to install it or still having probs?

thanx

Zelda-King 02-28-2003 02:46 PM

It's working fine for me. I added a load of fonts in the vbcode_fontbits template. All tested on vB first to make sure they work for everyone. I've got 30 fonts in there now. :)

And here it is;
Code:

<option value="verdana">Verdana</option>
<option value="arial">Arial</option>
<option value="times new roman">Times new roman</option>
<option value="courier new">Courier</option>
<option value="chasm">Chasm</option>
<option value="dolphin">Dolphin</option>
<option value="kelt">Kelt</option>
<option value="ms sans serif">Ms sans serif</option>
<option value="mirror">Mirror</option>
<option value="quixley let">Quixley let</option>
<option value="ruach let">Ruach let</option>
<option value="shorthand">Shorthand</option>
<option value="surfer">Surfer</option>
<option value="tahoma">Tahoma</option>
<option value="terminal">Terminal</option>
<option value="westminster">Westminster</option>
<option value="bangle">Bangle</option>
<option value="eurasia">Eurasia</option>
<option value="lynda cursive">Lynda cursive</option>
<option value="gaze">Gaze</option>
<option value="lucida sans">Lucida sans</option>
<option value="paris">Paris</option>
<option value="system">System</option>
<option value="tempus sans">Tempus sans</option>
<option value="university roman let">University roman let</option>
<option value="victorian let">Victorian let</option>
<option value="bimini">Bimini</option>
<option value="fixedsys">Fixedsys</option>
<option value="la bamba let">La bamba let</option>
<option value="cataneo bt">Cataneo bt</option>

I'd put them alphabetically but the default 'first' one is Verdana. :D

I recommend that setup. Those fonts're OK on vB as opposed to... some other ones.

TalkHardRandy 02-28-2003 04:27 PM

Quote:

Originally posted by nnjj.net
exe. is't ok to install it or still having probs?

thanx

No problems... all fixed...

Boofo 02-28-2003 06:01 PM

Zelda-King, those fonts will only work for the user if they themselves also have them installed on their machine (version of Windows). The fonts from Windows XP won't all work on Windows 95 or Windows 98 as they don't have all of the same fonts as Windows XP does.

Zelda-King 02-28-2003 06:33 PM

Yeah, these're pretty 'unspecial' fonts so I'm banking on there being no problems. I'll see how it goes. Having said that, mine doesn't even have Book Antigua! O_O

Boofo 02-28-2003 07:12 PM

I have a whole crapload too, but if they don't have a font they picked, it should just default to Arial, so you should be ok. ;)

Zelda-King 02-28-2003 08:35 PM

Yeah, my 'Book Antigua' comes out as arial. I should get a good test run in this sunday from more people so I'll update if there're problems.

EDIT: There's a bug somewhere. I'm seeing a few people with quite big fonts. The vB code being
Code:

[color=][font=][size=]Text[/size][/font][/color]

TalkHardRandy 03-03-2003 08:08 PM

Zelda, make sure that in the database the 'default_fcs' is set to '1' as a default. I had a couple of new users that happened to also. Plus, the text file is fixed.

Zelda-King 03-03-2003 10:54 PM

My default is 1. I'll see what I can do with this updated text file.

TalkHardRandy 03-05-2003 02:51 PM

Hmmm... what are their settings in the database?

Vivi Ornitier 03-06-2003 02:15 AM

the DB queries still don't work!! ahhh!!!

ADD `post_size` VARCHAR( 1 ) DEFAULT '2' NOT NULL

MySQL said:

You have an error in your SQL syntax near 'ADD `post_size` VARCHAR( 1 ) DEFAULT '2' NOT NULL' at line 1

I get that error from phpadmin

zootsuit 03-06-2003 04:44 AM

You have to run this as one query:

ALTER TABLE `user` ADD `post_font` VARCHAR( 25 ) DEFAULT 'Verdana' NOT NULL ,
ADD `post_color` VARCHAR( 25 ) DEFAULT 'black' NOT NULL ,
ADD `post_size` VARCHAR( 1 ) DEFAULT '2' NOT NULL ;

msimplay 03-06-2003 11:20 AM

does this hack work for vbulletin 2.3 release candidate one ?


All times are GMT. The time now is 10:39 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01396 seconds
  • Memory Usage 1,876KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (9)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete