pub / serci

Search the web with !keywords
git clone https://https://src.jayvii.de/pub/serci.git
Home | Log | Files | Exports | Refs | README | RSS

commit 4fde48ca2fcca6ad2102660f25e3982547263e0c
parent 14f6b40c7cc7cdfda2debf1e816a2f9695bb99c4
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Fri, 18 Oct 2024 11:24:26 +0200

feat: add testing procedure to check configuration

Diffstat:
Atests/categories.php | 44++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+), 0 deletions(-)

diff --git a/tests/categories.php b/tests/categories.php @@ -0,0 +1,44 @@ +<?php + +include("./config/config.php"); + +/* Find Empty categories ---------------------------------------------------- */ + +$searchcats = array(); +foreach (array_keys($categories) as $cid) { + + $currentcat = array(); + + /* Loop through search engines and add them to each category */ + foreach (array_keys($searches) as $sid) { + + /* Skip, if search engine is not in current category */ + if (array_search($cid, $searches[$sid]["categories"]) === false) { + continue; + } + + /* Add to current category */ + array_push($currentcat, $sid); + } + + /* Add array of search engines to each category */ + $searchcats[$cid] = $currentcat; + + if (count($currentcat) < 1) { + echo "[WARN] Empty Category found: " . $cid . PHP_EOL; + } +} + +/* Find non-defined categories ---------------------------------------------- */ + +$categorysearch = array(); +foreach (array_keys($searches) as $sid) { + + foreach ($searches[$sid]["categories"] as $cid) { + if (!array_key_exists($cid, $categories)) { + echo "[WARN] Undefined category found in " . $sid . ": " . $cid . + PHP_EOL; + } + } +} +