vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   VB3 MicroStats (https://vborg.vbsupport.ru/showthread.php?t=62173)

TECK 03-04-2004 10:00 PM

VB3 MicroStats
 
You asked for... but it was available for VB2 only? There you go, you have it now. ;)

Looking for 3.5.4 version? Get it here.

VERSION 1.2 RELEASED
Basically the only difference you will notice is a dropdown menu that will display the unchached templates.
In this way, you can add it to the cache and save one or more queries.


[high]THIS HACK WAS TESTED IN A DEFAULT, CODE UNMODIFIED BOARD.[/high]

This hack will add at the bottom of each vBulletin(powered) page the following stats:
REGULAR USERS STATS
- load time of specified page in microseconds (with custom no. of digits to show)
- percentages of PHP/MySQL usage
- number of queries executed

ADMINISTRATOR STATS
- number/name of uncached templates (name highlighted in blue, for uncached template)
- vBulletin DEBUG mode status
- server GZIP library compression status
- average Server Loads

[high]This is not only estethic, it will also help you troubleshoot any wierd queries that you have in your scripts.[/high]

IMPORTANT
If you get results like:
Page generated in 3.35731196 seconds (9.05% PHP - [high]90.95%[/high] MySQL) with 17 queries
You probably use a bad piece of code, because vBulletin will never generate those extreme results.
Imagine this: the code uses only 10% the resources to read the actual PHP code and the rest of 90% is used only to scan the tables... WOW!
That means the code forces to read into the database for each user who visits the site at this percentage... if you have 1000 users viewing the page in the same time.. you can get a picture of it...
If you compare this with vBulletin, the software does the opposite, 90% PHP and 10% MySQL... the right way.

DIVISION BY ZERO ERROR? Read this.
INVALID STATS IF MYSQL COMPILED IN A NON-ENGLISH LANGUAGE? Read this.

NOTE: The blue highlighting is not working in Opera 7.23 version. (Thanks Christine)

Have fun. :)

Gary King 03-05-2004 01:28 AM

Nice job on this hack TECK :)

Gio Takahashi 03-05-2004 01:55 AM

Been waiting for this hack. Will install when Gold is out.

Good job, Teck!

TECK 03-05-2004 02:35 AM

The part of code that needs to be edited is final. ;)
Feel free to install it now.

Natch 03-05-2004 02:46 AM

Can I ask - how to implement it ? I don't see how to actually layout the items for the same output I used to get for your previous hack ...

TECK 03-05-2004 03:27 AM

Quote:

Originally Posted by Natch
Can I ask - how to implement it ? I don't see how to actually layout the items for the same output I used to get for your previous hack ...

I'm sorry, I don't understand your question?
You mean: How to display the options the same way like the previous hack? Through a template? You can simply edit the html code to suit your needs...

I didn't want to create any templates do to the RC stage.
Also, I think is better to have it hard coded...
Code:

        $ms = '<tr align="right">' . "\n";
        $ms .= '                <td class="tcat"><div class="smallfont">';
        $ms .= 'Page generated in ' . $totaltime . ' seconds (' . $msphp . ' - ' . $mssql . ') with ';
        $ms .= $query_count . ' queries</div></td>' . "\n";
        $ms .= '</tr>' . "\n";

Code:

                $ms .= '<tr align="right">' . "\n";
                $ms .= '                <td class="alt1"><div class="smallfont">';
                $ms .= $mstemplates . $msdebug . $msgzip . $msserver . '</div></td>' . "\n";
                $ms .= '</tr>' . "\n";

Look at the code, is all there...

assassingod 03-05-2004 05:32 AM

Cool hack:):)

Zelda-King 03-05-2004 05:52 AM

Oh yes! I've been waiting for this. This is safe for the server, yes? I mean having the options that AREN'T for admins only. Well, I know you know about that old issue so I assume the answer's yes.

Logician 03-05-2004 07:05 AM

One of my favorites hack is back! :)

AlexanderT 03-05-2004 09:54 AM

Works very well here (v3.0rc4)!

PitchouneN64ngc 03-05-2004 10:50 AM

Thanks for this great hack, it's useful :)

But when you have the quick style chooser enabled, your hack deforms a little bit the footer.

For repair this, you must to do these modifications into ./includes/functions.php:

Quote:

$ms .= ' <td class="tcat"><div class="smallfont">';
Quote:

$ms .= ' <td class="tcat" colspan="2"><div class="smallfont">';
And:

Quote:

$ms .= ' <td class="alt1"><div class="smallfont">';
Quote:

$ms .= ' <td class="alt1" colspan="2"><div class="smallfont">';
And all is correct ;)

TECK 03-05-2004 11:19 AM

Thanks for mentioning, PitchouneN64ngc. I uploaded a new file with the fix.
Now is done automatically, so if you ever disable that option, you don't have to edit the code... ;)

TheComputerGuy 03-05-2004 11:58 AM

