Subversion Repositories SvarDOS

Rev

Rev 874 | Rev 1157 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 874 Rev 911
Line 3... Line 3...
3
/*
3
/*
4
  pkgnet interface
4
  pkgnet interface
5
  Copyright (C) 2021-2022 Mateusz Viste
5
  Copyright (C) 2021-2022 Mateusz Viste
6
 
6
 
7
 === API ===
7
 === API ===
8
  ?a=pull&p=PACKAGE           downloads the zip archive (svp) containing PACKAGE
8
  ?a=pull&p=PACKAGE[-VER]     downloads the svp archive of PACKAGE (possibly of VER version)
9
  ?a=pull&p=PACKAGE-VER       downloads the zip (svp) containing PACKAGE in version VER
9
  ?a=pullsrc&p=PACKAGE[-VER]  downloads the source zip of PACKAGE (possibly of VER version)
10
  ?a=search&p=PHRASE          list packages that match PHRASE
10
  ?a=search&p=PHRASE[::cat]   list packages that match PHRASE (possibly filtered by cat category)
11
  ?a=checkup                  list of packages+versions in $_POST
11
  ?a=checkup                  list of packages+versions in $_POST
12
*/
12
*/
13
 
13
 
14
 
14
 
15
// messages in different languages (and necessary mappings for codepage conversions)
15
// messages in different languages (and necessary mappings for codepage conversions)
Line 175... Line 175...
175
// search action
175
// search action
176
 
176
 
177
if ($a === 'search') {
177
if ($a === 'search') {
178
  $matches = 0;
178
  $matches = 0;
179
  header('Content-Type: text/plain');
179
  header('Content-Type: text/plain');
-
 
180
 
-
 
181
  // if catfilter present, trim it out of the search term
-
 
182
  $exp_cat = explode('::', $p);
-
 
183
  $p = $exp_cat[0];
-
 
184
  $catfilter = '';
-
 
185
  if (!empty($exp_cat[1])) $catfilter = strtolower($exp_cat[1]);
-
 
186
 
180
  foreach ($db as $pkg => $meta) {
187
  foreach ($db as $pkg => $meta) {
-
 
188
    // apply the category filter, if any
-
 
189
    if (! empty($catfilter)) {
-
 
190
      if (array_search($catfilter, $meta['cats']) === false) continue;
-
 
191
    }
-
 
192
    // look for term
181
    if ((stristr($pkg, $p)) || (stristr($meta['desc'], $p))) {
193
    if ((empty($p)) || (stristr($pkg, $p)) || (stristr($meta['desc'], $p))) {
182
      // fetch first (preferred) version
194
      // fetch first (preferred) version
183
      $prefver_fname = array_key_first($meta['versions']);
195
      $prefver_fname = array_key_first($meta['versions']);
184
      $prefver = array_shift($meta['versions']);
196
      $prefver = array_shift($meta['versions']);
185
      echo str_pad(strtoupper($pkg), 12);
197
      echo str_pad(strtoupper($pkg), 12);
186
      echo str_pad(get_msg('VER', $lang) . " {$prefver['ver']} ", 16);
198
      echo str_pad(get_msg('VER', $lang) . " {$prefver['ver']} ", 16);