PDA

View Full Version : Updated Stars Hack


08-24-2000, 04:51 PM
Here is an update to my stars hack - this one allows you different colored stars for admins/moderators

edit showthread.php

find:

$userinfo=$DB_site->query_first("SELECT userid,email,username,usertitle,signature,showemai l,homepage,icq,aim,yahoo,joindate,posts FROM user WHERE userid=$userid");


If you have installed the avatar hack, this line will be modified. Just look for ' $userid=$post[userid]; ' and the line listed above will be 3-4 lines below that.

Edit that line listed above and add


usergroupid,


after the "SELECT" in that line. Make sure there is a space between the word you added and "SELECT". Make sure there is a comma after the word you added and before the next. It looks like this:


$userinfo=$DB_site->query_first("SELECT usergroupid,userid, (...) etc etr


find:


$userpostcount=$userinfo[posts];


Add this after it:


// --- Stars Hack by rangersfan

$stars = "";
$s_usergroup = $userinfo[usergroupid];
$moderator=$DB_site->query_first("SELECT usergroupid FROM forumpermission WHERE usergroupid = $s_usergroup AND canadminedit=1");
if ($moderator[usergroupid] == $s_usergroup) // This is a Normal Mod!
{
$starsgif = "<img src=\"images/star2.gif\" border=\"0\" width=\"15\" height=\"15\">";
}
else if ($s_usergroup==6) // This is an Admin!
{
$starsgif = "<img src=\"images/star2.gif\" border=\"0\" width=\"15\" height=\"15\">";
}
else if ($s_usergroup==5) // This is a SuperMod!
{
$starsgif = "<img src=\"images/star2.gif\" border=\"0\" width=\"15\" height=\"15\">";
}
else
{
$starsgif = "<img src=\"images/star.gif\" border=\"0\" width=\"15\" height=\"15\">";
}
if ($userpostcount > 1999)
{ $stars .= $starsgif . $starsgif . $starsgif . $starsgif . $starsgif; }
elseif ($userpostcount > 999)
{ $stars .= $starsgif . $starsgif . $starsgif . $starsgif; }
elseif ($userpostcount > 399)
{ $stars .= $starsgif . $starsgif . $starsgif; }
elseif ($userpostcount > 99)
{ $stars .= $starsgif . $starsgif; }
elseif ($userpostcount > 19)
{ $stars .= $starsgif; }
if ($stars == "")
{
$stars .= "<br>";
}
else
{
$stars .= "<br><br>";
}
// - Stars Hack



You need to supply your own stars names "star.gif" and "star2.gif". "star2.gif" is for admins/moderators. Put them in forums/images.

To modify how many stars correspond to how many posts you will need to change the if ($userpostcount > ..) parts. If you don't want stars, but galagas or such, change the parts that say '$stars .= $starsgif . $starsgif . $starsgif . $starsgif . $starsgif;' to something like '$stars .= (path to my image for x number of posts);'

Edit the postbit template and put $stars where you want them to appear.

[Edited by freddie on 11-04-2000 at 04:56 PM]

08-24-2000, 09:15 PM
Why not just add the html into custom user titles from the control panel?

~Chris

08-24-2000, 09:22 PM
Admns and Mods have custom titles - are you going to monitor their posts to see when they should be given additional stars? What about other users you have given custom titles too? Going to monitor their post count also?
Custom User Title Hack - If you installed this hack of mine then you have to use a stars hack if you want automagic stars.
It's simple and efficient and didn't you (?) complain about having to change the fieldtype of usertitle as it doesn't hold that much info by default.


I think it is something that should be included by default with vB, with a toggle of course.

08-24-2000, 10:01 PM
OK i see now ;) I was just curious

~Chris

09-15-2000, 11:50 PM
Excellent! This is exactly what I was looking for! I was about to try making my own, but decided to take another look through the forums and see if somebody had already made one. Thanks, and well done :)

BTW, does anyone know where I can get some star images? Preferably gold and silver. I'm afraid of what might happen if I attempt to make my own... lol.

-Tom

09-15-2000, 11:54 PM
Originally posted by Tomeeboy
Excellent! This is exactly what I was looking for! I was about to try making my own, but decided to take another look through the forums and see if somebody had already made one. Thanks, and well done :)

BTW, does anyone know where I can get some star images? Preferably gold and silver. I'm afraid of what might happen if I attempt to make my own... lol.

