summaryrefslogtreecommitdiff
path: root/web-scripts/todos.php
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-02-01 11:54:49 +0100
committerErich Eckner <git@eckner.net>2018-02-01 11:54:49 +0100
commit296fc3012f41fd1380dec4a955b287dbb305f7ea (patch)
treec1d5f183a28556cd1c8a6c857cdcd5da1b8abb20 /web-scripts/todos.php
parent8d3d7cabdad3b873722064632968f3ce916b3e99 (diff)
downloadbuilder-296fc3012f41fd1380dec4a955b287dbb305f7ea.tar.xz
web-scripts/todos.php new
Diffstat (limited to 'web-scripts/todos.php')
-rw-r--r--web-scripts/todos.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/web-scripts/todos.php b/web-scripts/todos.php
new file mode 100644
index 0000000..6c3b555
--- /dev/null
+++ b/web-scripts/todos.php
@@ -0,0 +1,62 @@
+<?php
+
+$mysql = new mysqli("localhost", "webserver", "empty", "buildmaster");
+if ($mysql->connect_error) {
+ die("Connection failed: " . $mysql->connect_error);
+}
+
+$result = $mysql -> query(
+ "SELECT DISTINCT " .
+ "`todos`.`id`," .
+ "`todos`.`file`," .
+ "`todos`.`line`," .
+ "`todos`.`description` " .
+ "FROM `todos`;"
+);
+
+if ($result -> num_rows > 0) {
+
+ while ($row = $result->fetch_assoc())
+ $knot_rows[$row["id"]] =
+ $row["file"]. " (line ".$row["line"]."):\\n".$row["description"];
+
+ unset($knots);
+ foreach ($knot_rows as $knot)
+ $knots=$knots . "\"" . $knot . "\";\n";
+
+}
+
+$result = $mysql -> query(
+ "SELECT DISTINCT " .
+ "`todo_links`.`dependent`," .
+ "`todo_links`.`depending_on` " .
+ "FROM `todo_links`;"
+);
+
+if ($result -> num_rows > 0) {
+ $count = 0;
+ while ($row = $result->fetch_assoc()) {
+ $link_rows[$count]["dependent"] =
+ $knot_rows[$row["dependent"]];
+ $link_rows[$count]["depending_on"] =
+ $knot_rows[$row["depending_on"]];
+ $count++;
+ }
+
+ unset($edges);
+ foreach ($link_rows as $link)
+ $edges=$edges . "\"" . $link["depending_on"] . "\" -> \"" . $link["dependent"] . "\";\n";
+}
+
+header ("Content-type: image/png");
+passthru(
+ "dot -Tpng -o/dev/stdout /dev/stdin <<EOF\n".
+ "digraph dependencies {\n" .
+ "fontname=dejavu;\n" .
+ $knots .
+ $edges .
+ "}\n" .
+ "EOF\n"
+);
+
+?>