<?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\ToolsInterface $tools */
$tools = $container->get(Johncms\Api\ToolsInterface::class);

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

if ($agent_web == 'web') {
   require(ROOT_PATH . 'themes/' . $tools->getSkins() . '/end.php');
} else {

// Рекламный блок сайта
if (!empty($cms_ads[2])) {
    echo '<div class="gmenu">' . $cms_ads[2] . '</div>';
}

echo '</div><div class="fmenu">';

if (isset($_GET['err']) || $headmod != "mainpage" || ($headmod == 'mainpage' && isset($_GET['act']))) {
    echo '<div><a href=\'' . $config->homeurl . '\'>' . $tools->image('menu_home.png') . _t('Home', 'system') . '</a></div>';
}

echo '<div>' . $container->get('counters')->online() . '</div>' .
    '</div>' .
    '<div style="text-align:center">' .
    '<p><b>' . $config->copyright . '</b></p>';

// Счетчики каталогов
$req = $db->query('SELECT * FROM `cms_counters` WHERE `switch` = 1 ORDER BY `sort` ASC');

if ($req->rowCount()) {
    while ($res = $req->fetch()) {
        $link1 = ($res['mode'] == 1 || $res['mode'] == 2) ? $res['link1'] : $res['link2'];
        $link2 = $res['mode'] == 2 ? $res['link1'] : $res['link2'];
        $count = ($headmod == 'mainpage') ? $link1 : $link2;

        if (!empty($count)) {
            echo $count;
        }
    }
}

// Рекламный блок сайта
if (!empty($cms_ads[3])) {
    echo '<br />' . $cms_ads[3];
}

/*
-----------------------------------------------------------------
ВНИМАНИЕ!!!
Данный копирайт нельзя убирать в течение 90 дней с момента установки скриптов
-----------------------------------------------------------------
ATTENTION!!!
The copyright could not be removed within 90 days of installation scripts
-----------------------------------------------------------------
*/

if (!$OpMin) {
echo '<script type="text/javascript"> 
function showLoadingOnSubmit(){
document.getElementById(\'btnSubmit1\').style.display=\'none\';
document.getElementById(\'btnSubmit2\').style.display=\'inline-block\';
document.getElementById(\'loading\').style.display=\'block\';return true;
}
</script>';
echo '<form action="" method="post" onsubmit="showLoadingOnSubmit();">
			<button type="submit" class="aan-red" name="web" id="btnSubmit1" style="font-size:x-small"/>Dekstop Views</button>
          <button type="submit" class="aan-red" name="web" id="btnSubmit2" style="display:none;font-size:x-small"/> <i class="icon-spinner icon-spin"></i> Dekstop </button>
		</form>';
} else {
echo '<form action="" method="post">
			<input type="submit" name="web" value="Decstop Views" style="font-size:x-small" />
		</form>';
}

echo '<div><small>&copy; <a href="http://johncms.com">JohnCMS</a></small></div>' .
    '</div>';

if ($config['LoadPage'] == '4') {
   echo '</div>';
}
### Tips 1000 = 1 second
if ($config['LoadPage'] == '3') {
echo '<script type="text/javascript">setTimeout(function(){$("html").removeClass("load-page");},2000);</script>';
}
echo '</body></html>';
}