<?php
    $GLOBALS['highlight'] = 'forum';

    if (language() == 'french')
    {
        define('SHOW_COMMUNITY_COMMUNITY', 'Les Communaut�s');
        define('SHOW_COMMUNITY_NEW', 'nouveau');
        define('SHOW_COMMUNITY_TOTAL', 'total');
        define('SHOW_COMMUNITY_THREADS', 'Threads');
        define('SHOW_COMMUNITY_MESSAGES', 'Messages');
    }
    else
    {
        define('SHOW_COMMUNITY_COMMUNITY', 'Communities');
        define('SHOW_COMMUNITY_NEW', 'new');
        define('SHOW_COMMUNITY_TOTAL', 'total');
        define('SHOW_COMMUNITY_THREADS', 'Threads');
        define('SHOW_COMMUNITY_MESSAGES', 'Messages');
    }

    include('include/parts/header.php');
    
    echo box_outside_top(SHOW_COMMUNITY_COMMUNITY);
    $i = 0;
    $community = mysqli_query_logged("SELECT * FROM community ORDER BY community_id");
    while ($community_row = mysqli_fetch_array($community))
    {
        $community_forums_row = mysqli_fetch_assoc(mysqli_query_logged("SELECT SUM(forum_threads) AS forum_threads, SUM(forum_messages) AS forum_messages FROM community_forums WHERE section_id IN (SELECT section_id FROM community_sections WHERE community_id = '" . $community_row['community_id'] . "')"));
        if ($i++)
        {
            echo '<div style="padding: 5px 0px 0px 0px;"></div>';
        }
        echo box_inside_top();
        echo '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>';
        echo '<td align="left" style="font-size: 14px; font-weight: bold;"><a href="?s=community&i=' . $community_row['community_id'] . '">' . htmlspecialchars($community_row['community_name']) . '</a></td>';
        echo '<td width="100" align="right" style="padding-right: 5px;">' . SHOW_COMMUNITY_THREADS . ':<br />' . SHOW_COMMUNITY_MESSAGES . ':</td>';
        echo '<td width="100">';
        echo '<b>' . $community_forums_row['forum_threads'] . '</b> ' . SHOW_COMMUNITY_TOTAL . '<br />';
        echo '<b>' . $community_forums_row['forum_messages'] . '</b> ' . SHOW_COMMUNITY_TOTAL;
        echo '</td>';
        echo '</tr></table>';
        echo box_inside_bottom();
    }
    echo box_outside_bottom();

    include('include/parts/footer.php');
?>