<?php

/*
 * @name        JMY CMS
 * @link        https://jmy.su/
 * @copyright   Copyright (C) 2012-2025 JMY LTD
 * @license     LICENSE.txt (see attached file)
 * @version     VERSION.txt (see attached file)
 * @author      Komarov Ivan
 * @edited      Orlov Alexsey
 */

if (!defined('ACCESS')) {
    header('Location: /');
    exit;
}
global $core, $lang;
$query = isset($_POST['query']) ? filter(utf_decode($_REQUEST['query']), 'a') : '';
$query = isset($url[1]) && empty($query) ? $url[1] : $query;
$type = isset($_POST['type']) ? filter(utf_decode($_REQUEST['query']), 'a') : '';
$search = false;
set_title(array($lang['search'], $query));
$type = 'form';
$core->tpl->open();
$core->tpl->loadFile('search/search-' . $type);
$core->tpl->setVar('QUERY', !empty($query) ? $query : '');
$core->tpl->end();
$core->tpl->close();
if (!empty($query) && mb_strlen($query) >= 3) foreach (glob(ROOT . 'usr/modules/*/search.php') as $file) include($file);
if (empty($query)) $core->tpl->info($lang['search_fail']);
if (!empty($query) && mb_strlen($query) < 3) $core->tpl->info($lang['search_error']);