awesome hack. Installing in a bout 5 minutes ;)

djohn 03-05-2004 11:58 AM

I get a parse error when i go to the Template manager:
Quote:

Parse error: parse error in /home/site/public_html/board/includes/functions.php on line 2463

Fatal error: Call to undefined function: exec_nocache_headers() in /home/site/public_html/board/admincp/global.php on line 37

Boofo 03-05-2004 12:38 PM

I don't see the server load with this installed. It isn't in your screenshot either. ;)

Red Blaze 03-05-2004 01:13 PM

<a href="https://vborg.vbsupport.ru/showthread.php?t=59700" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=59700</a>

Doesn't that do pretty much the same thing? Only admins can see Erwin's version though. But I think that can be changed.

PitchouneN64ngc 03-05-2004 01:25 PM

Quote:

Originally Posted by djohn
I get a parse error when i go to the Template manager:

Have you edited your functions.php file with Dreamweaver?

TECK 03-05-2004 02:14 PM

Quote:

Originally Posted by Sonikku
https://vborg.vbsupport.ru/showthread.php?t=59700

Doesn't that do pretty much the same thing? Only admins can see Erwin's version though. But I think that can be changed.

Unfortunatelly, it does not do the same thing.
Erwin knows the difference:
Quote:

Originally Posted by Erwin
Okay, the original was by TECK. This is NOT based on his code - it is based on vB3's native code. If TECK wants me to remove this, I will do so. This is just my version that I use for my private forums.

Quote:

Originally Posted by Boofo
I don't see the server load with this installed. It isn't in your screenshot either. ;)

You need to have enabled the exec('uptime') in your server, in order to see the average server loads.
Contact your host for more details.
I know that Windows has no uptime binary, that could be executed with exec functions. Only Unix does this.

Boofo 03-05-2004 02:40 PM

I got it working. ;)

I had to change this:
PHP Code:

if (preg_match("/averages?: ([0-9\.]+), [\s]+([0-9\.]+), [\s]+([0-9\.]+)/"$stats$regs)) 

to this:

PHP Code:

preg_match("/averages?: ([0-9\.]+), [\s]+([0-9\.]+), [\s]+([0-9\.]+)/"$stats$regs); 

For some reason there was an if in that line. I know I have exec('uptime') enabled on the server because it was working fine before. And after taking the if out, it works fine now again. Thank you, Teck, for converting this to vB3. ;) I added a couple of things to mine, in case anyone wants to see it. ;)

TECK 03-05-2004 03:09 PM

The IF should not change anything, except avoid proccesing any not needed functions, while increasing performance.
Do you run a UNIX box? Also, something is wrong there with your server. You cannot have 0 for all average loads, or make it work on Windows, from what I know (if anyone knows a way, please let me know, since I'm not good at server configuration ;)).

Leave the code as it is (that's why you get zero's)... and check with your host.
Let us all know the results.

Cheers.

djohn 03-05-2004 03:11 PM

Quote:

Originally Posted by PitchouneN64ngc
Have you edited your functions.php file with Dreamweaver?

No, I've used internal FlashFXP editor. However, now everything is fine, that problem accured only once.

Boofo 03-05-2004 03:26 PM

Quote:

Originally Posted by TECK
The IF should not change anything, except avoid proccesing any not needed functions, while increasing performance.
Do you run a UNIX box? Also, something is wrong there with your server. You cannot have 0 for all average loads, or make it work on Windows, from what I know (if anyone knows a way, please let me know, since I'm not good at server configuration ;)).

Leave the code as it is (that's why you get zero's)... and check with your host.
Let us all know the results.

Cheers.

They are running Linux and the server load has always worked correctly before. It has always flucuated in the past.

TECK 03-05-2004 03:39 PM

Quote:

Originally Posted by Boofo
They are running Linux and the server load has always worked correctly before. It has always flucuated in the past.

Thanks for clearing this up. It beats me why the IF would not work, because it should.
Please post the full IF change so others could see it and paste it properly. :)
If it's working better your way, the hell with the code performance, we will use what's better, right? :D

Cheers.

Boofo 03-05-2004 03:45 PM

Here's what I did. I changed:

PHP Code:

  if ($stats = @exec('uptime 2>&1') AND trim($stats) != '')
  {
   if (
preg_match("/averages?: ([0-9\.]+), [\s]+([0-9\.]+), [\s]+([0-9\.]+)/"$stats$regs)) 

to:

PHP Code:

  if ( $stats = @exec'uptime' ) )
  {
    
preg_match'/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/' $stats $regs ); 

and it works right now. Here is a fresh screenshot of my server load (so you can see that it is working).

Sorry about this Floren. ;)

TECK 03-05-2004 03:52 PM

Quote:

Originally Posted by Boofo
Here's what I did. I changed:

