|
1
|
|
|
<?php |
|
2
|
|
|
// This file is part of BOINC. |
|
3
|
|
|
// http://boinc.berkeley.edu |
|
4
|
|
|
// Copyright (C) 2017 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
|
|
|
// web interface for managing apps |
|
20
|
|
|
|
|
21
|
|
|
require_once('../inc/util_ops.inc'); |
|
22
|
|
|
|
|
23
|
|
|
function do_updates() { |
|
24
|
|
|
$id = post_int("id"); |
|
25
|
|
|
$app = BoincApp::lookup_id($id); |
|
26
|
|
|
if (!$app) admin_error_page("no such app"); |
|
27
|
|
|
|
|
28
|
|
|
$n = post_str("deprecated", true)?1:0; |
|
29
|
|
|
$app->update("deprecated=$n"); |
|
30
|
|
|
|
|
31
|
|
|
$n = post_num("weight"); |
|
32
|
|
|
$app->update("weight=$n"); |
|
33
|
|
|
|
|
34
|
|
|
$n = post_int("homogeneous_redundancy"); |
|
35
|
|
|
$app->update("homogeneous_redundancy=$n"); |
|
36
|
|
|
|
|
37
|
|
|
$n = post_int("target_nresults"); |
|
38
|
|
|
$app->update("target_nresults=$n"); |
|
39
|
|
|
|
|
40
|
|
|
$n = post_str("homogeneous_app_version", true)?1:0; |
|
41
|
|
|
$app->update("homogeneous_app_version=$n"); |
|
42
|
|
|
|
|
43
|
|
|
$n = post_str("non_cpu_intensive", true)?1:0; |
|
44
|
|
|
$app->update("non_cpu_intensive=$n"); |
|
45
|
|
|
|
|
46
|
|
|
$n = post_str("beta", true)?1:0; |
|
47
|
|
|
$app->update("beta=$n"); |
|
48
|
|
|
|
|
49
|
|
|
$n = post_str("fraction_done_exact", true)?1:0; |
|
50
|
|
|
$app->update("fraction_done_exact=$n"); |
|
51
|
|
|
|
|
52
|
|
|
echo "Application $id updated. |
|
53
|
|
|
<p> |
|
54
|
|
|
You must restart the project for this to take effect. |
|
55
|
|
|
"; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
function add_app() { |
|
59
|
|
|
$name = BoincDb::escape_string(post_str('add_name')); |
|
60
|
|
|
$user_friendly_name = BoincDb::escape_string(post_str('add_user_friendly_name')); |
|
61
|
|
|
if (empty($name) || empty($user_friendly_name) ) { |
|
62
|
|
|
admin_error_page( |
|
63
|
|
|
"To add a new application please supply both a brief name and a longer 'user-friendly' name.</font></p>" |
|
64
|
|
|
); |
|
65
|
|
|
} |
|
66
|
|
|
$now = time(); |
|
67
|
|
|
$id = BoincApp::insert( |
|
68
|
|
|
"(name,user_friendly_name,create_time) VALUES ('$name', '$user_friendly_name', $now)" |
|
69
|
|
|
); |
|
70
|
|
|
if (!$id) { |
|
71
|
|
|
admin_error_page("insert failed"); |
|
72
|
|
|
} |
|
73
|
|
|
echo "Application added. |
|
74
|
|
|
<p> |
|
75
|
|
|
You must restart the project for this to take effect. |
|
76
|
|
|
"; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
function show_form($all) { |
|
80
|
|
|
echo " |
|
81
|
|
|
<h2>Edit applications</h2> |
|
82
|
|
|
"; |
|
83
|
|
|
|
|
84
|
|
|
$app_clause="deprecated=0"; |
|
85
|
|
|
$action_url="manage_apps.php"; |
|
86
|
|
|
if($all) { |
|
87
|
|
|
$app_clause = ""; |
|
88
|
|
|
$action_url="manage_apps.php?all=1"; |
|
89
|
|
|
echo "<a href=\"manage_apps.php\">Don't show deprecated applications</a>"; |
|
90
|
|
|
} else { |
|
91
|
|
|
echo "<a href=\"manage_apps.php?all=1\">Show deprecated applications</a>"; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
start_table('table-striped'); |
|
95
|
|
|
table_header( |
|
96
|
|
|
"ID", |
|
97
|
|
|
"Name and description<br><small>Click for details</small>", |
|
98
|
|
|
"Created", |
|
99
|
|
|
"weight<br><a href=https://github.com/BOINC/boinc/wiki/BackendPrograms#feeder><small>details</small></a>", |
|
100
|
|
|
"shmem items", |
|
101
|
|
|
"HR type<br><a href=https://github.com/BOINC/boinc/wiki/Homogeneous-Redundancy><small>details</small></a>", |
|
102
|
|
|
"Adaptive replication<br><a href=https://github.com/BOINC/boinc/wiki/Adaptive-Replication><small>details</small></a>", |
|
103
|
|
|
"homogeneous app version?<br><a href=https://github.com/BOINC/boinc/wiki/Homogeneous-App-Version><small>details</small></a>", |
|
104
|
|
|
"deprecated?", |
|
105
|
|
|
"Non-CPU-intensive?", |
|
106
|
|
|
"Beta?", |
|
107
|
|
|
"Exact fraction done?", |
|
108
|
|
|
"" |
|
109
|
|
|
); |
|
110
|
|
|
|
|
111
|
|
|
$total_weight = BoincApp::sum("weight", "where deprecated=0"); |
|
112
|
|
|
$swi = parse_config(get_config(), "<shmem_work_items>"); |
|
113
|
|
|
if (!$swi) { |
|
114
|
|
|
$swi = 100; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
$apps = BoincApp::enum($app_clause); |
|
118
|
|
|
foreach ($apps as $app) { |
|
119
|
|
|
// grey-out deprecated versions |
|
120
|
|
|
$f1=$f2=''; |
|
121
|
|
|
if ($app->deprecated==1) { |
|
122
|
|
|
$f1 = "<font color='GREY'>"; |
|
123
|
|
|
$f2 = "</font>"; |
|
124
|
|
|
} |
|
125
|
|
|
echo "<tr><form action=$action_url method=POST>"; |
|
126
|
|
|
echo "<input type=hidden name=id value=$app->id>"; |
|
127
|
|
|
echo " <TD align='center'>$f1 $app->id $f2</TD>\n"; |
|
128
|
|
|
|
|
129
|
|
|
echo " <TD align='left'>$f1<a href=app_details.php?appid=$app->id>$app->name</a><br> $app->user_friendly_name $f2</TD>\n"; |
|
130
|
|
|
|
|
131
|
|
|
echo " <TD align='center'>$f1 " .date_str($app->create_time)."$f2</TD>\n"; |
|
132
|
|
|
|
|
133
|
|
|
$v = $app->weight; |
|
134
|
|
|
echo " <TD align='center'> |
|
135
|
|
|
<input type='text' size='4' name='weight' value='$v'></TD>\n"; |
|
136
|
|
|
|
|
137
|
|
|
if ($app->deprecated || ($total_weight == 0)) { |
|
138
|
|
|
echo '<td></td>'; |
|
139
|
|
|
} else { |
|
140
|
|
|
echo '<td align="right">'.round($app->weight/$total_weight*$swi).'</td>'; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
$v = $app->homogeneous_redundancy; |
|
144
|
|
|
echo " <TD align='center'> |
|
145
|
|
|
<input size=4 name='homogeneous_redundancy' value='$v'></TD> |
|
146
|
|
|
"; |
|
147
|
|
|
|
|
148
|
|
|
$v = $app->target_nresults; |
|
149
|
|
|
echo " <TD align='center'> |
|
150
|
|
|
<input size=4 name='target_nresults' value='$v'></TD> |
|
151
|
|
|
"; |
|
152
|
|
|
|
|
153
|
|
|
$v = ''; |
|
154
|
|
|
if ($app->homogeneous_app_version) $v=' CHECKED '; |
|
155
|
|
|
echo " <TD align='center'> |
|
156
|
|
|
<input name='homogeneous_app_version' type='checkbox' $v></TD> |
|
157
|
|
|
"; |
|
158
|
|
|
|
|
159
|
|
|
$v = ''; |
|
160
|
|
|
if ($app->deprecated) $v = ' CHECKED '; |
|
161
|
|
|
echo " <TD align='center'> |
|
162
|
|
|
<input name='deprecated' type='checkbox' $v></TD> |
|
163
|
|
|
"; |
|
164
|
|
|
|
|
165
|
|
|
$v = ''; |
|
166
|
|
|
if ($app->non_cpu_intensive) $v = ' CHECKED '; |
|
167
|
|
|
echo " <TD align='center'> |
|
168
|
|
|
<input name='non_cpu_intensive' type='checkbox' $v></TD> |
|
169
|
|
|
"; |
|
170
|
|
|
|
|
171
|
|
|
$v = ''; |
|
172
|
|
|
if ($app->beta) $v = ' CHECKED '; |
|
173
|
|
|
echo " <TD align='center'> |
|
174
|
|
|
<input name='beta' type='checkbox' $v></TD> |
|
175
|
|
|
"; |
|
176
|
|
|
|
|
177
|
|
|
$v = ''; |
|
178
|
|
|
if ($app->fraction_done_exact) $v = ' CHECKED '; |
|
179
|
|
|
echo " <TD align='center'> |
|
180
|
|
|
<input name='fraction_done_exact' type='checkbox' $v></TD> |
|
181
|
|
|
"; |
|
182
|
|
|
if (!in_rops()) { |
|
183
|
|
|
echo "<td><input class=\"btn btn-default\" type=submit name=submit value=Update></td>"; |
|
184
|
|
|
} else { |
|
185
|
|
|
echo "<td> </td>"; |
|
186
|
|
|
} |
|
187
|
|
|
echo "</tr></form>"; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
end_table(); |
|
191
|
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
193
|
|
|
// Entry form to create a new application |
|
194
|
|
|
// |
|
195
|
|
|
if (in_rops()) { |
|
196
|
|
|
return; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
echo"<P> |
|
|
|
|
|
|
200
|
|
|
<h2>Add an application</h2> |
|
201
|
|
|
To add an application enter the short name and description |
|
202
|
|
|
('user friendly name') below. You can then edit the |
|
203
|
|
|
application when it appears in the table above. |
|
204
|
|
|
<p> |
|
205
|
|
|
<form action=$action_url method=POST> |
|
206
|
|
|
"; |
|
207
|
|
|
|
|
208
|
|
|
start_table("align='center' "); |
|
209
|
|
|
|
|
210
|
|
|
table_header("Name", "Description", " "); |
|
211
|
|
|
|
|
212
|
|
|
echo "<TR> |
|
213
|
|
|
<TD> <input type='text' size='12' name='add_name' value=''></TD> |
|
214
|
|
|
<TD> <input type='text' size='35' name='add_user_friendly_name' value=''></TD> |
|
215
|
|
|
<TD align='center' > |
|
216
|
|
|
<input type='submit' name='add_app' value='Add Application'></TD> |
|
217
|
|
|
</TR>\n"; |
|
218
|
|
|
|
|
219
|
|
|
end_table(); |
|
220
|
|
|
echo "</form><p>\n"; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
admin_page_head("Manage applications"); |
|
224
|
|
|
|
|
225
|
|
|
$all = get_int('all', true); |
|
226
|
|
|
|
|
227
|
|
|
if (post_str('add_app', true)) { |
|
228
|
|
|
add_app(); |
|
229
|
|
|
} else if (post_str('submit', true)) { |
|
230
|
|
|
do_updates(); |
|
231
|
|
|
} |
|
232
|
|
|
show_form($all); |
|
233
|
|
|
admin_page_tail(); |
|
234
|
|
|
|
|
235
|
|
|
?> |
|
236
|
|
|
|