vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Admin Quick Stats (https://vborg.vbsupport.ru/showthread.php?t=37193)

Freddie Bingham 04-08-2002 10:00 PM

Admin Quick Stats
 
I don't use vBhacker so you will have to do this the old fashioned way. Also forgive me if something like this has already been released. I think everything is good but it is hard to code in vb2 style after working on the vb3 style so much.

This hack shows some quick stats on your Admin index page such as PHP version, server type, mysql version, Database usage, attachment usage, avatar usage, moderation and forum stats. I can add support for calculating attachments from PPN's attachments as files but I have to actually look at it first, which I will do tomorrow. In vb3 there is a filesize column in the attachment table so you don't need to do anything different if the attachments are currently in the file system (you can move them back and forth) but I assume I will have to run through the directory with filesize() to get an attachment total with the hack.

Anyway open admin/index.php and find:
Code:

if ($moderatenewmembers==1 or $usecoppa==1) {
  $waiting=$DB_site->query_first("SELECT COUNT(*) AS users FROM user WHERE usergroupid=4");
  if ($waiting[users]==0) {
    echo "<font size='1'>There are currently $waiting[users] user(s) awaiting <a href=\"user.php?s=$session[sessionhash]&action=moderate\">moderation</a>.</font>";
  } else {
    echo "<b><a href=\"user.php?s=$session[sessionhash]&action=moderate\">There are currently $waiting[users] user(s) awaiting moderation</a>.</b>";
  }
}

Delete that and replace it with:

Code:

function kbtomb($value) {
        if ($value == 'N/A') {
                return $value;
        } elseif (!$value) {
                return '0.0 MB';
        } else {
                return sprintf('%.2f', $value / 1024000) . ' MB';
        }
}

$starttime = mktime(0, 0, 0, date('m'), date('d'), date('Y'));

$attach = $DB_site->query_first("SELECT SUM(LENGTH(filedata)) AS size FROM attachment");
$avatar = $DB_site->query_first("SELECT SUM(LENGTH(avatardata)) AS size FROM customavatar");

$newusers = $DB_site->query_first("SELECT COUNT(*) AS count FROM user WHERE joindate >= $starttime");
$newthreads = $DB_site->query_first("SELECT COUNT(*) AS count FROM thread WHERE dateline >= $starttime");
$newposts = $DB_site->query_first("SELECT COUNT(*) AS count FROM post WHERE dateline >= $starttime");
$users = $DB_site->query_first("SELECT COUNT(*) AS count FROM user WHERE lastactivity >= $starttime");

$mysqlversion = $DB_site->query_first("SELECT VERSION() AS version");

$indexsize = 0;
$datasize = 0;
if ($mysqlversion['version'] >= '3.23') {
        $DB_site->reporterror = 0;
        $tables = $DB_site->query("SHOW TABLE STATUS");
        $errno = $DB_site->errno;
        $DB_site->reporterror = 1;
        if (!$errno) {
                while ($table = $DB_site->fetch_array($tables)) {
                        $datasize += $table['Data_length'];
                        $indexsize += $table['Index_length'];
                }
                if (!$indexsize) {
                        $indexsize = 'N/A';
                }
                if (!datasize) {
                        $datasize = 'N/A';
                }
        } else {
                $datasize = 'N/A';
                $indexsize = 'N/A';
        }
}

$attachcount = $DB_site->query_first("SELECT COUNT(*) AS count FROM attachment WHERE visible = 0");

$serverinfo = PHP_OS . ' / PHP v' . phpversion();

if (phpversion() >= '4.0.3') {
        $serverinfo .= iif(ini_get('safe_mode'), ' Safe Mode', '');
        $serverinfo .= iif(ini_get('file_uploads'), '', '<br />FILE_UPLOADS disabled');
}

doformheader('', '');
maketableheader('Quick Stats');
makelabelcode('Server Type', $serverinfo);
makelabelcode('MySQL', 'v' . $mysqlversion['version']);
makelabelcode('Database Data Usage:', kbtomb($datasize));
makelabelcode('Database Index Usage:', kbtomb($indexsize));
makelabelcode('Attachment Usage:', kbtomb($attach['size']));
makelabelcode('Custom Avatar Usage:', kbtomb($avatar['size']));

// Only display if the admin has moderation enabled on an active postable forum.
if ($DB_site->query_first("SELECT forumid FROM forum WHERE moderatenew = 1 AND cancontainthreads = 1 AND active = 1 AND allowposting = 1")) {
        $postcount = $DB_site->query_first("SELECT COUNT(*) AS count FROM post WHERE visible=0");
        $threadcount = $DB_site->query_first("SELECT COUNT(*) AS count FROM thread WHERE visible=0");
        makelabelcode("Threads Awaiting <a href=\"../mod/moderate.php?s=$session[sessionhash]&action=posts\">Moderation</a>:", $threadcount['count']);
        makelabelcode("Posts Awaiting <a href=\"../mod/moderate.php?s=$session[sessionhash]&action=posts\">Moderation</a>:", $postcount['count']);
}
if ($moderatenewmembers==1 or $usecoppa==1) {
        $waiting=$DB_site->query_first("SELECT COUNT(*) AS users FROM user WHERE usergroupid=4");
        makelabelcode("Users Awaiting <a href=\"user.php?s=$session[sessionhash]&action=moderate\">Moderation</a>:", $waiting['users']);
}
makelabelcode("Attachments Awaiting <a href=\"../mod/moderate.php?s=$session[sessionhash]&action=attachments\">Moderation</a>:", $attachcount['count']);
makelabelcode('New Users Today:', $newusers['count']);
makelabelcode('Registered Visitors Today:', $users['count']);
makelabelcode('New Threads Today:', $newthreads['count']);
makelabelcode('New Posts Today:', $newposts['count']);
dotablefooter();


JulianD 04-09-2002 05:26 AM

Looks great freddie Installing right now :D

Recluse 04-09-2002 05:38 AM

problem closing the php

Parse error: parse error in /admin/index.php on line 283

line 282 =<?php
line 283 = }

