Here's a script I made to show post/topic statistics on my site pages with server side includes.

Coded in TCL, depends on TCL and mysqltcl.

Config script forumstats-config.cgi

#!/usr/bin/tclsh
### CONFIG ###

## Database host
set my_host "host"

## Database name
set my_name "database"

## Username
set my_user "username"

## Password
set my_pass "password"

## Forum stats table name (replace PREFIX with the prefix of your forum tables)
set my_table "PREFIX_forums"

## Forum online stats table name (replace PREFIX with the prefix of your forum tables)
set my_oltable "PREFIX_online"

## Path to direct access attempt log
set dalog "/tmp/stat-da-attempts.text"

## Full path to this script (relative to system, not webserver)
set filename "/var/www/cgi-bin/forumstats-config.cgi"

### END CONFIG ###
if {[string match -nocase $env(SCRIPT_FILENAME) $filename]} {
        set dasock [open $dalog a+]
        puts "Content-type: text/html\n"
        puts "You're not allowed to look at this! Go away!"
        puts $dasock "Direct access attempt from $env(REMOTE_ADDR) on [clock format [clock seconds]]"
        flush $dasock
        close $dasock
}

the main script forumstats.cgi

#!/usr/bin/tclsh
puts "Content-type: text/html\n"
###

source forumstats-config.cgi
package require mysqltcl

set mydb [::mysql::connect -host $my_host -user $my_user -password $my_pass -db $my_name]

set poststats [::mysql::sel $mydb "SELECT num_posts FROM $my_table" -flatlist]
set topicstats [::mysql::sel $mydb "SELECT num_topics FROM $my_table" -flatlist]
set online [::mysql::sel $mydb "SELECT ident FROM $my_oltable" -flatlist]

set totalposts [expr [join $poststats "+"]]
set totaltopics [expr [join $topicstats "+"]]
set avgposts [expr $totalposts/[llength $poststats]]
set avgtopics [expr $totaltopics/[llength $topicstats]]
if {$online == ""} {
        set onlinemsg "No users are currently logged in"
} elseif {[llength $online] == 1} {
        set onlinemsg "OK"
        set onlinecount [llength $online]
        set onlineunits "is user"
} else {
        set onlinemsg "OK"
        set onlinecount [llength $online]
        set onlineunits "are users"
}

puts "<div id=\"forumstats\">"
puts "There are $totalposts posts in $totaltopics topics in [llength $topicstats] forums<br />"
puts "Each forum has an average of $avgposts posts and $avgtopics topics<br />"

if {$onlinemsg != "OK"} {
        puts "$onlinemsg"
} else {
        puts "There [lindex [split $onlineunits] 0] currently $onlinecount [lindex [split $onlineunits] 1] logged in:<br /> \($online\)"
}
puts "</div>"
::mysql::close $mydb

If you change the filename of the config script, don't forget to update the filename on the line in the main script that begins with 'source'. Integrated into site with SSI 'include virtual' directive. Oh, it also uses good grammar for the totals tongue

Hope this helps someone wink

2

(3 replies, posted in PunBB 1.2 show off)

problem i've got on my site is that it uses ssi, for example, the index page is built with the following code (cgi scripts not included, too much code, but you get the idea tongue ):

header (included by main):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!-- HEADER START -->

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        <head>
                <!--#config errmsg="Error in SSI directive, please <a href="mailto:pepolez[at]toxicnantidote.net">tell me</a>" -->
                <!--#set var="root" value="http://www.toxicantidote.net/"-->


                <title>ToxicAntidote IRC network -- <!--#echo var="title" --></title>

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

                <!--#if expr="$desc" -->
<meta name="description" content="<!--#echo var="title"--> : <!--#echo var="desc"-->" />
                <!--#else-->
<meta name="description" content="" />
                <!--#endif-->
                <!--#if expr="$key" -->
<meta name="keywords" content="toxicantidote,irc,network,fun,small,net,ircd,relax,chat,full,of,good,goodness,<!--#echo var="key"--> " />
                <!--#else-->
<meta name="keywords" content="toxicantidote,irc,network,fun,small,net,ircd,relax,chat,full,of,good,goodness" />
                <!--#endif-->

