1 (edited by cuteseal 2006-01-16 04:06)

Topic: Stats: Topics and Posts in last 24 hours

Hope this hasn't been done before, but just wanted to post a quick mod to show the number of posts and topics in the last 24 hours.  I find it handy to know how active my forums have been on a day to day basis...

Demo here: http://www.shuttertalk.com/forums/index.php (scroll down to the bottom)

forums/index.php:

1.  Find ~ Line 160:

$result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());
list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result);

2.  Add below:

$lastday = time() - (24 * 60 * 60);
$result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'posts WHERE posted > '.$lastday) or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());
list($stats['day_posts']) = $db->fetch_row($result);

$result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'topics WHERE posted > '.$lastday) or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());
list($stats['day_topics']) = $db->fetch_row($result);

3.  Find (~ Line 170)

            <dl class="conr">
                <dt><strong><?php echo $lang_index['Board stats'] ?></strong></dt>
                <dd><?php echo $lang_index['No of users'].': <strong>'. $stats['total_users'] ?></strong></dd>
                <dd><?php echo $lang_index['No of topics'].': <strong>'.$stats['total_topics'] ?></strong></dd>
                <dd><?php echo $lang_index['No of posts'].': <strong>'.$stats['total_posts'] ?></strong></dd>
            </dl>
            <dl class="conl">
                <dt><strong><?php echo $lang_index['User info'] ?></strong></dt>
                <dd><?php echo $lang_index['Newest user'] ?>: <a href="profile.php?id=<?php echo $stats['last_user']['id'] ?>"><?php echo pun_htmlspecialchars($stats['last_user']['username']) ?></a></dd>

4.  Replace with:

            <dl class="conr">
                <dt><strong><?php echo $lang_index['Board stats'] ?></strong></dt>
                <dd><?php echo 'Topics in last 24 hours'.': <strong>'.$stats['day_topics'] ?></strong></dd>
                <dd><?php echo 'Posts in last 24 hours'.': <strong>'.$stats['day_posts'] ?></strong></dd>
                <dd><?php echo $lang_index['No of topics'].': <strong>'.$stats['total_topics'] ?></strong></dd>
                <dd><?php echo $lang_index['No of posts'].': <strong>'.$stats['total_posts'] ?></strong></dd>
            </dl>
            <dl class="conl">
                <dt><strong><?php echo $lang_index['User info'] ?></strong></dt>
                <dd><?php echo $lang_index['No of users'].': <strong>'. $stats['total_users'] ?></strong></dd>
                <dd><?php echo $lang_index['Newest user'] ?>: <a href="profile.php?id=<?php echo $stats['last_user']['id'] ?>"><?php echo pun_htmlspecialchars($stats['last_user']['username']) ?></a></dd>

Hope you find it useful!

Cheers,
Jules

Digital photography news, reviews, discussions and more!
http://www.shuttertalk.com

The online bible for all
http://www.publicbible.com