JulianD 04-09-2002 05:42 AM

Yeap.. having the same issue.... :(

JulianD 04-09-2002 05:49 AM

Already fixed:

Replace

PHP Code:

function kbtomb($value) {
    if (
$value == 'N/A') {
        return 
$value;
    } elseif (!
$value) {
        return 
'0.0 MB';
    } else
        return 
sprintf('%.2f'$value 1024000) . ' MB';
    }


with

PHP Code:

function kbtomb($value) {
    if (
$value == 'N/A') {
        return 
$value;
    } elseif (!
$value) {
        return 
'0.0 MB';
    } else {
        return 
sprintf('%.2f'$value 1024000) . ' MB';
    }


( note the extra { )

JulianD 04-09-2002 05:51 AM

BTW, very cool hack, thanks freddie :)

Floris 04-09-2002 05:54 AM

w00h00 freddie :) Thank you kindly for this hack, nice one and I can use it! By the way, nice Admin Control Panel theme you got going there.

FWC 04-09-2002 05:56 AM

Very nice, Freddie! Thanks. :)

Recluse 04-09-2002 06:11 AM

Quote:

Originally posted by JulianD
Already fixed:


( note the extra { )

beat me to it :), thanks for the hack freddie

heres mine

MarkB 04-09-2002 07:09 AM

Very cool! Thanks for the hack, Freddie, and thanks to JulianD for the quick fix :)

Scott MacVicar 04-09-2002 07:40 AM

I've installed this hack and its very handy, to get the size of attachments when they are files?
You could either read through the directory adding the file sizes together or exec("du -sm $attachpath");
Thats the only ways I can think of doing it unless there is a nice php function to get the size of a directory.

Scott

wooolF[RM] 04-09-2002 09:16 AM

]installed, voted 5! very good! :D

TECK 04-09-2002 09:26 AM

great hack. congrats. :)

inetd 04-09-2002 10:09 AM

Good! Super hack! Thanks, freddie!

I have one question: what is Database index usage?

WallStreat 04-09-2002 11:45 AM

Top NOTCH! Simple Yet Handy :)

Freddie Bingham 04-09-2002 01:49 PM

Quote:

Originally posted by inetd
Good! Super hack! Thanks, freddie!

I have one question: what is Database index usage?

Your database takes space for the data and it takes space to maintain the indeces.

MrLister 04-09-2002 01:50 PM

Awsome job! This is extremly useful!

Freddie Bingham 04-09-2002 01:53 PM

