|
1
|
|
|
<?php |
|
2
|
|
|
// This file is part of BOINC. |
|
3
|
|
|
// http://boinc.berkeley.edu |
|
4
|
|
|
// Copyright (C) 2015 University of California |
|
5
|
|
|
// |
|
6
|
|
|
// BOINC is free software; you can redistribute it and/or modify it |
|
7
|
|
|
// under the terms of the GNU Lesser General Public License |
|
8
|
|
|
// as published by the Free Software Foundation, |
|
9
|
|
|
// either version 3 of the License, or (at your option) any later version. |
|
10
|
|
|
// |
|
11
|
|
|
// BOINC is distributed in the hope that it will be useful, |
|
12
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
14
|
|
|
// See the GNU Lesser General Public License for more details. |
|
15
|
|
|
// |
|
16
|
|
|
// You should have received a copy of the GNU Lesser General Public License |
|
17
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
|
18
|
|
|
|
|
19
|
|
|
// Page for downloading the BOINC client, with support for autoattach: |
|
20
|
|
|
// https://github.com/BOINC/boinc/wiki/SimpleAttach |
|
21
|
|
|
// Note: to use autoattach: |
|
22
|
|
|
// 1) You need to have the latest client versions file |
|
23
|
|
|
// run html/ops/get_versions.php |
|
24
|
|
|
// 2) Put your project ID (ask DPA if you don't have one) |
|
25
|
|
|
// in config.xml as <project_id>x</project_id> |
|
26
|
|
|
// |
|
27
|
|
|
// There's a logged-in user. |
|
28
|
|
|
// |
|
29
|
|
|
// Autoattach case: if project has an ID and client is Win or Mac: |
|
30
|
|
|
// - find latest version for that platform |
|
31
|
|
|
// - Create a login token. |
|
32
|
|
|
// - Show download button(s) |
|
33
|
|
|
// The download will be via concierge, using the login token. |
|
34
|
|
|
// Otherwise: |
|
35
|
|
|
// - show link to download page on BOINC web site, |
|
36
|
|
|
// and instructions for what to do after that. |
|
37
|
|
|
|
|
38
|
|
|
// Can also be called as a web RPC; |
|
39
|
|
|
// see https://github.com/BOINC/boinc/wiki/WebRpc#download |
|
40
|
|
|
// NOT USED - OK TO REMOVE |
|
41
|
|
|
// rpc this says it's an RPC |
|
42
|
|
|
// user_agent web browser info |
|
43
|
|
|
// authenticator the account to link to |
|
44
|
|
|
// returns an XML doc of the form |
|
45
|
|
|
// <download_info> |
|
46
|
|
|
// [ <manual/> ] // not win or mac - tell user to visit BOINC download page |
|
47
|
|
|
// <project_id>X</project_id> |
|
48
|
|
|
|
|
49
|
|
|
require_once("../inc/util.inc"); |
|
50
|
|
|
require_once("../inc/account.inc"); |
|
51
|
|
|
|
|
52
|
|
|
// take the user agent string reported by web browser, |
|
53
|
|
|
// and return best guess for platform |
|
54
|
|
|
// |
|
55
|
|
|
function get_platform($user_agent) { |
|
56
|
|
|
if (strstr($user_agent, 'Windows')) { |
|
57
|
|
|
if (strstr($user_agent, 'Win64')||strstr($user_agent, 'WOW64')) { |
|
|
|
|
|
|
58
|
|
|
return 'windows_x86_64'; |
|
59
|
|
|
} else { |
|
60
|
|
|
return 'windows_intelx86'; |
|
61
|
|
|
} |
|
62
|
|
|
} else if (strstr($user_agent, 'Mac')) { |
|
63
|
|
|
if (strstr($user_agent, 'PPC Mac OS X')) { |
|
64
|
|
|
return 'powerpc-apple-darwin'; |
|
65
|
|
|
} else { |
|
66
|
|
|
return 'x86_64-apple-darwin'; |
|
67
|
|
|
} |
|
68
|
|
|
} else if (strstr($user_agent, 'Android')) { |
|
69
|
|
|
// Check for Android before Linux, |
|
70
|
|
|
// since Android contains the Linux kernel and the |
|
71
|
|
|
// web browser user agent string lists Linux too. |
|
72
|
|
|
// |
|
73
|
|
|
return 'arm-android-linux-gnu'; |
|
74
|
|
|
} else if (strstr($user_agent, 'Linux')) { |
|
75
|
|
|
if (strstr($user_agent, 'x86_64')) { |
|
76
|
|
|
return 'x86_64-pc-linux-gnu'; |
|
77
|
|
|
} else { |
|
78
|
|
|
return 'i686-pc-linux-gnu'; |
|
79
|
|
|
} |
|
80
|
|
|
} else { |
|
81
|
|
|
return null; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
function is_windows() { |
|
86
|
|
|
global $user_agent; |
|
87
|
|
|
if (strstr($user_agent, 'Windows')) { |
|
88
|
|
|
return true; |
|
89
|
|
|
} |
|
90
|
|
|
return false; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
function is_windows_or_mac() { |
|
94
|
|
|
global $user_agent; |
|
95
|
|
|
if (strstr($user_agent, 'Windows')) return true; |
|
96
|
|
|
if (strstr($user_agent, 'Mac')) return true; |
|
97
|
|
|
return false; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
// find release version for user's platform |
|
101
|
|
|
// |
|
102
|
|
|
function get_version($user_agent, $dev) { |
|
103
|
|
|
$v = simplexml_load_file("versions.xml"); |
|
104
|
|
|
$p = get_platform($user_agent); |
|
105
|
|
|
foreach ($v->version as $i=>$v) { |
|
|
|
|
|
|
106
|
|
|
if ((string)$v->dbplatform != $p) { |
|
107
|
|
|
continue; |
|
108
|
|
|
} |
|
109
|
|
|
if (strstr((string)$v->description, "Recommended")) { |
|
110
|
|
|
return $v; |
|
111
|
|
|
} |
|
112
|
|
|
if ($dev) { |
|
113
|
|
|
if (strstr((string)$v->description, "Development")) { |
|
114
|
|
|
return $v; |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
return null; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
function download_button($v, $project_id, $token, $user) { |
|
122
|
|
|
return sprintf( |
|
123
|
|
|
'<form action="https://boinc.berkeley.edu/concierge.php" method="post"> |
|
124
|
|
|
<input type=hidden name=project_id value="%d"> |
|
125
|
|
|
<input type=hidden name=token value="%s"> |
|
126
|
|
|
<input type=hidden name=user_id value="%d"> |
|
127
|
|
|
<input type=hidden name=filename value="%s"> |
|
128
|
|
|
<button class="btn" %s> |
|
129
|
|
|
<font size=+1><u>Download BOINC</u></font> |
|
130
|
|
|
<br>for %s (%s MB) |
|
131
|
|
|
<br>BOINC %s</button> |
|
132
|
|
|
</form> |
|
133
|
|
|
', |
|
134
|
|
|
$project_id, |
|
135
|
|
|
$token, |
|
136
|
|
|
$user->id, |
|
137
|
|
|
(string)$v->filename, |
|
138
|
|
|
button_style('green', 14), |
|
139
|
|
|
(string)$v->platform, |
|
140
|
|
|
(string)$v->size_mb, |
|
141
|
|
|
(string)$v->version_num |
|
142
|
|
|
); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
// We can't use auto-attach; direct user to the BOINC download page |
|
146
|
|
|
// |
|
147
|
|
|
function direct_to_boinc() { |
|
148
|
|
|
page_head(tra("Download BOINC")); |
|
149
|
|
|
text_start(); |
|
150
|
|
|
echo "<p>"; |
|
151
|
|
|
echo tra("To download and install BOINC, |
|
152
|
|
|
click on the link below and follow the instructions. |
|
153
|
|
|
"); |
|
154
|
|
|
echo "<p>"; |
|
155
|
|
|
show_button( |
|
156
|
|
|
"https://boinc.berkeley.edu/download.php", |
|
157
|
|
|
tra("Go to the BOINC download page."), |
|
158
|
|
|
null, null, 'target=_new' |
|
159
|
|
|
); |
|
160
|
|
|
|
|
161
|
|
|
if (parse_bool(get_config(), 'account_manager')) { |
|
162
|
|
|
echo sprintf( |
|
163
|
|
|
"<p><p>%s<p>", |
|
164
|
|
|
tra("When BOINC first runs it will ask you to select a project. |
|
165
|
|
|
Cancel out of this dialog, |
|
166
|
|
|
then select <b>Tools / Use Account Manager</b> |
|
167
|
|
|
to connect BOINC to your %1 account. |
|
168
|
|
|
See <a href=%2>detailed instructions</a>.", |
|
169
|
|
|
PROJECT, |
|
170
|
|
|
'https://boinc.berkeley.edu/wiki/Account_managers' |
|
171
|
|
|
) |
|
172
|
|
|
); |
|
173
|
|
|
} else { |
|
174
|
|
|
echo sprintf( |
|
175
|
|
|
"<p><p>%s<p>", |
|
176
|
|
|
tra("When BOINC first runs it will ask you to select a project. |
|
177
|
|
|
Select '%1' from the list, |
|
178
|
|
|
or enter this project's URL:<p>%2", |
|
179
|
|
|
PROJECT, |
|
180
|
|
|
master_url() |
|
181
|
|
|
) |
|
182
|
|
|
); |
|
183
|
|
|
} |
|
184
|
|
|
text_end(); |
|
185
|
|
|
page_tail(); |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
function show_download_page($user, $user_agent, $dev) { |
|
189
|
|
|
global $project_id; |
|
190
|
|
|
|
|
191
|
|
|
// If no project ID, we can't use simplified install |
|
192
|
|
|
// |
|
193
|
|
|
if (!$project_id || !is_windows_or_mac()) { |
|
194
|
|
|
direct_to_boinc(); |
|
195
|
|
|
return; |
|
196
|
|
|
} |
|
197
|
|
|
$v = get_version($user_agent, $dev); |
|
198
|
|
|
|
|
199
|
|
|
// if we can't figure out the user's platform, |
|
200
|
|
|
// take them to the download page on the BOINC site |
|
201
|
|
|
// |
|
202
|
|
|
if (!$v) { |
|
203
|
|
|
direct_to_boinc(); |
|
204
|
|
|
return; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
page_head("Download software"); |
|
208
|
|
|
|
|
209
|
|
|
$phrase = ""; |
|
210
|
|
|
$dlv = tra("the current version of BOINC"); |
|
211
|
|
|
$phrase = tra("this version is"); |
|
212
|
|
|
$dl = "BOINC"; |
|
213
|
|
|
echo tra("To participate in %1, %2 must be installed on your computer.", PROJECT, $dlv); |
|
214
|
|
|
echo" |
|
|
|
|
|
|
215
|
|
|
<p> |
|
216
|
|
|
"; |
|
217
|
|
|
echo tra("If %1 already installed, %2click here%3.", |
|
218
|
|
|
$phrase, |
|
219
|
|
|
"<a href=download_software.php?action=installed>", |
|
220
|
|
|
"</a>" |
|
221
|
|
|
); |
|
222
|
|
|
echo " |
|
223
|
|
|
<p> |
|
224
|
|
|
"; |
|
225
|
|
|
|
|
226
|
|
|
$token = make_login_token($user); |
|
227
|
|
|
echo "<table border=0 cellpadding=20>\n"; |
|
228
|
|
|
table_row("", download_button($v, $project_id, $token, $user), ""); |
|
229
|
|
|
echo "</table>\n"; |
|
230
|
|
|
echo "<p><p>"; |
|
231
|
|
|
echo tra("When the download is finished, open the downloaded file to install %1.", $dl); |
|
232
|
|
|
echo "<p><p>"; |
|
233
|
|
|
echo tra("All done? %1Click here to finish%2.", "<a href=welcome.php>", "</a>"); |
|
234
|
|
|
page_tail(); |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
// if user already has BOINC installed, tell them how to attach. |
|
238
|
|
|
// |
|
239
|
|
|
function installed() { |
|
240
|
|
|
$config = get_config(); |
|
241
|
|
|
$am = parse_bool($config, "account_manager"); |
|
242
|
|
|
if ($am) { |
|
243
|
|
|
page_head(tra("Use %1", PROJECT)); |
|
244
|
|
|
echo sprintf("%s |
|
245
|
|
|
<ul> |
|
246
|
|
|
<li> %s |
|
247
|
|
|
<li> %s |
|
248
|
|
|
<li> %s |
|
249
|
|
|
<li> %s |
|
250
|
|
|
</ul> |
|
251
|
|
|
", |
|
252
|
|
|
tra("To use %1 on this computer:", PROJECT), |
|
253
|
|
|
tra("In the BOINC manager, go to the Tools menu"), |
|
254
|
|
|
tra("Select Use Account Manager"), |
|
255
|
|
|
tra("Select %1 from the list", PROJECT), |
|
256
|
|
|
tra("Enter your %1 email address and password.", PROJECT) |
|
257
|
|
|
); |
|
258
|
|
|
} else { |
|
259
|
|
|
page_head(tra("Add %1", PROJECT)); |
|
260
|
|
|
echo sprintf("%s |
|
261
|
|
|
<ul> |
|
262
|
|
|
<li> %s |
|
263
|
|
|
<li> %s |
|
264
|
|
|
<li> %s |
|
265
|
|
|
<li> %s |
|
266
|
|
|
</ul> |
|
267
|
|
|
", |
|
268
|
|
|
tra("To add %1 on this computer:", PROJECT), |
|
269
|
|
|
tra("In the BOINC manager, go to the Tools menu"), |
|
270
|
|
|
tra("Select Add Project"), |
|
271
|
|
|
tra("Select %1 from the list", PROJECT), |
|
272
|
|
|
tra("Enter your %1 email address and password.", PROJECT) |
|
273
|
|
|
); |
|
274
|
|
|
} |
|
275
|
|
|
echo "<p><p>"; |
|
276
|
|
|
echo sprintf('<a href=home.php class="btn btn-success">%s</a> |
|
277
|
|
|
', |
|
278
|
|
|
tra('Continue to your home page') |
|
279
|
|
|
); |
|
280
|
|
|
page_tail(); |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
// RPC handler |
|
284
|
|
|
// NOT USED - OK TO REMOVE |
|
285
|
|
|
// |
|
286
|
|
|
function handle_get_info() { |
|
287
|
|
|
require_once("../inc/xml.inc"); |
|
288
|
|
|
global $user; |
|
289
|
|
|
$config = get_config(); |
|
290
|
|
|
xml_header(); |
|
291
|
|
|
$rpc_key = get_str('rpc_key'); |
|
292
|
|
|
if ($rpc_key != parse_config($config, "<rpc_key>")) { |
|
293
|
|
|
xml_error(-1, "RPC key mismatch"); |
|
294
|
|
|
} |
|
295
|
|
|
$user = BoincUser::lookup_auth(get_str('auth')); |
|
296
|
|
|
if (!$user) { |
|
297
|
|
|
xml_error(-1, "user not found"); |
|
298
|
|
|
} |
|
299
|
|
|
$project_id = parse_config($config, '<project_id>'); |
|
300
|
|
|
if (!$project_id) { |
|
301
|
|
|
xml_error(-1, "no project ID"); |
|
302
|
|
|
} |
|
303
|
|
|
$user_agent = get_str('user_agent'); |
|
304
|
|
|
$v = get_version($user_agent, false); |
|
305
|
|
|
if (!$v) { |
|
306
|
|
|
xml_error(-1, "no version for platform"); |
|
307
|
|
|
} |
|
308
|
|
|
|
|
309
|
|
|
$token = make_login_token($user); |
|
310
|
|
|
echo sprintf( |
|
311
|
|
|
'<download_info> |
|
312
|
|
|
<project_id>%s</project_id> |
|
313
|
|
|
<token>%s</token> |
|
314
|
|
|
<user_id>%d</user_id> |
|
315
|
|
|
<platform>%s</platform> |
|
316
|
|
|
<boinc> |
|
317
|
|
|
<filename>%s</filename> |
|
318
|
|
|
<size_mb>%s</size_mb> |
|
319
|
|
|
<boinc_version>%s</boinc_version> |
|
320
|
|
|
</boinc> |
|
321
|
|
|
', |
|
322
|
|
|
$project_id, |
|
323
|
|
|
$token, |
|
324
|
|
|
$user->id, |
|
325
|
|
|
(string)$v->platform, |
|
326
|
|
|
(string)$v->filename, |
|
327
|
|
|
(string)$v->size_mb, |
|
328
|
|
|
(string)$v->version_num |
|
329
|
|
|
); |
|
330
|
|
|
echo '</download_info> |
|
331
|
|
|
'; |
|
332
|
|
|
} |
|
333
|
|
|
|
|
334
|
|
|
// get config.xml items |
|
335
|
|
|
// |
|
336
|
|
|
$config = get_config(); |
|
337
|
|
|
$project_id = parse_config($config, "<project_id>"); |
|
338
|
|
|
|
|
339
|
|
|
$action = get_str("action", true); |
|
340
|
|
|
|
|
341
|
|
|
if ($action == "installed") { |
|
342
|
|
|
installed(); |
|
343
|
|
|
} else if ($action == 'get_info') { |
|
344
|
|
|
handle_get_info(); |
|
345
|
|
|
} else { |
|
346
|
|
|
$dev = get_str("dev", true); |
|
347
|
|
|
$user_agent = get_str("user_agent", true); // for debugging |
|
348
|
|
|
if (!$user_agent) { |
|
349
|
|
|
$user_agent = $_SERVER['HTTP_USER_AGENT']; |
|
350
|
|
|
} |
|
351
|
|
|
$user = get_logged_in_user(); |
|
|
|
|
|
|
352
|
|
|
show_download_page($user, $user_agent, $dev); |
|
353
|
|
|
} |
|
354
|
|
|
|
|
355
|
|
|
?> |
|
356
|
|
|
|