-Tom hehe borrow them from other forums -> http://www.fanforum.com has them :D

09-16-2000, 12:12 AM
Good idea! hehe. That site has some gold stars... I don't really care for the red ones.. I'll try to change the color to blue or silver I guess :) Thanks!

-Tom

09-16-2000, 12:14 AM
A slightly different way, utilizing the options in the control panel is something I wrote a while back:

Add this in place of the hard coded ratings in the if( .. ) blocks.



/// Begin Star Generation

$stars = "";

$formulabits = explode( ";", $userstarformula );

for( $i = 0; $i < count( $formulabits ); $i++ ) {

if( $userpostcount >= $formulabits[ $i ] ) {

$stars .= $startext;

} // end if

} // end if

if( empty( $stars ) ) {

$stars = $startext;

} // end if

/// End Star Generation


Then some things in /admin/options.php:

Add this after the "Styles Options" in options.php -- should be right up at the top around line 68.


<li><a href=\"#stars\">Stars Options</a></li>


Add this after the "Text that means off. This is used to keep the code language independant.." in the options section.. Around line 600.


<!--/// Stars stuff-->

<tr><td colspan=2><p><hr></p></td></tr>
<tr>
<td><p><a name=\"stars\"></a><b>star character or image</b></p></td>
<td><p><input type=\"text\" size=\"35\" name=\"newoption[startext]\" value=\"$startext\"></p></td>
</tr>
<tr><td colspan=2><p>What should we use for stars? Can be a character (e.g. *) or an image (e.g. http://www.yourboard.com/forums/img/star.jpg)<br></p></td></tr>

<!--// user star ratings-->
<tr>
<td><p><b>user star formula</b></p></td>
<td><p><input type=\"text\" size=\"35\" name=\"newoption[userstarformula]\" value=\"$userstarformula\"></p></td>
</tr>
<tr><td colspan=2><p>What kind of formula to use for user star generation?<br></p></td></tr>

<!--/// End Stars stuff-->


Ok, so you have the option of using a URL for the image, if you want make it an image, make sure to put in the entire image url.

<IMG SRC = "etc.">


Otherwise you can use text (I just use the star *).

Also, the formula is something like this:

0;19;99;399;1999

So users with more than one post but less than 19 will get one star, users in between 19 and 99 will get two, etc. And if you want to add another star level, just add another number to the end!

example:

0;19;99;399;1999;9999

But, if it seems harder to do, then don't worry about it -- I just thought I'd share it with people who are looking for this type of hack and might not want to mess with editing PHP files to find the right "formula" -- it took me a while to find a good balance, and if I had to keep uploading a PHP file I'd go crazy! :)

09-16-2000, 02:32 AM
For some reason, I can't get Rangersfan's code to work on my board. I followed the instructions exactly and didn't change any of the code except for the image names and image sizes. Has anyone else had any problems getting this working? or is there something I have to do after editing showthread.php? Here's what my code looks like after I add the hack:

$userinfo=$DB_site->query_first("SELECT usergroupid,userid,email,username,usertitle,signat ure,showemail,homepage,icq,aim,yahoo,joindate,post s FROM user WHERE userid=$userid");

$username=htmlspecialchars($userinfo[username]);
$searchuser=urlencode($userinfo[username]);
$usertitle=$userinfo[usertitle];
$userjoindate=date($registereddateformat,$userinfo[joindate]+(($timeoffset+$bbtimezoneoffset)*3600));
$userpostcount=$userinfo[posts];
// --- Stars Hack by rangersfan
$stars = "";
$s_usergroup = $userinfo[usergroupid];
$moderator=$DB_site->query_first("SELECT usergroupid FROM forumpermission WHERE usergroupid = $s_usergroup AND canadminedit=1");
if (($moderator[usergroupid] == $s_usergroup)||($s_usergroup==6))
{
$starsgif = "<img src=\"images/yellowstar.gif\" border=\"0\" width=\"10\" height=\"9\">";
}
else
{
$starsgif = "<img src=\"images/bluestar.gif\" border=\"0\" width=\"10\" height=\"9\">";
}
if ($userpostcount > 1999)
{ $stars .= $starsgif . $starsgif . $starsgif . $starsgif . $starsgif; }
elseif ($userpostcount > 999)
{ $stars .= $starsgif . $starsgif . $starsgif . $starsgif; }
elseif ($userpostcount > 399)
{ $stars .= $starsgif . $starsgif . $starsgif; }
elseif ($userpostcount > 99)
{ $stars .= $starsgif . $starsgif; }
elseif ($userpostcount > 19)
{ $stars .= $starsgif; }
if ($stars == "")
{
$stars .= "<br>";
}
else
{
$stars .= "<br><br>";
}
// - Stars Hack

-Tom

09-16-2000, 03:23 AM
Edit the postbit template and put $stars where you want them to appear.

09-16-2000, 03:32 AM
Doh! Feeling pretty dumb now...

Hehehe. Thanks RangersFan ;)

