<?php
/*
 * JohnCMS NEXT Mobile Content Management System (http://johncms.com)
 *
 * For copyright and license information, please see the LICENSE.md
 * Installing the system or redistributions of files must retain the above copyright notice.
 *
 * @link        http://johncms.com JohnCMS Project
 * @copyright   Copyright (C) JohnCMS Community
 * @license     GPL-3
 */

defined('_IN_JOHNCMS') or die('Error: restricted access');

/** @var Psr\Container\ContainerInterface $container */
$container = App::getContainer();

/** @var PDO $db */
$db = $container->get(PDO::class);

/** @var Johncms\Api\UserInterface $systemUser */
$systemUser = $container->get(Johncms\Api\UserInterface::class);

/** @var Johncms\Api\ToolsInterface $tools */
$tools = $container->get(Johncms\Api\ToolsInterface::class);

require('../system/head.php');

echo '<div class="mainblok"><div class="phdr"><a href="index.php"><b>' . _t('forum') . '</b></a> | ' . $lng['moders'] . '</div>';
$req = $db->query("SELECT * FROM `forum` WHERE `type` = 'f' ORDER BY `realid`");
while ($f1 = $req->fetch()) {
    $mod = $db->query("select * from `forum` where type='a' and refid='" . $f1['id'] . "'");
    $mod2 = $mod->rowCount();
    if ($mod2 != 0) {
        echo $i % 2 ? '<div class="list2">' : '<div class="list1">';
        echo '<b>' . $f1['text'] . '</b><br />';
        while ($mod1 = $mod->fetch()) {
            $uz = $db->query("select * from `users` where name='" . $mod1['from'] . "';");
            $uz1 = $uz->fetch();
            if ($uz1['rights'] == 3) {
                if ((!empty($_SESSION['uid'])) && ($systemUser->name != $mod1['from'])) {
                    echo '<a href="../profile/?user=' . $uz1['id'] . '">' . $mod1['from'] . '</a>';
                } else {
                    echo $mod1['from'];
                }
            }
        }
        echo '</div>';
        ++$i;
    }
}
echo '<div class="phdr"><a href="index.php?id=' . $id . '">' . _t('Back') . '</a></div></div>';
?>