-
Notifications
You must be signed in to change notification settings - Fork 7
/
su_user.inc
166 lines (155 loc) · 4.53 KB
/
su_user.inc
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
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2017 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// UI related to users
require_once("../inc/host.inc");
require_once("../inc/su_db.inc");
function latest_rpc_time($hosts) {
$t = 0;
foreach($hosts as $h) {
if ($h->rpc_time > $t) {
$t = $h->rpc_time;
}
}
return $t;
}
define('WARNING', "<font color=red>⚠</font> ");
define('CURRENT_CLIENT_VERSION', '7.14.2');
// suggest download in various situations
// - if account is > 1 hr old and no host
// download link, help link
// - if last RPC from any host is > 1 week
// warn; suggest reinstall
// - if client version is too old on an active machine
// suggest upgrade
//
function show_download($user) {
if (time() - $user->create_time < 3600) {
return;
}
$hosts = BoincHost::enum("userid=$user->id");
if (count($hosts) == 0) {
echo WARNING."It looks like BOINC isn't running on your computer.
Try <a href=download.php?dev=1>re-installing it</a>.
If you need help,
<a href=https://boinc.berkeley.edu/help.php>go here</a>.
<br>
";
return;
}
$dt = time() - latest_rpc_time($hosts);
if ($dt > 7*86400) {
echo WARNING."None of your computers has contacted us in the last ".time_diff($dt, 0)." ago.
Please check that BOINC is running.
You may need to <a href=download.php?dev=1>re-install BOINC</a>.
<br>
";
return;
}
foreach ($hosts as $host) {
if (time() - $host->rpc_time > 7*86400) {
continue;
}
$cv = boinc_version($host->serialnum);
if (version_compare($cv, CURRENT_CLIENT_VERSION) < 0) {
echo WARNING."Your computer $host->domain_name is running an old version of BOINC.
Please <a href=su_download_info.php>upgrade to the current version</a>.
<br>
";
}
}
}
// show keywords of recent jobs
//
// TODO: need client/scheduler support for this.
// - jobs must include list of keywords (area/loc)
// - AM request includes list of keywords of jobs on client
//
function show_supported_keywords($user) {
echo "
<p>
Recently, your computer has been
doing work for projects doing
(list of science keywords)
located in (list of locations).
";
}
function show_stats(
$cpu_ec, $cpu_time, $gpu_ec, $gpu_time, $njobs_success, $njobs_fail
){
echo sprintf(
"CPU: %.2f hours
",
$cpu_time/3600
);
if ($gpu_time > 0) {
echo sprintf(
"<br>GPU: %.2f hours
",
$gpu_time/3600
);
}
echo sprintf(
"<br>jobs: %d success, %d failure
",
$njobs_success, $njobs_fail
);
}
function show_last_day($user) {
$au = SUAccountingUser::last($user->id);
if (!$au) {
return;
}
echo "<p>Last day<br>";
show_stats(
$au->cpu_ec_delta,
$au->cpu_time_delta,
$au->gpu_ec_delta,
$au->gpu_time_delta,
$au->njobs_success_delta,
$au->njobs_fail_delta
);
echo "<p>Total<br>";
show_stats(
$au->cpu_ec_total,
$au->cpu_time_total,
$au->gpu_ec_total,
$au->gpu_time_total,
$au->njobs_success_total,
$au->njobs_fail_total
);
}
function show_calls_to_action() {
echo sprintf('
<h3>%s</h3>
<ul>
<li> %s
<li> %s
</ul>
%s
',
tra('Want to help more?'),
tra('Tell friends and family about %1.', PROJECT),
tra("Run BOINC on your other computing devices (desktops, laptops, tablets, Android phones)."),
tra("Is BOINC running on this computer? If not, %1Download it%2.",
'<a href="download.php">',
'<a/>'
)
);
echo "<p>\n";
}
?>