-Tom

09-16-2000, 03:53 AM
Hm... I've run into another problem, and I'm not quite sure what's wrong. I changed the code a little so if the user is Admin/Mod it automatically gives them 5 yellow stars, and if it's just a regular user, it gives them blue stars depending on how many posts they have. For some reason though, it's only giving the Administrator the yellow stars, and not the moderators (who are actually Super Moderators). Does it not work with Super Moderators?

-Tom

09-16-2000, 05:21 AM
Change this line

if (($moderator[usergroupid] == $s_usergroup)||($s_usergroup==6))

to

if (($moderator[usergroupid] == $s_usergroup)||($s_usergroup==6)||($s_usergroup==5 ))

09-25-2000, 11:51 PM
I have installed this hack and it works great! thanks a lot.
But I want to have it do mods get 9 silver stars and supper mods get 9 gold stars and admins get 10 gold

how can I do this? I have beed trying and i can't get it to work.

11-04-2000, 07:57 PM
Con_Man I have changed the code above and if check you will see it now has sections of Mod/SuperMod and Admin. Just put the stars you want for each into each section.

I will optimize the SQL in this hack when v2.0 is released if there are no stars in v2.0 by default.

[Edited by freddie on 11-04-2000 at 05:03 PM]

11-05-2000, 11:10 AM
Originally posted by freddie


I will optimize the SQL in this hack when v2.0 is released if there are no stars in v2.0 by default.

[Edited by freddie on 11-04-2000 at 05:03 PM]

I sure hope there is, should be :)

12-02-2000, 06:15 PM
thanx.
great hack. i changed it a little. i added that admins get 8 stars and mods 7, no matter how many posts they have.

12-04-2000, 10:05 AM
i get this when i upload the updated showthread.php

There seems to have been a slight problem with the database. Please try again by pressing the refresh button in your browser.

An E-Mail has been dispatched to our Technical Staff, who you can also contact if the problem persists.

We apologise for any inconvenience.

any ideas?

02-06-2001, 06:52 PM
Throughout the entire showthread.php file I did not find


$userinfo=$DB_site->query_first("SELECT userid,email,username,usertitle,signature,showemai l,homepage,icq,aim,yahoo,joindate,posts FROM user WHERE userid=$userid");


Nor anything close

02-06-2001, 07:01 PM
Line changed in 1.1.5.

Look for $posts=$DB_site->query_first..........

Hope I'm correct. :)

02-15-2001, 01:26 AM
Tragical Error!

There appears to be something wrong with the Database please e-mail the Technical Staff!

Something along these lines!

Couldn't you release a New Hack that has everything needed in it! And for 1.1.4 because I can't upgrade for some reasons my templates hae been changed and it won't do it!

02-15-2001, 01:58 AM
Sorry buy a license and upgrade.

02-15-2001, 10:09 AM
I have a license and I CAN'T upgrade!

I tried and I got a MAJOR error! IT screwed everything up so I had to go back to 1.1.4!

A simple No, Sorry would hae sufficed!

Maybe if I was a PHP genius like you people it would be easier!

02-15-2001, 01:22 PM
Templates will not stop you from being able to upgrade. Sorry not really a valid excuse.

The only problems being encountered are if you have an older version of MySQL, the code needs to be changed a little. If your PHP version is older than 3.0.9 the new script won't work either.

Or if you have a heavily hacked board you may have to back out some of the hacks.

02-16-2001, 04:38 AM
Thats what I am saying! I have added several of the HACKs to the board. I thought that was EDITED Templates! SheesH!

Its not my fault that the only way to get a great vB is to hack it up and down like a TREE!