<meta http-equiv="expires" content="Fri, Apr 01 1974 00:00:00 GMT" />
<meta name="last-modified" content="<!--#echo var="LAST_MODIFIED"-->" />
<meta name="robots" content="index,follow" />
<meta name="copyright" content="Distributed under the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License (http://creativecommons.org/licenses/by-nc-sa/2.5/)" />
<meta name="author" content="ToxicAntidote IRC network" />
<meta name="generator" content="gedit 2.14.2 + nano 1.3.10 + quanta css" />

                <!--#if expr="\"$DOCUMENT_NAME\" = \"trivia-answer.shtml\"" -->
<meta http-equiv="refresh" content="3; url=trivia.shtml" />
                <!--#elif expr="\"$DOCUMENT_NAME\" = \"vote-yes.shtml\"" -->
<meta http-equiv="refresh" content="0; url=index.shtml" />
                <!--#elif expr="\"$DOCUMENT_NAME\" = \"vote-no.shtml\"" -->
<meta http-equiv="refresh" content="0; url=index.shtml" />
                <!--#endif-->

                <link href="<!--#echo var="root"-->toxicantidote.css" type="text/css" rel="stylesheet" title="normal text" />

        </head>
        <body>
                <div id="header">
                        <img src="<!--#echo var="root"-->toxicantidote.jpg" alt="ToxicAntidote IRC network" />
                        <br />
                </div>
<!-- HEADER END -->

navigation (included by main):

<!-- NAVIGATION START -->
<div id="nav">
<div class="hovertext">

