-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_view.php
139 lines (126 loc) · 4.12 KB
/
build_view.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
<?php
// force display of error
//error_reporting(E_ALL);
//ini_set('display_errors', '1');
//date_default_timezone_set('Europe/Paris');
// check if all is here ...
//echo("<br/>USER = ".$_GET['USER']);
//echo("<br/>LIB_NAME = ".$_GET['LIB_NAME']);
//echo("<br/>branch = ".$_GET['branch']);
//die("<br/>die");
/*
header("Content-Type: image/svg+xml");
*/
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // ast time
/*
function errorSVG($_name) {
echo('<svg xmlns="http://www.w3.org/2000/svg" width="180" height="20">');
echo(' <linearGradient id="a" x2="0" y2="100%">');
echo(' <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>');
echo(' <stop offset="1" stop-opacity=".1"/>');
echo(' </linearGradient>');
echo(' <rect rx="3" width="120" height="20" fill="#F00"/>');
echo(' <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">');
echo(' <text x="60" y="15" fill="#010101" fill-opacity=".3">BUILD: '.$_name.'</text>');
echo(' <text x="60" y="14">BUILD: '.$_name.'</text>');
echo(' </g>');
echo('</svg>');
exit();
}
*/
include_once("connect.php");
@include_once("connect_server.php");
$COVERAGE_bdd = mysqli_connect($sqlServer, $sqlLogin, $sqlPass, $sqlBDD);
// Check connection
if (mysqli_connect_errno()) {
die ("connection n the server error");
}
// check if all is here ...
$branch = "master";
$tag = "Linux";
if (isset($_GET['USER']) == FALSE) {
die ("You must specify a user ...");
}
$listLibrary = []
if (isset($_GET['LIB_NAME']) == FALSE) {
$listLibrary.append($_GET['LIB_NAME']);
} else {
// Get all library names with all branches:
$sql = "SELECT * "
." FROM `CI_group`"
." WHERE `CI_group`.`user-name` = '".$_GET['USER']."'"
." LIMIT 1";
echo("sql : ".$sql);
$result = $COVERAGE_bdd->query($sql);
echo("result = ".$result);
}
/*
errorSVG("LIB_NAME??");
}
if (isset($_GET['branch']) == TRUE) {
$branch = $_GET['branch'];
}
if (isset($_GET['tag']) == TRUE) {
$tag = $_GET['tag'];
}
*/
//echo "register ".$_POST['JSON_FILE'];
$sql = "SELECT `BUILD_snapshot`.`".$tag."` "
." FROM `BUILD_snapshot`"
." , `CI_group`"
." WHERE `CI_group`.`user-name` = '".$_GET['USER']."'"
." AND `CI_group`.`lib-name` = '".$_GET['LIB_NAME']."'"
." AND `CI_group`.`lib-branch` = '".$branch."'"
." AND `CI_group`.`id` = `BUILD_snapshot`.`id-group`"
." LIMIT 1";
//echo("sql : ".$sql);
$result = $COVERAGE_bdd->query($sql);
//
if ($result == NULL) {
errorSVG("UNKNOW");
}
//echo("find result : ".$result);
if ($result->num_rows > 0) {
if ($result->num_rows > 1) {
errorSVG("To much value");
}
$row = $result->fetch_assoc();
$status = $row[$tag];
} else {
$status = "---";
//errorSVG("No Value");
}
//some coverage value :
if ($status == "UNKNOW") {
$color = "333";
} else if ($status == "START") {
$color = "11F";
} else if ($status == "ERROR") {
$color = "c11";
} else if ($status == "OK") {
$color = "4c1";
} else {
$color = "FF0";
}
echo('<svg xmlns="http://www.w3.org/2000/svg" width="180" height="20">');
echo(' <linearGradient id="a" x2="0" y2="100%">');
echo(' <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>');
echo(' <stop offset="1" stop-opacity=".1"/>');
echo(' </linearGradient>');
echo(' <rect rx="3" width="180" height="20" fill="#555"/>');
echo(' <rect rx="3" x="40" width="75" height="20" fill="#A60"/>');
echo(' <rect rx="3" x="110" width="70" height="20" fill="#'.$color.'"/>');
echo(' <rect rx="3" width="180" height="20" fill="url(#a)"/>');
echo(' <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">');
echo(' <text x="19" y="15" fill="#010101" fill-opacity=".3">build</text>');
echo(' <text x="19" y="14">Build</text>');
echo(' <text x="75" y="15" fill="#010101" fill-opacity=".3">'.$tag.'</text>');
echo(' <text x="75" y="14">'.$tag.'</text>');
echo(' <text x="145" y="15" fill="#010101" fill-opacity=".3">'.$status.'</text>');
echo(' <text x="145" y="14">'.$status.'</text>');
echo(' </g>');
echo('</svg>');
// simply close link with the DB...
$COVERAGE_bdd->close();
?>