diff --git a/buildsite.css b/buildsite.css
index 421402d..6df1a60 100644
--- a/buildsite.css
+++ b/buildsite.css
@@ -53,3 +53,31 @@ a, a:link, a:hover, a:visited, a:active {
text-align: center;
}
+td, th {
+ text-align: left;
+ margin: 0;
+ padding: 3px 20px 3px 3px;
+ vertical-align: top;
+ display: table-cell;
+ border: none;
+}
+
+th {
+ border-bottom: solid 1px #404040;
+ background: url(images/container-bg.gif) top repeat-x;
+}
+
+.build-list {
+ padding: 0;
+ margin: 0;
+ border-spacing: 0;
+ width: 100%;
+ border: solid 1px #404040;
+}
+
+pre {
+ font-family: monospace;
+ font-size: 8pt;
+ white-space: pre-wrap;
+ word-wrap: break-word;
+}
\ No newline at end of file
diff --git a/images/dl.gif b/images/dl.gif
new file mode 100644
index 0000000..e94f1f0
Binary files /dev/null and b/images/dl.gif differ
diff --git a/images/favicon.ico b/images/favicon.ico
new file mode 100644
index 0000000..f145db8
Binary files /dev/null and b/images/favicon.ico differ
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..4b370b2
--- /dev/null
+++ b/index.php
@@ -0,0 +1,103 @@
+ $email, "email" => "");
+ if (preg_match("|([^\<]*)<([^>]*)>|", $email, $m)) {
+ $ret["name"] = trim($m[1]);
+ $ret["email"] = trim($m[2]);
+ }
+ return $ret;
+}
+
+function print_changes($current, $next)
+{
+ global $DB;
+ if ($res = $DB->query(kl_str_sql("select * from revs where id<=!i and id>!i", $current->nr, $next->nr))) {
+ print '
';
+
+ while ($row = $DB->fetchRow($res)) {
+ $author = parse_email($row["author"]);
+ $gid = md5($author["email"]);
+ print '
+
+  ' .
+ htmlspecialchars($author["name"]) . ' |
+ ' . htmlspecialchars($row["hash"]) . ' |
+ ' . htmlspecialchars($row["time"]).
+ ' (' . Layout::since(strtotime($row["time"])) . ' ago) |
+
+
+ ' . htmlspecialchars($row["message"]) . ' |
+
';
+
+ # pre_dump($row);
+ }
+
+ print '
';
+ }
+}
+
+Function print_build($current, $next)
+{
+ print "
+
+ | " . htmlspecialchars($current->nr). " |
+ " . htmlspecialchars($current->modified). " (" . Layout::since(strtotime($current->modified)) . " ago) |
+ " . htmlspecialchars($current->chan). " |
+ Windows Installer
+ Build Log |
+
";
+ if ($next) {
+ print '| ';
+ print_changes($current, $next);
+ print " |
";
+ }
+
+}
+
+Layout::header();
+
+$chan = "SingularityAlpha";
+
+$pageSize = 20;
+
+$builds = array();
+
+if ($res = $DB->query(kl_str_sql("select * from builds where chan=!s order by nr desc limit !i", $chan, $pageSize + 1))) {
+ while ($row = $DB->fetchRow($res)) {
+
+ $build = new stdClass;
+ $DB->loadFromDbRow($build, $res, $row);
+ $builds[] = $build;
+ }
+}
+
+$nrBuilds = count($builds);
+
+if ($nrBuilds) {
+ print '';
+
+
+ for ($i = 0; $i < $pageSize; $i++) {
+ if (!isset($builds[$i])) continue;
+ print_build($builds[$i], $builds[$i + 1]);
+ }
+
+ print '
';
+
+}
+
+Layout::footer();
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/lib/DBH.php b/lib/DBH.php
index 906fed3..169f094 100644
--- a/lib/DBH.php
+++ b/lib/DBH.php
@@ -54,7 +54,7 @@ class DBH
if (!$res) {
DBH::log("[error] ".$q);
- DBH::log("[error_msg] " . $error_msg);
+ DBH::log("[error_msg] " . $error_msg . " " . @sqlite_error_string(@sqlite_last_error(($this->dbh))));
$this->last_error = $error_msg;
$e = debug_backtrace();
@@ -69,15 +69,6 @@ class DBH
return false;
} else {
- if ($res !== TRUE) {
- $result_id = (int)$res;
- if (!isset($this->field_desc[$result_id])) {
- $nf = sqlite_num_fields($res);
- for ($i=0; $i<$nf; $i++) {
- $this->field_desc[$result_id][sqlite_field_name($res, $i)] = sqlite_field_name($res, $i);
- }
- }
- }
DBH::log("[success] ".$q);
return $res;
}
@@ -86,19 +77,14 @@ class DBH
function loadFromDbRow(&$obj, $res, $row)
{
foreach ($row as $symbolicName => $nativeName){
- if ($nativeName && ($this->field_desc[(int)$res][$symbolicName] == "timestamp" ||
- $this->field_desc[(int)$res][$symbolicName] == "date")) {
- $obj->{$symbolicName} = strtotime($nativeName);
- } else {
- $obj->{$symbolicName} = $nativeName;
- }
+ $obj->{$symbolicName} = $nativeName;
}
return true;
}
function fetchRow($res)
{
- return @sqlite_fetch_array($res);
+ return @sqlite_fetch_array($res, SQLITE_ASSOC);
}
}
diff --git a/lib/Layout.php b/lib/Layout.php
index 6206a62..6197a94 100644
--- a/lib/Layout.php
+++ b/lib/Layout.php
@@ -3,6 +3,32 @@
class Layout
{
+
+ function since($since)
+ {
+ $since = time() - $since;
+ $chunks = array(
+ array(60 * 60 * 24 * 365 , 'year'),
+ array(60 * 60 * 24 * 30 , 'month'),
+ array(60 * 60 * 24 * 7, 'week'),
+ array(60 * 60 * 24 , 'day'),
+ array(60 * 60 , 'hour'),
+ array(60 , 'minute'),
+ array(1 , 'second')
+ );
+
+ for ($i = 0, $j = count($chunks); $i < $j; $i++) {
+ $seconds = $chunks[$i][0];
+ $name = $chunks[$i][1];
+ if (($count = floor($since / $seconds)) != 0) {
+ break;
+ }
+ }
+
+ $print = ($count == 1) ? '1 '.$name : "$count {$name}s";
+ return $print;
+ }
+
function header()
{ ?>
@@ -10,6 +36,7 @@ class Layout
+
Singularity Viewer Automated Build System
@@ -32,7 +59,7 @@ class Layout
About |
Issue Tracker |
Source Tracker |
- © 2012 Singularity Viewer Project |
+ © 2012 Singularity Viewer Project |
diff --git a/lib/ext_kl.php b/lib/ext_kl.php
index edea75c..da2b36a 100644
--- a/lib/ext_kl.php
+++ b/lib/ext_kl.php
@@ -104,6 +104,14 @@ function kl_str_sql()
return $res;
}
+
+function pre_dump($var, $die = false)
+{
+ print "";
+ var_dump($var);
+ print "
";
+ if ($die) die();
+}
/*
* Local variables:
diff --git a/lib/import_revs.php b/lib/import_revs.php
index 8bfbbc7..ffa2e39 100755
--- a/lib/import_revs.php
+++ b/lib/import_revs.php
@@ -98,7 +98,7 @@ function update_builds()
// check if table exists
if (!($res = $DB->query("select count(*) as c from builds"))) {
- $DB->query("create table builds(nr integer, chan varchar, version varchar, file varchar, primary key(nr, chan))");
+ $DB->query("create table builds(nr integer, chan varchar, version varchar, file varchar, modified timestamp, primary key(nr, chan))");
}
for ($i=0; $iquery(kl_str_sql("select count(*) as c from builds where nr=!i and chan=!s", $build, $chan));
$row = $DB->fetchRow($res);
if ($row["c"] === "0") {
- $DB->query(kl_str_sql("insert into builds (nr, chan, version, file) ".
- "values (!i, !s, !s, !s)",
- $build, $chan, $version, $file));
+ $DB->query(kl_str_sql("insert into builds (nr, chan, version, file, modified) ".
+ "values (!i, !s, !s, !s, !t)",
+ $build, $chan, $version, $file, $modified));
}
}
}
@@ -123,8 +124,8 @@ function update_builds()
}
chdir(SITE_ROOT . "/lib/source");
-update_source();
-update_revs();
+#update_source();
+#update_revs();
chdir(SITE_ROOT);
update_builds();
diff --git a/lib/init.php b/lib/init.php
index 4fd6397..325d9d2 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -4,6 +4,7 @@ if (!defined('SITE_ROOT')) {
}
error_reporting(E_ALL ^ E_NOTICE);
+ini_set("display_errors", "true");
if (!extension_loaded('kl')) {
require_once SITE_ROOT.'/lib/ext_kl.php';
diff --git a/pretty.php b/pretty.php
deleted file mode 100644
index f1906a6..0000000
--- a/pretty.php
+++ /dev/null
@@ -1,17 +0,0 @@
-