<div class="smalltext">
This server will be moved to it's new home with it's owner sometime in
July/August. This site, as well as all subdomains (except etmaps due to
it's size) will be mirrored elsewhere during the move. Trying to arrange SQL
servers so forums and albums can stay up, but no promises. Sorry for any
inconvinience.
</div>

<h4>Main:</h4>
<ul>
<li><a href="<!--#echo var="root" -->">Home</a></li>
<li><a href="<!--#echo var="root" -->album/index.php">Albums</a></li>
<li><a href="<!--#echo var="root" -->forums/index.php">Forums</a></li>
<li><a href="<!--#echo var="root" -->links.shtml">External links</a></li>
<li><a href="<!--#echo var="root" -->disclaimer.shtml">Disclaimer</a></li>
<li><a href="<!--#echo var="root" -->sponsors.shtml">Sponsors</a></li>
</ul>

<h4>Users:</h4>
<ul>
<li><a href="http://mail.google.com/hosted/toxicantidote.net/">Webmail login</a></li>
<li><a href="https://mail.google.com/hosted/toxicantidote.net/">Secure webmail login</a></li>
<li><a href="<!--#echo var="root" -->forums/login.php?action=login&redir=http://www.toxicantidote.net/">Login to forums/albums</a></li>
</ul>

<h4>Navigation:</h4>
<ul>
<li><b><a href="index.shtml">Return to category index</a></b></li>
<li><a href="<!--#echo var="root" -->flashg/index.shtml">Flash games</a></li>
<li><a href="<!--#echo var="root" -->flashm/index.shtml">Flash Movies</a></li>
<li><a href="<!--#echo var="root" -->humor/index.shtml">Humor</a></li>
<li><a href="<!--#echo var="root" -->irpg/index.shtml">IdleRPG statistics</a></li>
<li><a href="<!--#echo var="root" -->irc/index.shtml">IRC</a></li>
<li><a href="<!--#echo var="root" -->licenses/index.shtml">Licenses</a></li>
<li><a href="<!--#echo var="root" -->trivia.shtml">Online trivia</a></li>
<li><a href="<!--#echo var="root" -->quotes/index.shtml">Quotes</a></li>
<li><a href="<!--#echo var="root" -->scripts/index.shtml">Scripts</a></li>
<li><a href="<!--#echo var="root" -->tools/index.shtml">Tools</a></li>
<li><a href="<!--#echo var="root" -->trivstats/index.shtml">Trivia statistics</a></li>
<li><a href="<!--#echo var="root" -->unostats/index.shtml">Uno statistics</a></li>
</ul>

<!--#include VIRTUAL="cgi-bin/fuckyahoo.cgi"-->
<div class="smalltext">
Duplicate votes and spider votes will be removed.
</div>

<h4>Forum statistics</h4>
<!--#include VIRTUAL="cgi-bin/forumstats.cgi"-->
</div>

<div id="image">
<h4>Search:</h4>
<!-- SiteSearch Google -->
<form method="get" action="http://www.google.com/search">
<p>
<input type="hidden" name="ie" value="UTF-8" />
<input type="hidden" name="oe" value="UTF-8" />
</p>
<p>
<a class="imglink" href="http://www.google.com/">
<img src="http://www.google.com/logos/Logo_40blk.gif"
alt="Google" /></a>
</p>
<p>
<input type="text" name="q" size="25" maxlength="255" value="" alt="search input" />
<input type="submit" name="btnG" value="Google Search" />
<input type="hidden" name="domains" value="www.toxicantidote.net" /><br />
<input type="radio" name="sitesearch" value="" alt="search the web" /> Search the web<br />
<input type="radio" name="sitesearch" alt="search this site" value="www.toxicantidote.net" checked="checked" />Search ToxicAntidote
</p>
</form>
<!-- SiteSearch Google -->
</div>
</div>
<!-- NAVIGATION END -->

main part:

<!--#set var="title" value="Full of IRC goodness" -->
<!--#set var="desc" value="SSL and IPv6 capable"-->
<!--#set var="key" value="full,of,irc,goodness,ircd,fun,chat,small,net,computers,internet,bbs,technology,radio"-->
<!--#include file="header.shtml" -->
<!--#include file="nav.shtml" -->
<div id="main">
<h3>Our goal</h3>
<p>
Our goal is to provide users with a network where they can escape the
perils and power struggles of large IRC networks to a more relaxed IRC
network. ToxicAntidote is a place where your opinions matter and where
everybody is welcome. Just about anything (except XDCC, unlawful
activities and large botnets) are allowed on the network.
</p>
<hr />
<h3>Looking for links</h3>
<p>
ToxicAntidote is currently looking for servers <b>in Australia</b>. Servers
must be stable, running linux and also running unrealircd (or willing to
change). The server admin and his/her operators must be knowledgeable
(we're not going to hold your hand all the way).
</p>
<p>
Servers must be compiled with ssl and ziplinks support (requires openssl
and zlib) and have port 6667(normal clients), 6697 (ssl) and a linking
port avaliable.
</p>
<p>
This is a link <b>TO</b> the ToxicAntidote IRC network, we are not
looking to join another network, we are looking for servers to join us
and adopt our setup and policies.
</p>
<p>
If applicable, your may still advertise the network with your DNS, but
we ask that this DNS be changed to a CNAME record pointing at
irc.toxicantidote.net to allow load balancing and easy DNS updates.
</p>
<p>
If you're interested, please <a href="mailto:irc[AT]toxicantidote.net">send a message to us</a>.
</p>
<hr />
<!--#include file="news.shtml" -->
<hr />
<h3>Random fortune</h3>
<!--#include VIRTUAL="cgi-bin/fortune.cgi"-->
</div>
<!--#include file="footer.shtml" -->

news (included by main):

<h3>News</h3>
<h4>shack.* delinked (08/06/2006)</h4>
<p>
shack.toxicantidote.net, the UK server, has now delinked from the
network. Neoburner, it's owner, delinked his server because it was using
too much of his resources. Sorry to see your server go Neoburner, just
remember you're always welcome :)
</p>

<h4>Webmail introduction (17/05/2005)</h4>
<p>
Webmail was introduced today to replace the existing mailfowards for
users. Everyone who had a mailfoward has been emailed a login to their
webmail address from which they can send and receive mail. Webmail
system is provided by gmail, so you get a nice interface and 2gb of
storage space. Sorry for any invonvinience.
</p>

<h4>Registration merge (14/05/2006)</h4>
<p>
The registration process for the forums and albums have finally been
merged so that if you register on one, you will be registered on the
other and if you login on one, you will be logged in on the other.

This bridging came with an upgrade to the album system. Enjoy :)
</p>

<h4>Site + home.* downtime (28/04/2006)</h4>
<p>
I apologise for the downtime of home.* and the site yesterday and today.
The downtime was caused by a severed fibre link between our phone post
and the exchange, which meant we (plus several other people) had no
dialtone and no voltage on the line for the duration of the outage.
</p>

<h4>lelijk.* delinked (12/04/2006)</h4>
<p>
sith_mike has decided to delink lelijk.* as he simply doesn't have the
time to administer it anymore. This means ToxicAntidote will no longer
have a Canadian server. We'll miss you mike!
</p>

<h4>Categorized pages (13/03/2006)</h4>
<p>
Today all page categories were given index pages and referred to from
the main navigation to make it easier to navigate. Just click on the
appropriate page category and it will show an index of pages in that
category.
</p>

<h4>Fixed XHTML validation errors (06/03/2006)</h4>

<p>
Today I spent a couple of hours trying to get rid of all the XHTML
validation errors. All validation errors should be gone, but if you find
any or pages display incorrectly, please tell me.
</p>

<h4>Moved out of CMS (26/02/2006)</h4>
<p>
Due to hundreds of XHTML validation errors, and complaints of incorrect
layout, the site has now been taken out of the CMS and put into a series
of SHTML pages. This change means that the site should display
correctly,
reguardless of browser and that the fallback (absence of CSS) is easy to
navigate. The photo albums remain, and I hope to readd forums soon.
</p>
<p>
RSS feeds, weblogs, groups and a few other things have been removed,
although nobody really used them (which was another reason for this
change).
</p>
<p>
Sorry if this big change annoys you, but not changing was quite annoying
as well.
</p>
<p>
I'm still ironing out some bugs in this design, if you find any, please

<a href="mailto:web[at]toxicantidote.net">let me know</a>.
</p>

footer (included by main):

<!-- FOOTER START -->
<div id="footer">
<div class="smalltext">
Questions? Comments? Typos? Bugs? Cool stuff?
<b>web[AT]toxicantidote.net</b>
</div>
<hr />
<a class="imglink" href="http://validator.w3.org/check?uri=referer">
<img style="border:0;width:88px;height:31px" src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" />
</a>
<a class="imglink"
href="http://jigsaw.w3.org/css-validator/validator?uri=http://www.toxicantidote.net/toxicantidote.css">
<img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" />
</a>
<a href="http://www.spreadfirefox.com/?q=affiliates&id=109323&t=71"
class="imglink">
<img alt="Get Firefox!" src="http://sfx-images.mozilla.org/affiliates/Buttons/88x31/safer.gif"/>
</a>
<a href="http://www.searchirc.com/network/ToxicAntidote" class="imglink">
<img src="http://www.toxicantidote.net/searchirc.gif" alt="searchirc irc search engine"/>
</a>
<a href="http://www.mypagerank.net/" class="imglink">
<img src="http://www.mypagerank.net/srank.php?site=www.toxicantidote.net" alt="Google pagerank" />
</a>
 <!-- stat code -->
         <script type="text/javascript">
        var sc_project=680540;
        var sc_invisible=0;
        var sc_partition=5;
        var sc_security="ea3ca1eb";
        </script>

        <script type="text/javascript"
src="http://www.statcounter.com/counter/counter_xhtml.js">
        </script><noscript><div class="statcounter">
        <a class="imglink" href="http://www.statcounter.com/">
        <img class="statcounter" src="http://c6.statcounter.com/counter.php?sc_project=680540&java=0&security=ea3ca1eb&invisible=0" alt="web tracker" />
        </a></div></noscript>
</div>

<!-- FOOTER END -->
</body></html>

the 'fuckyahoo.cgi' include displays a poll assuming the client does not match a yahoo netblock - i had some problems with yahoo spiders not obeying the rel="noindex,nofollow" on the vote links

the 'fortune.cgi' include displays a random fortune

the 'forumstats.cgi' include generates some statistics for the forums

3

(3 replies, posted in PunBB 1.2 show off)

A fairly generic install I've already managed to mangle the style of :x

Time for me to learn some PHP and try to integrate it into my main site smile

http://www.toxicantidote.net/forums/index.php

Open for suggestions

4

(16 replies, posted in PunBB 1.2 show off)

nice and cleanly integrated, good work smile

5

(7 replies, posted in PunBB 1.2 bug reports)

If you feel comfortable doing so, I'd suggest that you simply make your router act as a bridge (i.e. transparently foward all requests to your server) assuming it's your gateway box as well as your server.

6

(5 replies, posted in Feature requests)

Code it as a module then? I for one would love to see this in punBB, it would put my mind at ease.

Just make sure it doesn't generate images in the same way phpBB does, that's been cracked by many many spambots