PHP Code:

  if ($stats = @exec('uptime 2>&1') AND trim($stats) != '')
  {
   if (
preg_match("/averages?: ([0-9\.]+), [\s]+([0-9\.]+), [\s]+([0-9\.]+)/"$stats$regs)) 

to:

PHP Code:

  if ( $stats = @exec'uptime' ) )
  {
    
preg_match'/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/' $stats $regs ); 

and it works right now. Here is a fresh screenshot of my server load (so you can see that it is working).

Sorry about this Floren. ;)

Try this for me please:
Code:

  if ($stats = @exec('uptime 2>&1') AND trim($stats) != '')
  {

Let me know if it's working. It should display the stats if the values are not 0 only. Thanks.

Boofo 03-05-2004 03:55 PM

Yes, that works, too. ;)

TECK 03-05-2004 04:00 PM

Ok, let's leave it then this way, what do you think?
Basically, we will remove only the IF in front of PREG_MATCH function... I'm still persistent with the IF... Leave the IF and try to refresh several times the page so you can create a server load. Let me know if it'S displaying the stats. Sorry to bother you but I don't have access to a UNIX server now.

I will update the file when I get back from work.

Boofo 03-05-2004 04:02 PM

Looks good to me. ;)

If I don't remove the IF, the server load doesn't show at all. ;)

TECK 03-05-2004 04:06 PM

Quote:

Originally Posted by Boofo
Looks good to me. ;)

If I don't remove the IF, the server load doesn't show at all. ;)

Try this line?
Code:

                        if (preg_match("/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $stats, $regs))
                        {

Let me know please Bob.
PS. Damn I deleted by accident the image, instead of the file, no more screenshot till tonight... We have one from Bob anyway, heh.

Boofo 03-05-2004 04:11 PM

This is wierd. I re-downloaded your file and put the if code in like you have it in your file and for some reason, it is showing the server load now (with the IF statement). I swear to you that it wasn't working before. I don't know what happened. You have any ideas? ;)

gmarik 03-05-2004 04:17 PM

Nice one!

TECK 03-05-2004 04:21 PM

Quote:

Originally Posted by Boofo
This is wierd. I re-downloaded your file and put the if code in like you have it in your file and for some reason, it is showing the server load now (with the IF statement). I swear to you that it wasn't working before. I don't know what happened. You have any ideas? ;)

My secret :D. Heh.
I made a little mistake, added a space in the wrong space. :p

Boofo 03-05-2004 04:34 PM

So it wasn't me messing up? Come on, you have to tell me. PM if you don't want to spill it here. I have to know now, especially after all we went through together on this, BUDDY! . ;)

TECK 03-05-2004 05:01 PM

Quote:

Originally Posted by Boofo
So it wasn't me messing up? Come on, you have to tell me. PM if you don't want to spill it here. I have to know now, especially after all we went through together on this, BUDDY! . ;)

No, it was REALLY me. :)
I added a space in the wrong place into preg_match() function.
Sorry guys, error fixed, thanks to Bob. The file is uploaded with the right code.

Boofo 03-05-2004 05:58 PM

What a team! What a team! ;)

I guess the file I downloaded had the fixed code in it already? Or do I need to re-download it?

It's working like a charm, by the way. Great work, Floren! ;)

TECK 03-05-2004 06:12 PM

Ya, the file you downloaded is the most recent one.

Boofo 03-05-2004 07:57 PM

Thank you, sir. ;)

ChuanSE 03-05-2004 08:19 PM

I don't know what to do with the footer template :/

I had this
Code:

{ms}
$ms = '<tr align="right">' . "\n";
$ms .= '<td class="tcat"><div class="smallfont">';
$ms .= 'Page generated in ' . $totaltime . ' seconds (' . $msphp . ' - ' . $mssql . ') with ';
$ms .= $query_count . ' queries</div></td>' . "\n";
$ms .= '</tr>' . "\n";
$ms .= '<tr align="right">' . "\n";
$ms .= '                <td class="alt1"><div class="smallfont">';
$ms .= $mstemplates . $msdebug . $msgzip . $msserver . '</div></td>' . "\n";
$ms .= '</tr>' . "\n";

and it gave me this : (see attachment)

= ' ' . "\n"; .= ' '; .= 'Page generated in ' . . ' seconds (' . . ' - ' . . ') with '; .= 8 . ' queries ' . "\n"; .= '
' . "\n"; .= ' ' . "\n"; .= ' '; .= . . . . '

any idea's? :ermm:

Boofo 03-05-2004 08:23 PM

This is all you add to your footer template:

HTML Code:

{ms}
The rest stays in the functions.php

ChuanSE 03-05-2004 09:04 PM

then it does nothin'

but where do i remove the "if" from the pragma thingie?


All times are GMT. The time now is 04:52 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.01565 seconds
  • Memory Usage 1,852KB
  • 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
  • (5)bbcode_code_printable
  • (1)bbcode_html_printable
  • (6)bbcode_php_printable
  • (17)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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