forked from Kitware/CDash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewMap.php
149 lines (124 loc) · 5.68 KB
/
viewMap.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
<?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.
=========================================================================*/
$noforcelogin = 1;
include("cdash/config.php");
require_once("cdash/pdo.php");
include('login.php');
include_once("cdash/common.php");
include("cdash/version.php");
@$projectname = $_GET["project"];
if ($projectname != NULL)
{
$projectname = htmlspecialchars(pdo_real_escape_string($projectname));
}
@$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);
$projectid = get_project_id($projectname);
if($projectid == -1)
{
echo "Wrong project name";
return;
}
checkUserPolicy(@$_SESSION['cdash']['loginid'],$projectid);
$xml = begin_XML_for_XSLT();
$xml .= "<title>CDash : Sites map for ".$projectname."</title>";
$xml .= "<backurl>index.php?project=".urlencode($projectname)."&date=$date</backurl>";
$xml .= "<menutitle>CDash</menutitle>";
$xml .= "<menusubtitle>Build location</menusubtitle>";
$xml .= "<dashboard>";
$xml .= "<title>CDash</title>";
$xml .= "<date>".$date."</date>";
// Find the correct google map key
foreach($CDASH_GOOGLE_MAP_API_KEY as $key=>$value)
{
if(strstr($_SERVER['HTTP_HOST'],$key) !== FALSE)
{
$apikey = $value;
break;
}
}
$xml .= add_XML_value("googlemapkey",$apikey);
$xml .= add_XML_value("projectname",$projectname);
$xml .= add_XML_value("projectname_encoded",urlencode($projectname));
$xml .= "</dashboard>";
$project = pdo_query("SELECT * FROM project WHERE id='$projectid'");
$project_array = pdo_fetch_array($project);
list ($previousdate, $currenttime, $nextdate) = get_dates($date,$project_array["nightlytime"]);
$nightlytime = strtotime($project_array["nightlytime"]);
$nightlyhour = gmdate("H",$nightlytime);
$nightlyminute = gmdate("i",$nightlytime);
$nightlysecond = gmdate("s",$nightlytime);
$end_timestamp = $currenttime-1; // minus 1 second when the nightly start time is midnight exactly
$beginning_timestamp = gmmktime($nightlyhour,$nightlyminute,$nightlysecond,gmdate("m",$end_timestamp),gmdate("d",$end_timestamp),gmdate("Y",$end_timestamp));
if($end_timestamp<$beginning_timestamp)
{
$beginning_timestamp = gmmktime($nightlyhour,$nightlyminute,$nightlysecond,gmdate("m",$end_timestamp-24*3600),gmdate("d",$end_timestamp-24*3600),gmdate("Y",$end_timestamp-24*3600));
}
$beginning_UTCDate = gmdate(FMT_DATETIME,$beginning_timestamp);
$end_UTCDate = gmdate(FMT_DATETIME,$end_timestamp);
if($CDASH_DB_TYPE == "pgsql")
{
$site = pdo_query("SELECT s.id,s.name,si.processorclockfrequency,
si.description,
si.numberphysicalcpus,s.ip,s.latitude,s.longitude,
".qid('user').".firstname,".qid('user').".lastname,".qid('user').".id AS userid
FROM build AS b, siteinformation AS si, site as s
LEFT JOIN site2user ON (site2user.siteid=s.id)
LEFT JOIN ".qid('user')." ON (site2user.userid=".qid('user').".id)
WHERE s.id=b.siteid
AND b.starttime<'$end_UTCDate' AND b.starttime>'$beginning_UTCDate'
AND si.siteid=s.id
AND b.projectid='$projectid' GROUP BY s.id,s.name,si.processorclockfrequency,
si.description,
si.numberphysicalcpus,s.ip,s.latitude,s.longitude,".qid('user').".firstname,".qid('user').".lastname,".qid('user').".id");
}
else
{
$site = pdo_query("SELECT s.id,s.name,si.processorclockfrequency,
si.description,
si.numberphysicalcpus,s.ip,s.latitude,s.longitude,
".qid('user').".firstname,".qid('user').".lastname,".qid('user').".id AS userid
FROM build AS b, siteinformation AS si, site as s
LEFT JOIN site2user ON (site2user.siteid=s.id)
LEFT JOIN ".qid('user')." ON (site2user.userid=".qid('user').".id)
WHERE s.id=b.siteid
AND b.starttime<'$end_UTCDate' AND b.starttime>'$beginning_UTCDate'
AND si.siteid=s.id
AND b.projectid='$projectid' GROUP BY s.id");
}
echo pdo_error();
while($site_array = pdo_fetch_array($site))
{
$xml .= "<site>";
$xml .= add_XML_value("name",$site_array["name"]);
$xml .= add_XML_value("id",$site_array["id"]);
$xml .= add_XML_value("description",$site_array["description"]);
$xml .= add_XML_value("processor_speed",getByteValueWithExtension($site_array["processorclockfrequency"]*1024*1024));
$xml .= add_XML_value("numberphysicalcpus",$site_array["numberphysicalcpus"]);
$xml .= add_XML_value("latitude",$site_array["latitude"]);
$xml .= add_XML_value("longitude",$site_array["longitude"]);
$xml .= add_XML_value("longitude",$site_array["longitude"]);
$xml .= add_XML_value("maintainer_name",$site_array["firstname"]." ".$site_array["lastname"]);
$xml .= add_XML_value("maintainer_id",$site_array["userid"]);
$xml .= "</site>";
}
$xml .= "</cdash>";
// Now doing the xslt transition
generate_XSLT($xml,"viewMap");
?>