hash = $hash;
$build->result = -1;
$build->project = $project;
$file = MICOBU_BASE . "/". $project->name . "/" . $hash . "/meta.json";
if (file_exists($file)) {
$json = json_decode(file_get_contents($file));
$build->hash = $json->hash;
$build->result = $json->result;
$build->time_start = $json->time_start;
$build->time_stop = $json->time_stop;
$build->description = $json->description;
}
return $build;
}
function scan_project($name) {
$project = new micobu_project();
$project->name = $name;
$project->builds = array();
$dirs = glob_sorted_mtime(MICOBU_BASE . "/" . $name);
foreach ($dirs as $dir) {
$hash = basename($dir);
$project->builds += array($hash => scan_build($project, $hash));
}
return $project;
}
function micobu_scan() {
$projects = array();
foreach (glob(MICOBU_BASE . "/*", GLOB_ONLYDIR) as $project_path) {
$project_name = basename($project_path);
$projects += array($project_name => scan_project($project_name));
}
return $projects;
}
function micobu_get_trend($project) {
foreach ($project->builds as $build) {
if ($build->result > 0)
return "❌";
else
return "✅";
}
return "⌛";
return "🔼";
return "❗";
}
function micobu_get_build_icon($build) {
if ($build->result > 0)
return "❌";
else
return "✅";
}
function micobu_get_build_time($build) {
return gmdate("i\m s\s", $build->time_stop - $build->time_start);
}
function micobu_get_weblink($build, $filename) {
return MICOBU_BASE_LINK . "/" . $build->project->name . "/" . $build->hash . "/" . $filename;
}
$projects = micobu_scan();
if (isset($_GET['p'])) {
$selected_project = $_GET['p'];
preg_match("/^[_\-A-Za-z0-9]{1,20}$/", $selected_project, $matches);
if (!$matches)
die("Invalid request.");
if (!isset($projects[$selected_project]))
die("Invalid project.");
if (isset($_GET['h'])) {
$selected_hash = $_GET['h'];
preg_match("/^[_\-A-Za-z0-9]{1,40}$/", $selected_hash, $matches);
if (!$matches)
die("Invalid request.");
if (!isset($projects[$selected_project]->builds[$selected_hash]))
die("Invalid hash.");
}
}
?>
$selected_project" : "");
$dpath .= (isset($selected_hash) ? " / $selected_hash" : "");
echo "";
?>
builds[$selected_hash]);
$build = $projects[$selected_project]->builds[$selected_hash];
echo "
";
echo "Build status | " . micobu_get_build_icon($build). " |
";
echo "Build time | " . micobu_get_build_time($build) . " |
";
echo "
";
} else if (isset($selected_project)) {
echo "
";
} else {
echo "
";
foreach ($projects as $project) {
echo "" . $project->name . " | " . micobu_get_trend($project) . " |
";
}
echo "
";
}
?>