query('SELECT * FROM `tasks` WHERE `build`=\''.$request['build'].'\' AND `order`='.$request['task']); if ($r->rowCount() == 0) { echo print_error('Not found', 'Build '.$request['build'].'/task '.$request['task'].' was not found.'); return; } $task=new sql_task($r->fetch(PDO::FETCH_ASSOC)); echo '
'.$task->display().'
'; echo 'Back
'; $page=isset($request['page']) && is_numeric($request['page'])?$request['page']:1; $count=$S['pdo']->query('SELECT COUNT(*) FROM `buildlogs` WHERE `build`=\''.$task->build.'\' AND `task`='.$task->order)->fetch(PDO::FETCH_COLUMN); $pager=''; if ($count > $conf['logview_max']) { $pager='
Page: '; if ($page > 1) { $pager.=' '."\n"; } $pager.=' '; if ($page*$conf['logview_max']<$count) { $pager.=' '."\n"; } $pager.='
'; echo $pager; } $r=$S['pdo']->query('SELECT * FROM `buildlogs` WHERE `build`=\''.$task->build.'\' AND `task`='.$task->order.' ORDER BY `order` ASC LIMIT '.$conf['logview_max'].' OFFSET '.($page-1)*$conf['logview_max']); if ($r->rowCount()) { echo '
'; $ansi=new ansi_to_html(); while ($entry=$r->fetch(PDO::FETCH_ASSOC)) { $entry=new sql_buildlog_entry($entry); // $text=str_replace(array("\n", "\t"), array("
\n", str_repeat(' ', 4)), htmlentities($entry->text)); // echo 'stream=='stderr'?' style="color: red" ':'').' title="'.strtoupper($entry->stream).', entry #'.$entry->order.' @ '.date('D j M Y @ H:i:s', $entry->timestamp).' UTC">'.$text.''; echo $ansi->process(str_replace(array("\n", ' ', "\t"), array("
\n", ' ', str_repeat(' ', 8)), $entry->text)); // TODO handle tabs properly, move all this into ansi_to_html } echo $ansi->reset(); // Clear any leftover s echo '
'; echo $pager; echo 'Back
'; } else { if ($count) { echo print_error("There aren't $page pages. Try an build.'/'.$task->order)."\">earlier page."); } else { echo print_warning('No output'); } } } elseif (isset($request['build']) && preg_match('/[a-z0-9]{6}/', $request['build'])) { $build=new sql_build($request['build']); echo $build->display(); $r=$S['pdo']->query('SELECT * FROM `tasks` WHERE `build`="'.$request['build'].'" ORDER BY `order` ASC'); if ($r->rowCount() == 0) { echo 'No tasks found.'; } $i=0; while ($task=$r->fetch(PDO::FETCH_ASSOC)) { $task=new sql_task($task); echo $task->display(); } } else { $r=$S['pdo']->query('SELECT * FROM `builds` ORDER BY `ctime` IS NULL ASC, `ctime` ASC, `status` DESC'); if ($r->rowCount() == 0) { echo print_warning('No builds found.'); } while ($build=$r->fetch(PDO::FETCH_ASSOC)) { $build=new sql_build($build); echo $build->display(); } } } ?>