\n";
$date_search = (Search_Engine::get_param('datelimit') != 0 ? ' AND download_datestamp>='.(TIME - Search_Engine::get_param('datelimit')) : '');
if (Search_Engine::get_param('stype') == 'downloads' || Search_Engine::get_param('stype') == 'all') {
$sort_by = [
'datestamp' => "download_datestamp",
'subject' => "download_title",
'author' => "download_user",
];
$order_by = [
'0' => ' DESC',
'1' => ' ASC',
];
$sortby = !empty(Search_Engine::get_param('sort')) ? "ORDER BY ".$sort_by[Search_Engine::get_param('sort')].$order_by[Search_Engine::get_param('order')] : '';
$limit = (Search_Engine::get_param('stype') != "all" ? " LIMIT ".Search_Engine::get_param('rowstart').",10" : '');
switch (Search_Engine::get_param('fields')) {
case 2:
Search_Engine::search_column('download_title', 'downloads');
Search_Engine::search_column('download_description', 'downloads');
Search_Engine::search_column('download_user', 'downloads');
break;
case 1:
Search_Engine::search_column('download_description', 'downloads');
Search_Engine::search_column('download_title', 'downloads');
break;
default:
Search_Engine::search_column('download_title', 'downloads');
}
if (!empty(Search_Engine::get_param('search_param'))) {
$query = "SELECT td.*,tdc.*
FROM ".DB_DOWNLOADS." td
INNER JOIN ".DB_DOWNLOAD_CATS." tdc ON td.download_cat=tdc.download_cat_id
".(multilang_table("DL") ? "WHERE ".in_group('tdc.download_cat_language', LANGUAGE)." AND " : "WHERE ")
.groupaccess('download_visibility')." AND ".Search_Engine::search_conditions('downloads').$date_search;
$result = dbquery($query, Search_Engine::get_param('search_param'));
$rows = dbrows($result);
} else {
$rows = 0;
}
if ($rows != 0) {
$item_count = "".$rows." ".($rows == 1 ? $locale['d401'] : $locale['d402'])." ".$locale['522']."
\n";
$result = dbquery("SELECT td.*, tdc.*, user_id, user_name, user_status, user_avatar, user_joined, user_level
FROM ".DB_DOWNLOADS." td
INNER JOIN ".DB_DOWNLOAD_CATS." tdc ON td.download_cat=tdc.download_cat_id
LEFT JOIN ".DB_USERS." tu ON td.download_user=tu.user_id
".(multilang_table("DL") ? "WHERE ".in_group('tdc.download_cat_language', LANGUAGE)." AND " : "WHERE ").groupaccess('td.download_visibility')." AND
".Search_Engine::search_conditions('downloads').$date_search.$sortby.$limit, Search_Engine::get_param('search_param'));
$search_result = '';
while ($data = dbarray($result)) {
$timeoffset = timezone_offset_get(timezone_open($settings['timeoffset']), new \DateTime());
if ($data['download_datestamp'] + 604800 > time() + ($timeoffset * 3600)) {
$new = " ".$locale['d403']."";
} else {
$new = "";
}
$text_all = $data['download_description'];
$text_all = Search_Engine::search_striphtmlbbcodes($text_all);
$text_frag = Search_Engine::search_textfrag($text_all);
// $subj_c = Search_Engine::search_stringscount($data['download_title']);
// $text_c = Search_Engine::search_stringscount($data['download_description']);
$context = '';
if ($text_frag != "") {
$context .= "