mirror of
https://github.com/danpros/htmly.git
synced 2026-04-19 12:06:22 +05:30
three-character minimum for $keyword
system/includes/functions.php: add function to limit $keyword to three, or more, characters; cleanup themes/doks/main.html.php: remove color <span>
This commit is contained in:
parent
5d873dceec
commit
a88411150d
2 changed files with 37 additions and 32 deletions
|
|
@ -1319,35 +1319,38 @@ function get_frontpage()
|
|||
// Return search page.
|
||||
function get_keyword($keyword, $page, $perpage)
|
||||
{
|
||||
$posts = get_blog_posts();
|
||||
if (strlen($keyword) >= 3) { // three-character minimum
|
||||
|
||||
$tmp = array();
|
||||
$posts = get_blog_posts();
|
||||
|
||||
foreach ($posts as $index => $v) {
|
||||
$tmp = array();
|
||||
|
||||
$filepath = $v['dirname'] . '/' . $v['basename'];
|
||||
foreach ($posts as $index => $v) {
|
||||
|
||||
$findRxWhole = '\b' . preg_quote($keyword, '~') . '\b'; // Add word boundaries (find whole-words only)
|
||||
$filepath = $v['dirname'] . '/' . $v['basename'];
|
||||
|
||||
$findRx = "~{$findRxWhole}~iu"; // Case-insensitive and UTF-8 mode
|
||||
$findRxWhole = '\b' . preg_quote($keyword, '~') . '\b'; // whole-words only
|
||||
|
||||
$lines = file($filepath);
|
||||
$findRx = "~{$findRxWhole}~iu"; // Case-insensitive and UTF-8 mode
|
||||
|
||||
foreach ($lines as $line) {
|
||||
if (preg_match ($findRx, $line)) {
|
||||
if (!in_array($v, $tmp)) {
|
||||
$tmp[] = $v;
|
||||
$lines = file($filepath);
|
||||
|
||||
foreach ($lines as $line) {
|
||||
if (preg_match ($findRx, $line)) {
|
||||
if (!in_array($v, $tmp)) {
|
||||
$tmp[] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($tmp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $tmp = get_posts($tmp, $page, $perpage);
|
||||
|
||||
}
|
||||
|
||||
if (empty($tmp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $tmp = get_posts($tmp, $page, $perpage);
|
||||
|
||||
}
|
||||
|
||||
// Get related posts base on post category.
|
||||
|
|
@ -1513,32 +1516,34 @@ function get_tagcount($var)
|
|||
// Return search result count
|
||||
function keyword_count($keyword)
|
||||
{
|
||||
$posts = get_blog_posts();
|
||||
if (strlen($keyword) >= 3) { // three-character minimum
|
||||
|
||||
$tmp = array();
|
||||
$posts = get_blog_posts();
|
||||
|
||||
foreach ($posts as $index => $v) {
|
||||
$tmp = array();
|
||||
|
||||
$filepath = $v['dirname'] . '/' . $v['basename'];
|
||||
foreach ($posts as $index => $v) {
|
||||
|
||||
$findRxWhole = '\b' . preg_quote($keyword, '~') . '\b'; // Add word boundaries (find whole-words only)
|
||||
$filepath = $v['dirname'] . '/' . $v['basename'];
|
||||
|
||||
$findRx = "~{$findRxWhole}~iu"; // Case-insensitive and UTF-8 mode
|
||||
$findRxWhole = '\b' . preg_quote($keyword, '~') . '\b'; // whole-words only
|
||||
|
||||
$lines = file($filepath);
|
||||
$findRx = "~{$findRxWhole}~iu"; // Case-insensitive and UTF-8 mode
|
||||
|
||||
foreach ($lines as $line) {
|
||||
if (preg_match ($findRx, $line)) {
|
||||
if (!in_array($v, $tmp)) {
|
||||
$tmp[] = $v;
|
||||
$lines = file($filepath);
|
||||
|
||||
foreach ($lines as $line) {
|
||||
if (preg_match ($findRx, $line)) {
|
||||
if (!in_array($v, $tmp)) {
|
||||
$tmp[] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tmp = array_unique($tmp, SORT_REGULAR);
|
||||
|
||||
return count($tmp);
|
||||
$tmp = array_unique($tmp, SORT_REGULAR);
|
||||
return count($tmp);
|
||||
}
|
||||
}
|
||||
|
||||
// Return recent posts lists
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue