MyBB Community Forums

Full Version: My forum stats mod
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Now granted this may not be the most efficient script but it'll get the job done. This is only getting the data there is currently no printing of it.

I made it compatible the MyBB's config file so all you'd need to edit is one line of code near the top.

Out of date file
You should use something like this instead though.
if($query = mysql_query("SELECT COUNT(*) as total FROM ".$config['table_prefix']."users")) {
$users = mysql_fetch_array($query);
$users = $users['total'];
}
Would be much simpler, an while there is just overkill.

This will ofcourse be on all except the last, allthough, the last you don't need an while since it only will return one item. I suggest.
			 if ($r4 = mysql_query ("SELECT username FROM ".$config['table_prefix']."users ORDER BY uid DESC LIMIT 1")) {
					$results = mysql_fetch_array ($r4);
					$newest_member = $results['username'];
			 }

Oh one last thingy, remember always to define every variable, to avoid security possibilities on servers with register_global on.
Quote:Oh one last thingy, remember always to define every variable, to avoid security possibilities on servers with register_global on.

Do you mean giving the variables a value when the file is loaded?

Well as a said it may not be the most efficient but it'll get tht job done. I implemented your suggestions.

I didn't know about the "SELECT COUNT(*) as total" trick because my book on PHP doesn't talk about that.

[attachment=3097]

Here's the updated file
Simulationcity Wrote:
Quote:Oh one last thingy, remember always to define every variable, to avoid security possibilities on servers with register_global on.

Do you mean giving the variables a value when the file is loaded?
Well, yes. if you do $var .= "wee"; or $var += "wee"; without declaring it first like $var = ""; it could be an possible security vurnability. Smile
I'm assuming $var .= "wee"; has to do concatenation(spelling?) and that $var += "wee"; is an accumulator. If not I don't know what those do. How would it be a security problem?
Well, if anyone has register_global on, anyone could do ?var=whatever and it will be before any of those values. If you understand. that is if you do not declare them before you do += or .=
I sort of understand.
Well you can read more about it here Smile
Oh I get it now. Are there any security problems with what I made?
Hello?
Pages: 1 2