<?php
/***************************************************************************
 *                             forum_status.php
 *                            -------------------
 *   begin                : Saturday, Apr 8, 2006
 *   copyright            : (C) 2006 NeoCom Ltd.
 *   support              : http://www.neocom.ca/forum/
 *   Designed by          : Boris Maisuradze
 *
 *   Frontend             : Windows executable forumstat.exe
 *                        : The latest release at http://www.neocom.ca/forum/
 ***************************************************************************/

/***************************************************************************
 *
 *   This file has to be uploaded into the phpBB installation directory.
 *
***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/


include('config.php');

echo('Database Status:');

$dbcnx = @mysql_connect($dbhost,$dbuser,$dbpasswd);
if (!$dbcnx)
    echo("Not reachable\n");
else {
    if (!@mysql_select_db($dbname))
        echo("Cannot Open\n");
    else {
        echo("OK\n");
//============================
        echo('Number of posts:');
        $sql='SELECT COUNT(*) AS NUMBER FROM phpbb_posts';
        $result = @mysql_query($sql);
        if (!$result)
            echo("ERROR\n");
        else {
      	    $row = @mysql_fetch_array($result);
      	    echo($row['NUMBER'] . "\n");
        }
//============================
        echo('Number of topics:');
        $sql='SELECT COUNT(*) AS NUMBER FROM phpbb_topics';
        $result = @mysql_query($sql);
        if (!$result)
            echo("ERROR\n");
        else {
      	    $row = @mysql_fetch_array($result);
      	    echo($row['NUMBER'] . "\n");
        }
//============================
        echo('Number of users:');
        $sql='SELECT COUNT(*) AS NUMBER FROM phpbb_users WHERE user_id <>-1';
        $result = @mysql_query($sql);
        if (!$result)
            echo("ERROR\n");
        else {
      	    $row = @mysql_fetch_array($result);
      	    echo($row['NUMBER'] . "\n");
        }
//============================
        echo('Number of active users:');
        $sql='SELECT COUNT(*) AS NUMBER FROM phpbb_users WHERE user_active=1 AND  user_id <> -1';
        $result = @mysql_query($sql);
        if (!$result)
            echo("ERROR\n");
        else {
      	    $row = @mysql_fetch_array($result);
      	    echo($row['NUMBER'] . "\n");
        }
//============================
        echo('Number of votes:');
        $sql='SELECT SUM(vote_result) AS NUMBER FROM phpbb_vote_results';
        $result = @mysql_query($sql);
        if (!$result)
            echo("ERROR\n");
        else {
      	    $row = @mysql_fetch_array($result);
      	    echo($row['NUMBER'] . "\n");
        }
    }
}
echo("\n");
?>