PDA

View Full Version : Change style on index with UPDATE


grog6
05-01-2003, 10:00 PM
This hack displays a small box at the top of your forum's index, where you can change easily of style.
The number of users who used is too displayed just next the Style's name.

This hacks was already existed :

https://vborg.vbsupport.ru/showthread.php?s=&threadid=33418&highlight=style+AND+index

but it didn't updat the user's table in the database, and if you use others hacks which display the user's style in the postbit, or an other hack to list hacks used on your board (such as mine or Lesane's), information which was displayed was false ! Now, it's updated when the user uses this scroll menu, and so, no pb with other hacks :-)

Moreover, the style directly shown in the scroll menu, is the style that the user uses, so he knows which style he used
A simple changement in this scroll menu, and the user is automatically redirected to the forum's index with the new style selected




Ce hack affiche en haut de votre forum une petite boite, ou vous pouvez facilement changer de style.
Le nombre d'utilisateurs utilisant ce style est egalement montre a cote du nom du style.

Ce genre de hack existait deja :

https://vborg.vbsupport.ru/showthread.php?s=&threadid=33418&highlight=style+AND+index

mais il ne mettait pas a jour les infos du membre dans la table user, et si vous utilisez d'autres hacks qui montre le style de chaque membre dans le postbit, ou mon hack qui liste les styles utilises sur votre forum, les infos affichees auraient alors pu etre fausses ! Maintenant c'est mis a jour quand le user utilise ce petit menu, et ainsi, plus de pb avec les autres hacks :-)

De plus, le style actuellement utilis? par le membre est directement affiche, ainsi il sait quel style il utilise a tout moment.
Un simple changement dans ce menu, redirige le membre vers l'accueil du forum avec le nouveau style choisi



Here is the english version.
I could understand a mod or Firefly want to remove this hack (which is only a modification of an other one)

Voici la version anglaise.
Je pourrais comprendre qu'un modo ou un Firefly veuille supprimer ce hack, etant donne que ce n'est que la modification d'un hack de Firefly

grog6
05-02-2003, 08:55 PM
Here is the french version

Voici la version francaise.

grog6
05-02-2003, 08:55 PM
and the SC

Disturbed
05-02-2003, 09:41 PM
nice!

thanks man, i needed that :D

flup
05-02-2003, 09:55 PM
Haha, uc, Grog6 has followed my command ;P

grog6
05-02-2003, 09:57 PM
@ Flup : ;)

N9ne
05-02-2003, 10:07 PM
Nice work grog, but how many queries does this add to forumhome?

grog6
05-02-2003, 10:26 PM
1 query to get the number of styles,

1 other which is run X times (depends of your number of styles to display how many users use the style, but you can remove this query and not show the number of users who use styles,

and 1 to update the user's table which is ONLY run if the user modify his style ;)

all-the-vb
05-02-2003, 10:48 PM
nice work :glasses:

MetroSports82
05-03-2003, 01:19 AM
grog6,

nice hack. :) 1 question. say i have other styles running, but are not selectable to users, how I can avoid from having those style sets from showing up in the box? i've attached a ss to show you what i mean. i have 4 styles that are set as non-selectable. (ie, 0 users) thanks! ;)

grog6
05-03-2003, 09:30 AM
@ Metrosports82 : Replace in the index.php


$styles=$DB_site->query("SELECT styleid,title FROM `style` ORDER by styleid");

by

$styles=$DB_site->query("SELECT styleid,title FROM `style` WHERE userselect='1' ORDER by styleid");

Archive updated ;)

MetroSports82
05-03-2003, 01:28 PM
thanks mate. great job on the hack. ;)

Alien
05-03-2003, 05:30 PM
Hey nice work.

May I ask exactly what needs to be removed to take out the number of users using a style? Thanks!

-Jason

Yesterday at 07:26 PM grog6 said this in Post #8 (https://vborg.vbsupport.ru/showthread.php?postid=390664#post390664)
1 query to get the number of styles,

