<?php

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

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

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

echo '<div class="Block">
        <div class="Block-tl"></div>
        <div class="Block-tr"></div>
        <div class="Block-bl"></div>
        <div class="Block-br"></div>
        <div class="Block-tc"></div>
        <div class="Block-bc"></div>
        <div class="Block-cl"></div>
        <div class="Block-cr"></div>
        <div class="Block-cc"></div>
        <div class="Block-body">
            <div class="BlockHeader">
                <div class="l"></div>
                <div class="r"></div>
                <div class="header-tag-icon">';
                echo '<div class="t"> ' . _t('Hi', 'system') . ', ' . ($systemUser->id ? '<b>' . $systemUser->name . '</b>!' : _t('Guest', 'system') . '!') . '</div>';
            echo '</div>
            </div><div class="BlockContent">
                    <div class="BlockContent-tl"></div>
                    <div class="BlockContent-tr"></div>
                    <div class="BlockContent-bl"></div>
                    <div class="BlockContent-br"></div>
                    <div class="BlockContent-tc"></div>
                    <div class="BlockContent-bc"></div>
                    <div class="BlockContent-cl"></div>
                    <div class="BlockContent-cr"></div>
                    <div class="BlockContent-cc"></div>
                    <div class="BlockContent-body">
                <div>';
if ($systemUser->id && $systemUser->isValid()) {
echo '<ul>';
$total_photo = $db->query("SELECT COUNT(*) FROM `cms_album_files` WHERE `user_id` = '" . $systemUser->id . "'")->fetchColumn();
$count_input = $db->query("
	SELECT COUNT(*) 
	FROM `cms_mail` 
	LEFT JOIN `cms_contact` 
	ON `cms_mail`.`user_id`=`cms_contact`.`from_id` 
	AND `cms_contact`.`user_id`='" . $systemUser->id . "' 
	WHERE `cms_mail`.`from_id`='" . $systemUser->id . "' 
	AND `cms_mail`.`sys`='0' AND `cms_mail`.`delete`!='" . $systemUser->id . "' 
	AND `cms_contact`.`ban`!='1' AND `spam`='0'")->fetchColumn();
echo '<li>' . $tools->image('contacts.png') . '<a href="'.$config['homeurl'].'/profile/index.php">' . _t('Profile') . '</a></li>' .
    '<li>' . $tools->image('rate.gif') . '<a href="'.$config['homeurl'].'/profile/index.php?act=stat">' . _t('Statistics') . '</a></li>' .
    '<li>' . $tools->image('photo.gif') . '<a href="'.$config['homeurl'].'/album/index.php?act=list">' . _t('Photo Album') . '</a>&#160;(' . $total_photo . ')</li>' .
    '<li>' . $tools->image('guestbook.gif') . '<a href="'.$config['homeurl'].'/profile/index.php?act=guestbook">' . _t('Guestbook') . '</a></li>';
echo '<li>' . $tools->image('np.gif') . '<a href="'.$config['homeurl'].'/profile/notif.php">Notif Forum</a>&#160;(<span class="red">+' . $systemUser->notif_forum . '</span>)</li>';
echo '<li>' . $tools->image('mail-inbox.png') . '<a href="'.$config['homeurl'].'/mail/index.php?act=input">' . _t('Received') . '</a>&nbsp;(' . $count_input . ($new_mail ? '/<span class="red">+' . $new_mail . '</span>' : '') . ')</li>';
echo '<li>' . $tools->image('user-edit.png') . '<a href="'.$config['homeurl'].'/profile/index.php?act=edit">' . _t('Edit Profile') . '</a></li>' .
    '<li>' . $tools->image('lock.png') . '<a href="'.$config['homeurl'].'/profile/index.php?act=password">' . _t('Change Password') . '</a></li>' .
    '<li>' . $tools->image('settings.png') . '<a href="'.$config['homeurl'].'/profile/index.php?act=settings">' . _t('System Settings') . '</a></li>';
if ($systemUser->rights >= 1) {
    echo '<li>' . $tools->image('forbidden.png') . '<span class="red"><a href="'.$config['homeurl'].'/admin/"><b>' . _t('Admin Panel') . '</b></a></span></li>';
}
echo '</ul>';
} else {
echo '<b>Login</b>
		<div align="center">
			<form action="'.$config['homeurl'].'/login.php" method="post">Name:<br/>
				<input type="text" name="n" value="" maxlength="20"/><br/>Password:<br/>
				<input type="password" name="p" maxlength="20"/><br/>
				<input type="checkbox" name="mem" value="1" checked="checked"/>Remember<br/>
				<span class="button-wrapper">
                    <span class="l"> </span>
                    <span class="r"> </span>
				<input class="button" type="submit" value="Login"/></span>
			</form>
		</div>
<div><p>' . $tools->image('lock.png') . '<a href="profile/skl.php?continue">' . _t('Forgot password?', 'system') . '</a></p></div>';
}
		  echo '</div>
            <div class="cleared"></div>
				   </div>
				  </div>
<div class="cleared"></div>
        </div>
</div>';
?>