summaryrefslogtreecommitdiff
path: root/list.php
diff options
context:
space:
mode:
Diffstat (limited to 'list.php')
-rw-r--r--list.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/list.php b/list.php
new file mode 100644
index 0000000..24340a8
--- /dev/null
+++ b/list.php
@@ -0,0 +1,41 @@
+<?php
+require_once('conf.php');
+
+$repo = [];
+
+$stmt = $db->prepare(
+ 'SELECT `package`.`id`,`package`.`name`,`url`,`desc`,`author`.`name` ' .
+ 'FROM `package`,`author` ' .
+ 'WHERE `package`.`author_id` = `author`.`id`');
+$stmt->execute();
+$stmt->bind_result($id, $name, $url, $desc, $author);
+while ($stmt->fetch() === true) {
+ $repo[] = [
+ 'id' => $id,
+ 'name' => $name,
+ 'author' => $author,
+ 'desc' => $desc,
+ 'url' => $url,
+ 'versions' => []
+ ];
+}
+$stmt->close();
+
+$stmt = $db->prepare(
+ 'SELECT `major`,`minor`,`revision`,`depends` ' .
+ 'FROM `version` WHERE `package_id`=?');
+$stmt->bind_param('i', $pkg);
+$stmt->bind_result($maj, $min, $rev, $deps);
+for ($i = 0; $i < count($repo); $i++) {
+ $pkg = $repo[$i]['id'];
+ $stmt->execute();
+ while ($stmt->fetch() === true) {
+ $repo[$i]['versions'][] = [
+ 'version' => [$maj, $min, $rev],
+ 'depends' => json_decode($deps)
+ ];
+ }
+ unset($repo[$i]['id']);
+}
+
+print(json_encode($repo));