1 other which is run X times (depends of your number of styles to display how many users use the style, but you can remove this query and not show the number of users who use styles,

and 1 to update the user's table which is ONLY run if the user modify his style ;)

grog6
05-03-2003, 05:59 PM
@ Alien : Remove it from the index.php modification :

$listes=$DB_site->query_first("SELECT COUNT(*) AS nombre FROM `user` WHERE styleid='$style[styleid]'");
$nombre=$listes[nombre];

if ($bbuserinfo[styleid] == $style[styleid]) $select='selected'; else $select='';

And it from the style_liste template : ($nombre)

-Sidekick-
05-03-2003, 11:28 PM
Here is a problem I'm having with this hack...

If I use the style change hack to change my style, then I go into my usercp options and try to change it to something else, it won't take effect on the style I pick in my usercp options unless I pick it twice in a row.

Did I explain that okay? -.-

o0stephane0o
05-05-2003, 08:50 AM
Side click, the bug you are experioencing have nothing to see with that hack, you have just noticed it now but it was there before installing that hack.

Edgar
05-05-2003, 11:16 AM
Nice hack, but the numbers are not coming up correct for me.
To see what I mean see: http://www.avalancheonline.com/forums/index.php?s=
I have close to 1900 members yet only 200 or so users are showing up in the menu. And these are the only 3 styles there are.

grog6
05-05-2003, 11:30 AM
@ Edgar : Take a look into your database, and look if other users don't have a wrong styleid recorded in their profile which may correspond to an old style you could have removed ;)

Edgar
05-05-2003, 12:19 PM
Ah, that will probably be it. I had a duplicate on one of my styles I later removed. So I guess the number will only update when people use that dropdownbox now or change it in their profile again, I see it already increased by a few numbers.

But I can live with it. Nice job with your hacks man, I already installed a few of them. They're small but usefull hacks, I like it that way.

grog6
05-05-2003, 12:27 PM
Cliks install if you like it :)

Edgar
05-05-2003, 02:33 PM
Done :cool:

-Sidekick-
05-05-2003, 06:53 PM
Today at 04:50 AM o0stephane0o said this in Post #16 (https://vborg.vbsupport.ru/showthread.php?postid=391675#post391675)
Side click, the bug you are experioencing have nothing to see with that hack, you have just noticed it now but it was there before installing that hack.

Yes it does have to do with this hack. I'm absolutely positive it does. I've changed my style many times before installing this hack and never had a problem.

It's not just this hack, it's any of these style changing hacks. Even here on vb.org you'll experience the problem if you do what I described and it's not even the same hack.

Now is there any solution to this?

BustaCap
05-05-2003, 09:09 PM
Grog, I have a question about your hack. When I go to edit my forumhome template (Templates/modify) I see this:


http://www.jdcarr.com/images/templates.gif

Do I have to edit the forumhome template for all the different styles?

Also, when I create the two new templates, which template set do I save them to (Default, plasma, etc...)?

Thanks!

grog6
05-05-2003, 09:40 PM
@ BustaCap : To add this modification to all styles, you have to add the 2 new templates and add the variable to each of your forumhome template ;)

That's why I created 2 .txt file which countain the template to add, use the hack Template Backup System to add these 2 templates to each style faster ;) (just 2 clicks ;) )

BustaCap
05-06-2003, 12:31 AM
I've installed Firefly's template backup hack. I'm not clear on how I should use this to add the two templates to all of the style sets. ..

Sorry for being so dense about this but I'm new to this. Can you tell me how I should do this?

-Sidekick-
05-06-2003, 04:59 AM
You can do it fast without any hacks. Create one of the templates to your top style. Then hit your back button for your browser and change the style you are saving it to from the dropdown menu. Then do the same for the second template. :)

-Sidekick-
05-06-2003, 05:00 AM
Grog any comment on my situation? Otherwise I'll just remove the style change option from the usercp since it will be on the main page of the forums.

grog6
05-06-2003, 09:26 AM
@ -Sidekick- : Yup but you have to clik X times (the number of styles you have ;) ) to install a template to all styles, and the same thing with the second template whereas with the TBS, just upload the 2 .txt files to your FTP, and then click import to all styles, and you"re done :)

