aboutsummaryrefslogtreecommitdiff
path: root/web/funcs.inc.php
blob: a44a3c6648189e8af876d3d145814ac62dbed7a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
include(dirname(__FILE__) . "/../web/config.inc.php");
include(dirname(__FILE__) . "/../web/db.inc.php");

$buildresultdir = $maindir . "/results/";

function bab_header($title)
{
  echo "<html>\n";
  echo "<head>\n";
  echo "  <title>$title</title>\n";
  echo "  <link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\"/>\n";
  echo "  <link rel=\"alternate\" href=\"rss.php\" title=\"Autobuild Buildroot results\" type=\"application/rss+xml\" />\n";
  echo "</head>\n";
  echo "<body>\n";
  echo " <h1>$title</h1>\n";
}

function bab_footer()
{
  echo "<p style=\"width: 90%; margin: auto; text-align: center; font-size: 60%; border-top: 1px solid black; padding-top: 5px;\">\n";
  echo "<a href=\"http://buildroot.org\">About Buildroot</a>&nbsp;-&nbsp;";
  echo "<a href=\"rss.php\">RSS feed of build results</a>&nbsp;-&nbsp;";
  echo "<a href=\"stats.php\">build stats</a>&nbsp;-&nbsp;";
  echo "<a href=\"stats/\">package stats</a>&nbsp;-&nbsp;";
  echo "<a href=\"toolchains/\">toolchain configs</a>&nbsp;-&nbsp;";
  echo "<a href=\"http://git.buildroot.net/buildroot-test/plain/utils/br-reproduce-build\">Script to reproduce a build</a>\n";
  echo "</p>\n";
  echo "</body>\n";
  echo "</html>\n";
}

/*
 * Returns the total number of results.
 */
function bab_total_results_count()
{
  $db = new db();
  $sql = "select count(*) from results;";
  $ret = $db->query($sql);
  if ($ret == FALSE) {
    echo "Something's wrong in here\n";
    return;
  }

  $ret = mysql_fetch_array($ret);
  return $ret[0];
}

/*
 * Returns an array containing the build results starting from $start,
 * and limited to $count items. The items starting with $start=0 are
 * the most recent build results.
 */
function bab_get_results($start=0, $count=100, $filter_status=-1, $filter_arch="", $filter_reason="", $filter_submitter="", $filter_libc="", $filter_static="", $filter_subarch="")
{
  $db = new db();
  $where_parts = array();
  if ($filter_status != -1)
    $where_parts[] = " status=" . $db->quote_smart($filter_status) . " ";
  if ($filter_arch != "")
    $where_parts[] = " arch=" . $db->quote_smart($filter_arch) . " ";
  if ($filter_reason != '')
    $where_parts[] = " reason=" . $db->quote_smart($filter_reason) . " ";
  if ($filter_submitter != '')
    $where_parts[] = " submitter=" . $db->quote_smart($filter_submitter) . " ";
  if ($filter_libc != '')
    $where_parts[] = " libc=" . $db->quote_smart($filter_libc) . " ";
  if ($filter_static != '')
    $where_parts[] = " static=" . $db->quote_smart($filter_static) . " ";
  if ($filter_subarch != '')
    $where_parts[] = " subarch=" . $db->quote_smart($filter_subarch) . " ";
  if (count($where_parts)) {
    $condition = "where " . implode("and", $where_parts);
  } else {
    $condition = "";
  }
  $sql = "select * from results $condition order by builddate desc limit $start, $count;";
  $ret = $db->query($sql);
  if ($ret == FALSE) {
    echo "Something's wrong with the SQL query\n";
    return;
  }

  return $ret;
}

function bab_get_path($identifier, $file="") {
  return "results/" . substr($identifier, 0, 3) . "/" . $identifier . "/" . $file;
}

?>