") === false && strpos($_GET['q'], ">") === false) { $q = $_GET['q']; } else { header("Location: /"); die(); } $_TITLE = "Search Results"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/header.php"; $orig = getArticlesList(); $list = []; $words = explode(' ', $q); $index = 0; foreach ($words as $word) { if (!ctype_alnum($word)) { header("Location: /"); die(); } } foreach ($orig as $article) { if (!$article["admin"]) { $item = $article; $add = false; $matches = 0; foreach ($words as $word) { if (substr_count(strtolower($article["title"]), strtolower($word)) > 0) $add = true; if (substr_count(strtolower($article["title"]), strtolower($word)) > 0) $matches += substr_count(strtolower($article["title"]), strtolower($word)); foreach ($article["author"] as $author) { if (substr_count(strtolower($author), strtolower($word)) > 0) $add = true; if (substr_count(strtolower($author), strtolower($word)) > 0) $matches += substr_count(strtolower($author), strtolower($word)); } if (substr_count(strtolower($article["category"]), strtolower($word)) > 0) $add = true; if (substr_count(strtolower($article["category"]), strtolower($word)) > 0) $matches += substr_count(strtolower($article["category"]), strtolower($word)); if (substr_count(strtolower($article["content"]["clean"]), strtolower($word)) > 0) $add = true; if (substr_count(strtolower($article["content"]["clean"]), strtolower($word)) > 0) $matches += substr_count(strtolower($article["content"]["clean"]), strtolower($word)); if (substr_count(strtolower($article["date"]), strtolower($word)) > 0) $add = true; if (substr_count(strtolower($article["date"]), strtolower($word)) > 0) $matches += substr_count(strtolower($article["date"]), strtolower($word)); } if ($add) { $list[$index]["matches"] = $matches; $list[$index]["content"] = '
= count($list) ?> result= count($list) > 1 ? "s" : "" ?> found