For your question concerning the user profile's change, and the problem you have, as you've said above, this pb is when you install a hack to change the style elsewhere than ic the user CP :(
I don't know why, sorry guy :(

BustaCap
05-06-2003, 04:19 PM
ah, so I can import a .txt file as a template? That's what had me confused. I though I had to somehow convert it to a template file before I could import it.

Anyway, I got it working and it seems to be both showing correctly the number of users using each style, including showing styles even if noone is using them. Thanks!

BustaCap
05-11-2003, 03:55 PM
grog6, I've got it working and it's working as it should except for one problem. On one of my styles it "squashes" it so that it looks really narrow. However, if I select the style through the UserCP it looks fine, so it must be something to do with the hack. The style is the Ravio Skin (http://www.vbskins.com/demo/indexravio.htm) offered by VBskins.com. It happens with both the fixed width and expanded style. Any thoughts as to why this happens or how to fix it?

Right now what I've done is to remove the:

<center>
$style_select
</select>
<br>

from the forumhome template for the Ravio style. Of course, this means that I don't get the dropdown box on that skin. However, if I'm viewing another skin (with the dropdown box) I can at least change to the Ravio Skin. As soon as I add the:
<center>
$style_select
</select>
<br>

to the forum home for Ravio style it messes it up again. So I'm just leaving it out.

-Sidekick-
06-05-2003, 07:42 AM
Can this be modified so it will work in the header template as well? If so, how?

grog6
06-05-2003, 03:02 PM
Use firefly to use it in the header, I think it should be better ;)

With mine, all modifications are done in the index.php, and if you want to do it in the header, you' ve to modify the global.php ...

Mr. Brian
06-05-2003, 07:26 PM
Might install this if I have the time to do so.. ;)

Matthew's click *install* :)

Chris M
06-05-2003, 09:42 PM
05-05-03 at 01:16 PM Edgar said this in Post #17 (https://vborg.vbsupport.ru/showthread.php?postid=391712#post391712)
Nice hack, but the numbers are not coming up correct for me.
To see what I mean see: http://www.avalancheonline.com/forums/index.php?s=
I have close to 1900 members yet only 200 or so users are showing up in the menu. And these are the only 3 styles there are.

@Edgar - You could alternatively force all users to update their styles, by running this query:

UPDATE user SET styleid='1' WHERE styleid!='2' AND styleid!='4'
^ That should work:)

That query will update all users setting their styleid to 1, unless their styleid is 2 or 4 (the other 2 styles on your site):)

Satan

grog6
06-05-2003, 10:07 PM
Hehe, thx Chris :)

-Sidekick-
06-06-2003, 02:53 AM
Today at 11:02 AM grog6 said this in Post #32 (https://vborg.vbsupport.ru/showthread.php?postid=404780#post404780)
Use firefly to use it in the header, I think it should be better ;)

With mine, all modifications are done in the index.php, and if you want to do it in the header, you' ve to modify the global.php ...

FireFly's doesn't Update things like the postbit hack like yours does. That's why I was wondering if you can expand on this one. -.-

grog6
06-06-2003, 06:09 PM
Try this Sidekick, it may bu usefull for you ;)

https://vborg.vbsupport.ru/showthread.php?s=&threadid=48597&highlight=add+AND+template+AND+each+style

-Sidekick-
06-07-2003, 05:49 AM
That hack will update the style postbit hack like yours?

grog6
06-07-2003, 12:06 PM
I haven't looked at this hack yet, but just ask the question to the hacker, he should answer you with pleasure ;)

-Sidekick-
06-11-2003, 05:42 AM
I've gotten no response from that hacker....

grog6
06-11-2003, 11:48 AM
I can nothing for you at the moment ... haven't any time ...

See it later (at the end of the week ! ;) )

Raz
06-23-2003, 06:40 PM
There is a security issue with this hack. I won't release the detail just yet, but here is what mine currently looks like:if ($bbuserinfo['userid'] > 0 and $_GET['styleid'] > 0) {
$newstyleset = intval($_GET['styleid']);
if ($allowchangestyles==1) {
$DB_site->query("UPDATE session SET styleid='$newstyleset' WHERE sessionhash='".addslashes($session['dbsessionhash'])."'");
$DB_site->query("UPDATE user SET styleid='$newstyleset' WHERE userid='$bbuserinfo[userid]' LIMIT 1");
vbsetcookie("bbstyleid","",1);
}
standardredirect("Style settings have been updated.", $bburl);
exit;
}There extra code is how vB itself deals with changing styles i.e. expiring the style cookie and updating the sessions table.

BigJohnson
06-28-2003, 02:18 PM
Hey SideKick. I have fixed that problem you have been tlaking about with the having to sumbit twice. Well that problem is due to this hack.

I have fixed it. And I think vbulletin.org should actually use this hack as well.

Ok go to member.php.

change this


$stylesetlist = "";
if ($allowchangestyles==1) {
$stylesets=$DB_site->query("SELECT * FROM style WHERE userselect=1 ORDER BY title");
if ( !isset($bbuserinfo['realstyleid']) ) {
$bbuserinfo['realstyleid'] = $bbuserinfo['styleid'];
}
while($thisset=$DB_site->fetch_array($stylesets)) {
if ($bbuserinfo['realstyleid']==$thisset['styleid']) {
$selected = "selected";
} else {
$selected = "";
}
$thisid = $thisset['styleid'];
$thisstylename = $thisset['title'];
eval ("\$stylesetlist .= \"".gettemplate("modifyoptions_styleset")."\";");
eval ("\$stylecell = \"".gettemplate("modifyoptions_stylecell")."\";");
}
} else {
$stylecell = "";
}

to this

$stylesetlist = "";
if ($allowchangestyles==1) {
$styles=$DB_site->query("SELECT styleid,title FROM `style` WHERE userselect='1' ORDER by styleid");
while ($style=$DB_site->fetch_array($styles)) {

$listes=$DB_site->query_first("SELECT COUNT(*) AS nombre FROM `user` WHERE styleid='$style[styleid]'");
$nombre=$listes[nombre];

if ($bbuserinfo[styleid] == $style[styleid]) $select='selected'; else $select='';

eval ("\$stylesetlist .= \"".gettemplate("modifyoptions_styleset")."\";");

}
eval ("\$stylecell = \"".gettemplate("modifyoptions_stylecell")."\";");

if ($styleid!='')
{
$DB_site->query("UPDATE user SET styleid='$styleid' WHERE userid='$bbuserinfo[userid]'");
}
}else{
$stylecell = "";
}

and then change in the templates

modifyoptions_styleset
to this


<option value="$style[styleid]" $select> $style[title] ($nombre)</option>


This works 100%. I hope u enjoy it.

-Sidekick-
06-29-2003, 02:34 AM
Thank you very much for looking into it Big, but I think I'm gonna hold off untill this security issue is looked into, and someone can modify it so it will work in the header as well. :)

Kamui Shirou
06-29-2003, 05:14 PM
now ive got 45 queries instead of 35

Kamui Shirou
06-29-2003, 06:37 PM
hm some kind of wierd. with out this hack i've got 33 queries, with it i've got 45 queries. with the one firefly posted 41 queries..... what the hell please help me ^^

DB8 MissingLink
08-12-2003, 03:30 AM
I know this has been asked and vaguely responded to, but it would be awesome if I could add this to the header instead of forumhome...

Anyone...?

Please :)

jEd

-Sidekick-
08-14-2003, 04:23 AM
08-11-03 at 11:30 PM DB8 MissingLink said this in Post #47 (https://vborg.vbsupport.ru/showthread.php?postid=425358#post425358)
I know this has been asked and vaguely responded to, but it would be awesome if I could add this to the header instead of forumhome...

Anyone...?

Please :)

jEd

This hack was ditched by the hacker a couple of months ago. =\

trinitym
01-16-2004, 06:32 PM
Is someone distributing this hack for vb3? I'd love to add this type of functionality to my board. I noticed it's on this [vb.org] board. :)

[I did a search and all I could find were vb2x versions, sorry if I'm blind.]

grog6
01-17-2004, 01:15 AM
Hurm, haven't you seen at the bottom of each page on vb3 a similar thing ?? ;)

WaterTrooper
01-29-2004, 12:27 AM
All I can say is that this is a great hack. :)