Microstats

Discussion in 'vBulletin Discussions' started by Medora, Nov 21, 2009.

  1. Medora

    Medora Regular Member

    Joined:
    Sep 18, 2009
    Messages:
    134
    Likes Received:
    18
    Location:
    California
    Hi.

    I added a feature that displays this information in the footer:

    Code:
    Page generated in [B]0.17830[/B] seconds with [B]13[/B] queries [Server Loads: [B]1.86[/B] 1.71 : 1.86]
    However, I want to remove this part (it's only viewable to an administrator, but I want to remove it entirely):

    Code:
    [Server Loads: [B]1.86[/B] 1.71 : 1.86]
    Sorry, I understand that I should seek support first of all at the place I found it, by the author who posted it, but he hasn't been around for a long time, and I feel I may have a better chance getting help here since more people would look at the topic, and there are plenty of people here knowledgeable about working with code for vBulletin.

    Anyways, I did a search of the author's topic to see if I could find an answer to my question, and it turned out that one person asked the same question. The answer he received was that he needs to modify the product file, and remove lines 17-32. However, when I do that, I get the following error displaying on the header of my forum:

    Code:
    [B]Parse error[/B]:  syntax error, unexpected '}' in [B]/home/content/h/y/p/hyperionv1/html/includes/functions.php(5584) : eval()'d code[/B] on line [B]6[/B]
    If I understand correct, these are lines 17-32:

    Code:
    $pageendtime = microtime();
    $starttime = explode(' ', $pagestarttime);
    $endtime = explode(' ', $pageendtime);
    $totaltime = vb_number_format($endtime[0] - $starttime[0] + $endtime[1] - $starttime[1], 5);
    $debughtml = '<center><span class="smallfont">Page generated in <b>' . $totaltime . '</b> seconds with <b>' . $vbulletin->db->querycount . '</b> queries';
    
    if ($vbulletin->userinfo['usergroupid'] == 6) {
    
    if ($loadavg = @file_get_contents("/proc/loadavg")) {
    
    $regs = explode(" ",$loadavg);
    $serverload = ' [Server Loads: <b>' . $regs[0] .'</b> ' . $regs[1] . ' : ' . $regs[2] . ']';
    
    }elseif ($stats=@exec('uptime')) {
    
    preg_match('/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/',$stats,$regs);
    Any idea what I did wrong?
     
  2. Chani

    Chani Grand Master

    Joined:
    Sep 1, 2009
    Messages:
    884
    Likes Received:
    54
    First Name:
    Chani
    I only removed the template portion of the plugin where it shows server load, but try this:

    Code:
    
    $pageendtime = microtime();
    $starttime = explode(' ', $pagestarttime);
    $endtime = explode(' ', $pageendtime);
    $totaltime = vb_number_format($endtime[0] - $starttime[0] + $endtime[1] - $starttime[1], 5);
    $debughtml = '<center><span class="smallfont">Page generated in <b>' . $totaltime . '</b> seconds with <b>' . $vbulletin->db->querycount . '</b> queries';
    
    if ($vbulletin->userinfo['usergroupid'] == 6) {
    
    if ($loadavg = @file_get_contents("/proc/loadavg")) {
    
    $regs = explode(" ",$loadavg);
    $serverload = ' [Server Loads: <b>' . $regs[0] .'</b> ' . $regs[1] . ' : ' . $regs[2] . ']';
    
    }elseif ($stats=@exec('uptime')) {
    
    preg_match('/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/',$stats,$regs);
    
     
  3. Medora

    Medora Regular Member

    Joined:
    Sep 18, 2009
    Messages:
    134
    Likes Received:
    18
    Location:
    California
    Chani,

    Thank you for the assistance. Unfortunately, when I upload your modified version of Microstats, I receive the following error on the header of my forum:

    Code:
    [B]Parse error[/B]:  syntax error, unexpected '"' in [B]/home/content/h/y/p/hyperionv1/html/includes/functions.php(5584) : eval()'d code[/B] on line [B]28[/B]
    Also, as with the previous parse error mentioned in my previous post, the "Page generated..." message disappears from the footer.

    That said, I'm wondering if the following information might be relevant/useful. First, here is the URL for the download location for Microstats:

    Microstats - load times, server loads, queries, uncached templates - vBulletin.org Forum

    On that page, I followed the instructions by the author by placing this code in config.php:

    Code:
    [I]$config['Microstats']['replacementvariable'] = '<!-- display microstats here -->';[/I]
    I then edited the phrase powered_by_vbulletin:

    Code:
    Powered by vBulletin&reg;, Copyright &copy 2000 - {2} Jelsoft Enterprises Ltd.
    To include the following inline after:
    Code:
    <br /><!-- display microstats here -->
    Anyways, I am not sure if this is even relevant, but I guess it doesn't hurt to reveal all the details.
     
  4. Chani

    Chani Grand Master

    Joined:
    Sep 1, 2009
    Messages:
    884
    Likes Received:
    54
    First Name:
    Chani
    I missed a " when I was removing code. :(

    Try this:

    PHP:
    $pageendtime microtime();
    $starttime explode(' '$pagestarttime);
    $endtime explode(' '$pageendtime);
    $totaltime vb_number_format($endtime[0] - $starttime[0] + $endtime[1] - $starttime[1], 5);
    $debughtml '<center><span class="smallfont">Page generated in <b>' $totaltime '</b> seconds with <b>' $vbulletin->db->querycount '</b> queries';

    if (
    $vbulletin->userinfo['usergroupid'] == 6) {

    if (
    $loadavg = @file_get_contents("/proc/loadavg")) {

    $regs explode(" ",$loadavg);
    $serverload ' [Server Loads: <b>' $regs[0] .'</b> ' $regs[1] . ' : ' $regs[2] . ']';

    }elseif (
    $stats=@exec('uptime')) {

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

     
    2 people like this.
  5. Medora

    Medora Regular Member

    Joined:
    Sep 18, 2009
    Messages:
    134
    Likes Received:
    18
    Location:
    California
    Chani,

    That worked splendidly.

    I am most grateful.

    Regards,

    Kevin
     
  6. Chani

    Chani Grand Master

    Joined:
    Sep 1, 2009
    Messages:
    884
    Likes Received:
    54
    First Name:
    Chani
    You're more than welcome. :)
     
  7. Nick

    Nick Regular Member

    Joined:
    Jul 27, 2008
    Messages:
    7,441
    Likes Received:
    218
    Some posts have been edited to remove a large portion of the code. Most developers wouldn't appreciate or want their entire product code to be posted anywhere other than where it was originally released. :)
     
  8. Chani

    Chani Grand Master

    Joined:
    Sep 1, 2009
    Messages:
    884
    Likes Received:
    54
    First Name:
    Chani
    Oops, Sorry, Nick. :o
     
  9. Nick

    Nick Regular Member

    Joined:
    Jul 27, 2008
    Messages:
    7,441
    Likes Received:
    218
    No worries, Chani. :)
     
  10. kneel

    kneel Regular Member

    Joined:
    Jun 25, 2009
    Messages:
    612
    Likes Received:
    16
    on an off topic, the Enlighten skin you used looks great! I really like the blue you added!!
     
  11. Medora

    Medora Regular Member

    Joined:
    Sep 18, 2009
    Messages:
    134
    Likes Received:
    18
    Location:
    California
    Thanks, kneel. I owe thanks to Saint (one of my fellow administrators) for the banner, and FullMetalBabe for changing the colors for some of the status icons.

    The rest was just changing hex codes through the ACP.
     

Share This Page