pub / serci

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

generate_mappings.php (1177B)


      1 <?php
      2 
      3 include("./config/config.php");
      4 
      5 /* Keyword to Search Engine mapping ----------------------------------------- */
      6 
      7 $searchkeys = array();
      8 foreach (array_keys($searches) as $search) {
      9     foreach ($searches[$search]["keywords"] as $keyword) {
     10         $searchkeys[$keyword] = $search;
     11     }
     12 }
     13 
     14 /* Export the mapping to file */
     15 $file = fopen(
     16     $searchkeys_file,
     17     "w"
     18 );
     19 fwrite(
     20     $file,
     21     json_encode($searchkeys)
     22 );
     23 fclose($file);
     24 
     25 /* Category to Search Engine mapping ---------------------------------------- */
     26 
     27 $searchcats = array();
     28 foreach (array_keys($categories) as $category) {
     29 
     30     $currentcat = array();
     31     foreach (array_keys($searches) as $search) {
     32 
     33         /* Skrip, if search engine is not in current category */
     34         if (
     35             array_search($category, $searches[$search]["categories"])
     36             === false
     37         ) {
     38             continue;
     39         }
     40 
     41         /* Add to current category */
     42         array_push($currentcat, $search);
     43     }
     44 
     45     $searchcats[$category] = $currentcat;
     46 }
     47 
     48 /* Export the mapping to file */
     49 $file = fopen(
     50     $searchcats_file,
     51     "w"
     52 );
     53 fwrite(
     54     $file,
     55     json_encode($searchcats)
     56 );
     57 fclose($file);
     58 
     59 ?>