Subversion Repositories SvarDOS

Rev

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

Rev 345 Rev 559
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
  pkgnet interface
4
  pkgnet interface
5
  Copyright (C) 2021 Mateusz Viste
5
  Copyright (C) 2021-2022 Mateusz Viste
6
 
6
 
7
 === API ===
7
 === API ===
8
  ?a=pull&p=PACKAGE           downloads the zip archive containing PACKAGE
8
  ?a=pull&p=PACKAGE           downloads the zip archive containing PACKAGE
-
 
9
  ?a=pull&p=PACKAGE-VER       downloads the zip containing PACKAGE in version VER
9
  ?a=search&p=PHRASE          list packages that match PHRASE
10
  ?a=search&p=PHRASE          list packages that match PHRASE
10
  ?a=checkup                  list of packages+versions in $_POST
11
  ?a=checkup                  list of packages+versions in $_POST
11
*/
12
*/
12
 
13
 
13
 
14
 
Line 110... Line 111...
110
  $matches = 0;
111
  $matches = 0;
111
  while (($pkg = fgetcsv($handle, 1024, "\t")) !== FALSE) {
112
  while (($pkg = fgetcsv($handle, 1024, "\t")) !== FALSE) {
112
    if ((stristr($pkg[0], $p)) || (stristr($pkg[2], $p))) {
113
    if ((stristr($pkg[0], $p)) || (stristr($pkg[2], $p))) {
113
      echo str_pad(strtoupper($pkg[0]), 12) . str_pad("ver: {$pkg[1]}", 13) . str_pad("size: " . nicesize(filesize($pkg[0] . '.zip')), 13) . "BSUM: " . sprintf("%04X", $pkg[3]) . "\r\n";
114
      echo str_pad(strtoupper($pkg[0]), 12) . str_pad("ver: {$pkg[1]}", 13) . str_pad("size: " . nicesize(filesize($pkg[0] . '.zip')), 13) . "BSUM: " . sprintf("%04X", $pkg[3]) . "\r\n";
114
      echo wordwrap($pkg[2], 79, "\r\n", true);
115
      echo wordwrap($pkg[2], 79, "\r\n", true);
115
      echo "\r\n\r\n";
116
      echo "\r\n";
-
 
117
      // do I have any alt versions?
-
 
118
      $altvers = glob("{$pkg[0]}-*.zip");
-
 
119
      if (!empty($altvers)) {
-
 
120
        $alts = str_replace('.zip', '', $altvers);
-
 
121
        echo wordwrap("[alt versions: " . implode(', ', $alts), 79, "\r\n", true) . "]\r\n";
-
 
122
      }
-
 
123
      echo "\r\n";
116
      $matches++;
124
      $matches++;
117
    }
125
    }
118
  }
126
  }
119
  if ($matches == 0) echo "No matching package found.\r\n";
127
  if ($matches == 0) echo "No matching package found.\r\n";
120
}
128
}