forked from Kitware/CDash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildOverview.php
183 lines (154 loc) · 5.2 KB
/
buildOverview.php
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
/*=========================================================================
Program: CDash - Cross-Platform Dashboard System
Module: $Id$
Language: PHP
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
include("cdash/config.php");
require_once("cdash/pdo.php");
include_once("cdash/common.php");
include("cdash/version.php");
$noforcelogin = 1;
include('login.php');
@$projectname = $_GET["project"];
if ($projectname != NULL)
{
$projectname = htmlspecialchars(pdo_real_escape_string($projectname));
}
if(!isset($projectname) || strlen($projectname)==0)
{
die("Error: project not specified<br>\n");
}
@$date = $_GET["date"];
if ($date != NULL)
{
$date = htmlspecialchars(pdo_real_escape_string($date));
}
$db = pdo_connect("$CDASH_DB_HOST", "$CDASH_DB_LOGIN","$CDASH_DB_PASS");
pdo_select_db("$CDASH_DB_NAME",$db);
$xml = begin_XML_for_XSLT();
$xml .= "<title>".$projectname." : Build Overview</title>";
$xml .= get_cdash_dashboard_xml_by_name($projectname,$date);
// Get some information about the specified project
$project = pdo_query("SELECT id, nightlytime FROM project WHERE name = '$projectname'");
if(!$project_array = pdo_fetch_array($project))
{
die("Error: project $projectname not found<br>\n");
}
checkUserPolicy(@$_SESSION['cdash']['loginid'],$project_array["id"]);
$projectid = $project_array["id"];
$nightlytime = $project_array["nightlytime"];
// We select the builds
list ($previousdate, $currentstarttime, $nextdate,$today) = get_dates($date,$nightlytime);
$xml .= "<menu>";
$xml .= add_XML_value("previous","buildOverview.php?project=".urlencode($projectname)."&date=".$previousdate);
if(has_next_date($date, $currentstarttime))
{
$xml .= add_XML_value("next","buildOverview.php?project=".urlencode($projectname)."&date=".$nextdate);
}
else
{
$xml .= add_XML_value("nonext","1");
}
$xml .= add_XML_value("current","buildOverview.php?project=".urlencode($projectname)."&date=");
$xml .= add_XML_value("back","index.php?project=".urlencode($projectname)."&date=".$today);
$xml .= "</menu>";
// Return the available groups
@$groupSelection = $_POST["groupSelection"];
if ($groupSelection != NULL)
{
$groupSelection = pdo_real_escape_numeric($groupSelection);
}
if(!isset($groupSelection))
{
$groupSelection = 0;
}
$buildgroup = pdo_query("SELECT id,name FROM buildgroup WHERE projectid='$projectid'");
while($buildgroup_array = pdo_fetch_array($buildgroup))
{
$xml .= "<group>";
$xml .= add_XML_value("id",$buildgroup_array["id"]);
$xml .= add_XML_value("name",$buildgroup_array["name"]);
if($groupSelection == $buildgroup_array["id"])
{
$xml .= add_XML_value("selected","1");
}
$xml .= "</group>";
}
// Check the builds
$beginning_timestamp = $currentstarttime;
$end_timestamp = $currentstarttime+3600*24;
$beginning_UTCDate = gmdate(FMT_DATETIME,$beginning_timestamp);
$end_UTCDate = gmdate(FMT_DATETIME,$end_timestamp);
$groupSelectionSQL = "";
if($groupSelection>0)
{
$groupSelectionSQL = " AND b2g.groupid='$groupSelection' ";
}
$sql = "SELECT s.name,b.name as buildname,be.type,be.sourcefile,be.sourceline,be.text
FROM build AS b,builderror as be,site AS s, build2group as b2g
WHERE b.starttime<'$end_UTCDate' AND b.starttime>'$beginning_UTCDate'
AND b.projectid='$projectid' AND be.buildid=b.id
AND s.id=b.siteid AND b2g.buildid=b.id
".$groupSelectionSQL."ORDER BY be.sourcefile ASC,be.type ASC,be.sourceline ASC";
$builds = pdo_query($sql);
echo pdo_error();
if(pdo_num_rows($builds)==0)
{
$xml .= "<message>No warnings or errors today!</message>";
}
$current_file = "ThisIsMyFirstFile";
while($build_array = pdo_fetch_array($builds))
{
if($build_array["sourcefile"] != $current_file)
{
if($current_file != "ThisIsMyFirstFile")
{
$xml .= "</sourcefile>";
}
$xml .= "<sourcefile>";
$xml .= "<name>".$build_array["sourcefile"]."</name>";
$current_file = $build_array["sourcefile"];
}
if($build_array["type"] == 0)
{
$xml .= "<error>";
}
else
{
$xml .= "<warning>";
}
$xml .= "<line>".$build_array["sourceline"]."</line>";
$textarray = explode("\n",$build_array["text"]);
foreach($textarray as $text)
{
if(strlen($text)>0)
{
$xml .= add_XML_value("text",$text);
}
}
$xml .= "<sitename>".$build_array["name"]."</sitename>";
$xml .= "<buildname>".$build_array["buildname"]."</buildname>";
if($build_array["type"] == 0)
{
$xml .= "</error>";
}
else
{
$xml .= "</warning>";
}
}
if(pdo_num_rows($builds)>0)
{
$xml .= "</sourcefile>";
}
$xml .= "</cdash>";
generate_XSLT($xml, "buildOverview");
?>