Topic: Adding further stats to collect in index.php

I was just trying to manually add some code to collect how many spammers/bots I've blocked and show in statistic, but I'm having trouble knowing where to put it in lines 265-304.... or how I select the table "stopforumspam" and/or "url_spam"...

[code=php]
// Collect some statistics from the database
$query = array(
    'SELECT'    => 'COUNT(u.id) - 1',
    'FROM'        => 'users AS u',
    'WHERE'        => 'u.group_id != '.FORUM_UNVERIFIED
);

($hook = get_hook('in_stats_qr_get_user_count')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$stats['total_users'] = $forum_db->result($result);

$query = array(
    'SELECT'    => 'u.id, u.username',
    'FROM'        => 'users AS u',
    'WHERE'        => 'u.group_id != '.FORUM_UNVERIFIED,
    'ORDER BY'    => 'u.registered DESC',
    'LIMIT'        => '1'
);

($hook = get_hook('in_stats_qr_get_newest_user')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$stats['last_user'] = $forum_db->fetch_assoc($result);

$query = array(
    'SELECT'    => 'SUM(f.num_topics), SUM(f.num_posts), SUM(f.stopforumspam)',
    'FROM'        => 'forums AS f'
);

($hook = get_hook('in_stats_qr_get_post_stats')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
list($stats['total_topics'], $stats['total_posts'], $stats['total_stopforumspam']) = $forum_db->fetch_row($result);

$stats_list['no_of_users'] = '<li class="st-users"><span>'.sprintf($lang_index['No of users'], '<strong>'.forum_number_format($stats['total_users']).'</strong>').'</span></li>';
$stats_list['newest_user'] = '<li class="st-users"><span>'.sprintf($lang_index['Newest user'], '<strong>'.($forum_user['g_view_users'] == '1' ? '<a href="'.forum_link($forum_url['user'], $stats['last_user']['id']).'">'.forum_htmlencode($stats['last_user']['username']).'</a>' : forum_htmlencode($stats['last_user']['username'])).'</strong>').'</span></li>';
$stats_list['no_of_topics'] = '<li class="st-activity"><span>'.sprintf($lang_index['No of topics'], '<strong>'.forum_number_format($stats['total_topics']).'</strong>').'</span></li>';
$stats_list['no_of_posts'] = '<li class="st-activity"><span>'.sprintf($lang_index['No of posts'], '<strong>'.forum_number_format($stats['total_posts']).'</strong>').'</span></li>';

($hook = get_hook('in_stats_pre_info_output')) ? eval($hook) : null;

?>
[/code]

What would be best:
Knowing how to easily add via a hook & manifest

2

Re: Adding further stats to collect in index.php

For SFS and Url checker you can use hook ain_items_end and this code

[code=php]            <div class="ct-set group-item<?php echo ++$forum_page['item_count'] ?>">
                <div class="ct-box">
                    <h3 class="ct-legend hn"><span>StopForumSpam.com</span></h3>
                    <ul class="data-list">
<?php
    $query = array(
        'SELECT'    => 'count(*)',
        'FROM'        => 'stopforumspam'
    );
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    list($sfs) = $forum_db->fetch_row($result);
?>
                        <li><span><?php echo $sfs; ?>&nbsp;bots blocked</span></li>
                    </ul>
                </div>
            </div>
            <div class="ct-set group-item<?php echo ++$forum_page['item_count'] ?>">
                <div class="ct-box">
                    <h3 class="ct-legend hn"><span>URL spam checker</span></h3>
                    <ul class="data-list">

<?php
    $query = array(
        'SELECT'    => 'u.username, us.ip, us.url, DATE_FORMAT(us.time, \'%Y-%m-%d\') AS date, us.type',
        'FROM'        => 'url_spam AS us',
        'JOINS'        => array(
            array(
                'LEFT JOIN'    => 'users AS u',
                'ON'        => 'u.id = us.user_id',
            ),
        ),
        'ORDER BY'    => 'time DESC',
    );
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    ?>
   
                        <li><table>
                        <tr><th style="width: 100px;">User</th><th style="width: 70px;">IP</th><th style="width: 300px;">URL</th><th style="width: 70px;">Date</th><th style="width: 50px;">Type</th></tr>
                        <?php
                        while($spam = $forum_db->fetch_assoc($result)) {
                            echo "<tr>";
                                echo "<td>".$spam['username']."</td>";
                                echo "<td>".$spam['ip']."</td>";
                                echo "<td><small>".$spam['url']."</small></td>";
                                echo "<td>".$spam['date']."</td>";
                                echo "<td>".$spam['type']."</td>";
                            echo "</tr>";
                        }
                        ?>
                        </table>
                        <center><i>Last 25 entries. Ordered by date.</i></center></li>
                    </ul>
                </div>
            </div>[/code]

Output is like this (administration index)
http://dl.dropbox.com/u/6232434/PunBB/url_spam%2Bsfs.JPG

Eraversum - scifi browser-based online webgame

Re: Adding further stats to collect in index.php

Brilliant big_smile
See what we've been catching thanks to you:

http://keydogbb.info/img/extpic.png