-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrobotAttrConf.php
More file actions
241 lines (231 loc) · 8.17 KB
/
robotAttrConf.php
File metadata and controls
241 lines (231 loc) · 8.17 KB
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Scouting App</title>
<link rel="stylesheet" type="text/css" href="Style/scoutingStyle.css">
<head>
<link rel="apple-touch-icon" sizes="57x57" href="/Logo/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/Logo/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/Logo/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/Logo/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/Logo/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/Logo/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/Logo/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/Logo/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/Logo/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/Logo/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/Logo/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/Logo/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/Logo/favicon-16x16.png">
<link rel="manifest" href="/Logo/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/Logo/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="width=device-width, initial-scale=1">
<body>
<h1><center>Bomb Botz Scouting App</center></h1>
</body>
<p></p>
<p></p>
<h2>
<center><a id="buttons" class="clickme danger" href="index.php">Home</a>
<a id="buttons" class="clickme danger" href="robotAttrList.php">Pit Scout</a></center>
</h2>
<?php
$serverName = getenv("ScoutAppDatabaseServerName");
$database = getenv("Database");
$userName = getenv("DatabaseUserName");
$password = getenv("DatabasePassword");
$connectionOptions = array(
"Database" => "$database",
"Uid" => "$userName",
"PWD" => "$password"
);
//Establishes the connection
$conn = sqlsrv_connect($serverName, $connectionOptions);
// Get Login info
$loginEmailAddress = $_SERVER['HTTP_X_MS_CLIENT_PRINCIPAL_NAME'] ?? getenv("DefaultLoginEmailAddress");
$tsql = "select s.scoutGUID
, s.isAdmin
, g.gameYear
from Scout s
inner join Team t
on t.id = s.teamId
inner join GameEvent ge
on ge.id = t.gameEventId
inner join Game g
on g.id = ge.gameId
where isActive = 'Y' and emailAddress = '$loginEmailAddress'";
$getResults = sqlsrv_query($conn, $tsql);
if ($getResults == FALSE)
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
$row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC);
$loginGUID = $row['scoutGUID'];
$gameYear = $row['gameYear'];
$isAdmin = $row['isAdmin'];
// Handle if logged in user is not active/configured in Scout table
if (empty($loginGUID)) {
$loginEmailAddress = getenv("DefaultLoginEmailAddress");
$tsql = "select s.scoutGUID
, s.isAdmin
, g.gameYear
from Scout s
inner join Team t
on t.id = s.teamId
inner join GameEvent ge
on ge.id = t.gameEventId
inner join Game g
on g.id = ge.gameId
where isActive = 'Y' and emailAddress = '$loginEmailAddress'";
$getResults = sqlsrv_query($conn, $tsql);
if ($getResults == FALSE)
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
$loginGUID = $row['scoutGUID'];
$gameYear = $row['gameYear'];
$isAdmin = $row['isAdmin'];
}
// Non-Admin should not be on this page
if ($isAdmin != "Y") {
echo '<center>';
echo 'Email: ' . $loginEmailAddress . ' is not authorized on this page.';
echo '</center>';
sqlsrv_close($conn);
echo '</head>';
echo '</html>';
exit(0);
}
# Reference autoload (assuming you're using Composer)
require_once('vendor/autoload.php');
use MicrosoftAzure\Storage\Blob\Models\CreateBlockBlobOptions;
use MicrosoftAzure\Storage\Blob\Models\ListBlobsOptions;
use MicrosoftAzure\Storage\Blob\BlobRestProxy;
// Get posted variables
$teamId = $_POST['teamId'];
$teamNumber = $_POST['teamNumber'];
// Get Query String Parameters
$scoutId1 = $_POST['scoutId1'];
$scoutId2 = $_POST['scoutId2'];
$scoutId3 = $_POST['scoutId3'];
$value1 = $_POST['value1'];
$value2 = $_POST['value2'];
$value3 = $_POST['value3'];
$value4 = $_POST['value4'];
$value5 = $_POST['value5'];
$value6 = $_POST['value6'];
$value7 = $_POST['value7'];
$value8 = $_POST['value8'];
$value9 = $_POST['value9'];
$value10 = $_POST['value10'];
$value11 = $_POST['value11'];
$value12 = $_POST['value12'];
$value13 = $_POST['value13'];
$value14 = $_POST['value14'];
$value15 = $_POST['value15'];
$value16 = $_POST['value16'];
$value17 = $_POST['value17'];
$value18 = $_POST['value18'];
$value19 = $_POST['value19'];
$value20 = $_POST['value20'];
$tsql = "sp_ins_scoutRobot $teamId, '$loginGUID', $scoutId1, $scoutId2, $scoutId3, '$value1'";
if (isset($value2))
$tsql .= ", '$value2'";
if (isset($value3))
$tsql .= ", '$value3'";
if (isset($value4))
$tsql .= ", '$value4'";
if (isset($value5))
$tsql .= ", '$value5'";
if (isset($value6))
$tsql .= ", '$value6'";
if (isset($value7))
$tsql .= ", '$value7'";
if (isset($value8))
$tsql .= ", '$value8'";
if (isset($value9))
$tsql .= ", '$value9'";
if (isset($value10))
$tsql .= ", '$value10'";
if (isset($value11))
$tsql .= ", '$value11'";
if (isset($value12))
$tsql .= ", '$value12'";
if (isset($value13))
$tsql .= ", '$value13'";
if (isset($value14))
$tsql .= ", '$value14'";
if (isset($value15))
$tsql .= ", '$value15'";
if (isset($value16))
$tsql .= ", '$value16'";
if (isset($value17))
$tsql .= ", '$value17'";
if (isset($value18))
$tsql .= ", '$value18'";
if (isset($value19))
$tsql .= ", '$value19'";
if (isset($value20))
$tsql .= ", '$value20'";
$results = sqlsrv_query($conn, $tsql);
if($results)
echo "<p></p><center>Submission Succeeded!</center>";
if(!$results)
{
echo "It is not working!<br />";
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
}
?>
<p></p>
<form enctype="multipart/form-data" action='./photoUpload.php' method='post'>
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
<?php
echo '<input type="hidden" id="teamNumber" name="teamNumber" value="' . $teamNumber . '">';
echo '<input type="hidden" id="teamId" name="teamId" value="' . $teamId . '">';
?>
</form>
<p></p>
<?php
// Display current photo
$storageAccountName = getenv("StorageAccountName");
$containerName = getenv("StorageContainer");
$accessKey = getenv("StorageAccessKey");
# Setup Azure Storage connection
$connectionString = "DefaultEndpointsProtocol=https;AccountName=$storageAccountName;AccountKey=$accessKey";
try {
$blobClient = BlobRestProxy::createBlobService($connectionString);
}
catch (Exception $e) {
echo "Failed create Blob Service: " . $e . "<br />";
}
$key = $gameYear . '/' . $teamNumber . '/';
$blobListOptions = new ListBlobsOptions();
$blobListOptions->setPrefix($key);
$blobList = $blobClient->listBlobs($containerName, $blobListOptions);
foreach($blobList->getBlobs() as $key => $blob) {
//echo "Blob ".$key.": \t".$blob->getName()."\t(".$blob->getUrl().")<br />";
echo '<img class="image'.$key.'" src="'.$blob->getUrl().'" style="max-width: 75%;"><br />';
}
// Close SQL
sqlsrv_free_stmt($getResults);
sqlsrv_close($conn);
?>
</head>
</html>