I am interested in what is displayed if you are using php < 4.0.3 or INNODB tables in mysql.

Steve Machol 04-09-2002 05:31 PM

Works great! Thanks freddie! :)

Xelation 04-09-2002 05:32 PM

awsome hack! I will install it as soon as I get some time. :)

LouChipher 04-09-2002 05:41 PM

New Threads Today: 8866

the normal statistik says something eles.. hm.. i will search..

g-force2k2 04-09-2002 06:18 PM

Great Job Freddie... looks great... keep up the good hacks ;D

~gforce2001~

Aaow AnD wHiTe 04-09-2002 07:25 PM

Thank you freddie :) Gonna install it now :) BTW.... I smell some of the official v3 colors... ;)

Erwin 04-09-2002 07:30 PM

Sweet. Thanks!

SWFans.net 04-09-2002 07:31 PM

Great hack! :)

I?m curious if there is any way to optimize the database index so that its space allocation is lessened as much as possible?

Freddie Bingham 04-09-2002 07:33 PM

No those colors are from my vb2 forum.

Freddie Bingham 04-09-2002 07:36 PM

Quote:

Originally posted by LouChipher
New Threads Today: 8866

the normal statistik says something eles.. hm.. i will search..

What 'normal statistic' are you referring to? The stats.php that is in the admin panel? I checked and the stats match on my forum.

Freddie Bingham 04-09-2002 07:50 PM

I have the version that supports the attachments as files hack as well as some additional stats / averages. I will post it tonight when I get home.

SWFans.net 04-09-2002 09:14 PM

Quote:

Originally posted by SWFans.net
Great hack! :)

I?m curious if there is any way to optimize the database index so that its space allocation is lessened as much as possible?

Odd. My post should have been number 28 from what I saw of this thread when I replied. @_@

Oh well, nevermind me and my seeing things.

Ian 04-09-2002 09:19 PM

Hmm, do you guys know if it'd be possible to add this hack to the mod control panel?

Vivi Ornitier 04-10-2002 02:51 AM

Exellant hack, very simple and yet very useful

LouChipher 04-10-2002 04:50 PM

I checked the MySQL Query but didn't found any Problem, it must work! Maybe someone has an idea?

Im using vB 2.2.4, PHP 4.4.1 and MySQL 3.23.41

It always says that we have about 8000 new Threads this day.

Code:

$newthreads = $DB_site->query_first("SELECT count(*) AS count FROM thread WHERE dateline >= $starttime");
$newposts = $DB_site->query_first("SELECT count(*) AS count FROM post WHERE dateline >= $starttime");

So this is the same line, but Posts are working, Threads not...!?

Xelation 04-10-2002 08:35 PM

Ah, worked great! this is incrediably useful to me! Thank You Freddie!!

SirSteve 04-11-2002 03:47 AM

Excellent hack! This needs to be in VB3! :)

Freddie Bingham 04-11-2002 04:23 AM

Quote:

Originally posted by SirSteve
Excellent hack! This needs to be in VB3! :)
Maybe it already is? ;)

SirSteve 04-11-2002 04:28 AM

Quote:

Originally posted by freddie
Maybe it already is? ;)
Very cool!! :D

ryanhulce 04-11-2002 05:56 AM

Strange I did what I thought I needed to but it gives me this error

Quote:

Parse error: parse error in /home/clanomn/public_html/omni/admin/index.php on line 106
Here is my admin/index.php

ryanhulce 04-11-2002 06:06 AM

Line 106 in my admin/index.php is

function kbtomb($value) {

FWC 04-11-2002 06:09 AM

Quote:

Originally posted by ryanhulce
Strange I did what I thought I needed to but it gives me this error



Here is my admin/index.php

What did you use for a code editor? Everything is weirdly spaced. The lines are double spaced and the space between function and kbtomb is not a real space. That's causing the parse error. But everything below it has the same problem, too. You need to start over. Also, we're not supposed to post complete vB files. You should delete that attachment.

ryanhulce 04-11-2002 06:18 AM

I copied it using Opera not Internet Explorer and for some reason Opera had it all spaced!! It works great now thanks for helping.


All times are GMT. The time now is 04:47 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.01386 seconds
  • Memory Usage 1,830KB
  • 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
  • (3)bbcode_code_printable
  • (2)bbcode_php_printable
  • (8)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