categories.php (1168B)
1 <?php
2
3 include("./config/config.php");
4
5 /* Find Empty categories ---------------------------------------------------- */
6
7 $searchcats = array();
8 foreach (array_keys($categories) as $cid) {
9
10 $currentcat = array();
11
12 /* Loop through search engines and add them to each category */
13 foreach (array_keys($searches) as $sid) {
14
15 /* Skip, if search engine is not in current category */
16 if (array_search($cid, $searches[$sid]["categories"]) === false) {
17 continue;
18 }
19
20 /* Add to current category */
21 array_push($currentcat, $sid);
22 }
23
24 /* Add array of search engines to each category */
25 $searchcats[$cid] = $currentcat;
26
27 if (count($currentcat) < 1) {
28 echo "[WARN] Empty Category found: " . $cid . PHP_EOL;
29 }
30 }
31
32 /* Find non-defined categories ---------------------------------------------- */
33
34 $categorysearch = array();
35 foreach (array_keys($searches) as $sid) {
36
37 foreach ($searches[$sid]["categories"] as $cid) {
38 if (!array_key_exists($cid, $categories)) {
39 echo "[WARN] Undefined category found in " . $sid . ": " . $cid .
40 PHP_EOL;
41 }
42 }
43 }
44