CuteNews is an ancient news CMS that has not seen an update in years and it's support forums are dead. I have experience with it from long ago and I decided to make a website (a diary of sorts) where I upload daily stuff. My site is ready, I have been using it for a while now (over 160 articles), fixed some deprecated php errors (by trial and error, because I'm an absolute ape), but there is one thing that I cannot figure out by myself. So CuteNews has a feature where you can archive your news/articles and then when you search for something there's a checkbox to search in the archives. I tried everything and it just won't work. I'm using PHP Version 7.4.29, if I had to guess its something to do with that. I have not modified any related files, been looking at the code all day and I'm almost ready to throw in the towel and give up on archiving. If you can please take a look at the attached .txt file and tell me if you see anything wrong.
// Variables by default
list($template, $dosearch, $search, $user, $archives) = GET('template, dosearch, search, user, archives');
list($search_st, $number, $category_exclude) = GET('search_st, number, category_exclude', 'GPG');
list($_fd, $_fm, $_fy) = GET('from_date_day, from_date_month, from_date_year');
list($_td, $_tm, $_ty) = GET('to_date_day, to_date_month, to_date_year');
Both $user and $archives do not seem to be working. Otherwise the search functions properly.
if ($dosearch)
{
$mc_start = microtime(true);
// Remove parameters for go to news from searchbox
$_static_qr = 'dosearch,archives,search,from_date_year,from_date_month,from_date_day,to_date_year,to_date_month,to_date_day,search_st,number,archive,template';
$st = -1;
$_next_link = FALSE;
$_number = $number;
$archive_id = 0;
// get archive list
$_list_archives = db_get_archives();
krsort($_list_archives);
reset($_list_archives);
$news = db_index_load('');
$c_time = ctime();
$itemid = 0;
if (strlen($search) < 3)
{
echo "<div>Too short request!</div>";
}
else
{
$block = '';
$found = 0;
do
{
reset($news);
// repeat, while data exists
while ($news)
{
// pop top element
$id = key($news);
unset($news[$id]);
if ($id > $c_time) continue;
if ($id < $date_from || $id > $date_to) continue;
$nbp = db_get_nloc($id);
if ($block !== $nbp)
$ent = db_news_load($block = $nbp);
// @syslog internal error
if (empty($ent)) continue;
$item = $ent[$id];
// Check category (exclude for search)
if ($item['c']) {
$categories = explode(',', $item['c']);
if (isset($category_exclude) && array_intersect($categories, $category_exclude)) {
continue;
}
}
$MB = function_exists('mb_strtolower');
$Ts = $MB ? mb_strtolower($item['t'], 'UTF-8') : strtolower($item['t']);
$Fs = $MB ? mb_strtolower($item['f'], 'UTF-8') : strtolower($item['f']);
$Ss = $MB ? mb_strtolower($item['s'], 'UTF-8') : strtolower($item['s']);
$_query = spsep($search, ' ');
foreach ($_query as $_id => $_val) $_query[$_id] = preg_quote($_val, '/');
// By user, but user not match
if ($user && !$user != $item['u'])
continue;
// Query string not found
if (!preg_match('/'.join('.*?', $_query).'/uis', $Fs . $Ss . $Ts))
continue;
$st++;
if ($st < $search_st) continue;
if ($found == 0)
echo "<p class='cutenews_found_news'>".i18n('Search results for')." "".cn_htmlspecialchars($search).""</p><div class='cn_search_body'>";
$found++;
$title = cn_htmlspecialchars($item['t']);
// Call: id, archiveid, template
if (getoption('rw_engine'))
{
$url = cn_rewrite('full_story', cn_put_alias($id));
if (getoption('search_hl')) $url .= "?qhl=".urlencode($search);
}
else
{
if (getoption('search_hl'))
$url = cn_url_modify($_static_qr, 'id='.$id, "qhl=".urlencode($search));
else
$url = cn_url_modify($_static_qr, 'id='.$id);
}
$itemid++;
echo "<div class='cutenews_search_item'>$itemid <b><a href='$url'>$title</a></b> (". date("d F, Y", $id) .")</div>";
$_number--;
if ($_number == 0)
{
$_next_link = TRUE;
break 2;
}
}
// Next archive, if present
if ($archives && count($_list_archives))
{
$archive_id = key($_list_archives);
// Load ID from archives
$news = array_keys(db_index_load("archive-$archive_id"));
krsort($news);
unset($_list_archives[$archive_id]);
}
// Only in active news, or no archives left
else break;
}
while (TRUE);
// show results ------------
if (!$found)
{
echo "<p class='cutenews_not_match'>".i18n('There are no news articles matching your search criteria')."</p>";
}
else
{ // Close "cn_search_body"
echo "</div>";
}
echo '<div class="cn_paginate_search">';
$__PHP_SELF = $PHP_SELF; $PHP_SELF = $_SERVER['SCRIPT_NAME'];
if ($search_st - $number >= 0 && $number) echo ' <a href="'.cn_url_modify('search_st='.($search_st - $number)).'"><< Prev</a> ';
if ($search_st) echo ' (skip <b class="search_skip">'.$search_st.'</b> items) ';
if ($_next_link) echo ' <a href="'.cn_url_modify('search_st='.($search_st + $number)).'">Next >></a>';
$PHP_SELF = $__PHP_SELF; unset($__PHP_SELF);
echo '</div>';
}
echo '<p class="cutenews_search_results"><i>'.i18n('Search performed for').' '.round(microtime(true) - $mc_start, 4).' s.</i></p>';
}
return TRUE;
search.txt