56
59
// Various functions are defined below for converting between these forms,
57
60
// and also to/from HTML form elements
62
error_reporting(E_ALL);
63
ini_set('display_errors', true);
64
ini_set('display_startup_errors', true);
66
include_once("../inc/prefs_util.inc");
59
67
include_once("../project/project_specific_prefs.inc");
61
// strings describing various preference fields
63
define("CPU_LIMIT_DESC", "Processor usage");
64
define("SUSPEND_WHILE_ON_BATTERIES_DESC",
65
"Suspend work while computer is on battery power?
66
<br><span class=note>(matters only for portable computers)</span>"
68
define("RUN_IF_USER_ACTIVE_DESC",
69
"Suspend work while computer is in use?"
71
define("IDLE_TIME_TO_RUN_DESC", "'In use' means mouse/keyboard activity in last");
72
define("SUSPEND_IF_NO_RECENT_INPUT_DESC",
73
"Suspend work if no mouse/keyboard activity in last
74
<br><span class=note>(Needed to enter low-power mode on some computers)
75
<br>Enforced by version 5.10.14+</span>"
77
define("START_END_DESC", "Do work only between the hours of");
78
define("START_END_DESC2", "<br><span class=note>(no restriction if equal)</span>");
79
define("LEAVE_APPS_IN_MEMORY_DESC",
80
"Leave applications in memory while suspended?
81
<br><span class=note>(suspended applications will consume swap space if 'yes')</span>");
82
define("CPU_SCHEDULING_DESC", "Switch between applications every
83
<br><span class=note>(recommended: 60 minutes)</span>");
84
define("CONFIRM_BEFORE_CONNECTING_DESC",
85
"Confirm before connecting to Internet?
86
<br><span class=note>(matters only if you have a modem, ISDN or VPN connection)</span>"
88
define("HANGUP_IF_DIALED_DESC",
89
"Disconnect when done?
90
<br><span class=note>(matters only if you have a modem, ISDN or VPN connection)</span>"
92
define("WORK_BUF_MIN_DAYS_DESC",
93
"Computer is connected to the Internet about every
94
<br><span class=note>(Leave blank or 0 if always connected.
95
<br>BOINC will try to maintain at least this much work.)</span>
98
define("WORK_BUF_ADDITIONAL_DAYS_DESC",
99
"Maintain enough work for an additional
100
<br><span class=note>Enforced by version 5.10+</span>
103
define("MAX_NCPUS_PCT_DESC", "On multiprocessors, use at most<span class=note><br>Enforced by version 6.1+</span>");
104
define("MAX_NCPUS_PCT_DESC2", "% of the processors");
105
define("MAX_CPUS_DESC", "On multiprocessors, use at most<span class=note><br>Enforced by version 5.10 and earlier</span>");
106
define("MAX_CPUS_DESC2", "processors");
107
define("USE_AT_MOST", "Use at most");
108
define("USE_AT_MOST2", "Use at most<span class=note><br>(Can be used to reduce CPU heat)<br>Enforced by version 5.6+</span>");
109
define("USE_AT_MOST3", "Use at most<br><span class=note>Enforced by version 5.8+</span>");
110
define("CPU_USAGE_LIMIT_DESC2", "percent of CPU time");
111
define("DISK_INTERVAL_DESC", "Write to disk at most every");
112
define("DISK_LIMIT_DESC", "Disk and memory usage");
113
define("DISK_MIN_FREE_GB_DESC", "Leave at least");
114
define("DISK_SCHED_MIN_FREE_DESC1", "<br><span class=note>(Values smaller than ");
115
define("DISK_SCHED_MIN_FREE_DESC2", " are ignored)</span>");
116
define("DISK_MAX_USED_PCT_DESC2", "% of total disk space");
117
define("VM_MAX_USED_PCT_DESC2", "% of page file (swap space)");
118
define("RAM_MAX_USED_BUSY_PCT_DESC2", "% of memory when computer is in use");
119
define("RAM_MAX_USED_IDLE_PCT_DESC2", "% of memory when computer is not in use");
120
define("NETWORK_LIMIT_DESC", "Network usage");
121
define("MAX_BYTES_SEC_DOWN_DESC", "Maximum download rate:");
122
define("MAX_BYTES_SEC_UP_DESC", "Maximum upload rate:");
123
define("NET_START_END_DESC",
124
"Use network only between the hours of
125
<br><span class=note>Enforced by version 4.46+</span>"
127
define("DONT_VERIFY_IMAGES_DESC",
128
"Skip image file verification?
129
<br><span class=note>Check this ONLY if your Internet provider
130
modifies image files (UMTS does this, for example).
131
<br>Skipping verification reduces the security of BOINC.</span>"
134
define("BYTE_CONVERSION", 1000.0);
135
define("BYTE_UNITS", "Kbytes/sec");
136
define("BYTE_ABBR", "KB/s");
137
define("ALLOW_BETA_WORK",
138
"Run test applications?<br>
139
<span class=note>This helps us develop applications,
140
but may cause jobs to fail on your computer</span>"
69
$app_types = get_app_types();
71
$venues = array("home", "school", "work");
76
"Suspend work while computer is on battery power? %1 Matters only for portable computers %2",
77
"<br><span class=note>",
84
tra("Suspend work while computer is in use?"),
90
"Suspend GPU work while computer is in use? %1 Enforced by version 6.6.21+ %2",
91
"<br><span class=note>",
94
"run_gpu_if_user_active",
98
tra("'In use' means mouse/keyboard activity in last"),
100
new NUM_SPEC(tra("minutes"), 1, 9999, 3)
104
"Suspend work if no mouse/keyboard activity in last %1 Needed to enter low-power mode on some computers %2",
105
"<br><span class=note>",
108
"suspend_if_no_recent_input",
109
new NUM_SPEC(tra("minutes"), 0, 9999, 0)
113
"Suspend work if CPU usage is above %1 0 means no restriction<br>Enforced by version 6.10.30+ %2",
114
"<br><span class=note>",
118
new NUM_SPEC("%", 0, 100, 25)
121
tra("Do work only between the hours of %1 No restriction if equal %2",
122
"<br><span class=note>",
125
"start_hour", "end_hour"
129
"Leave tasks in memory while suspended? %1 Suspended tasks will consume swap space if 'yes' %2",
130
"<br><span class=note>",
133
"leave_apps_in_memory",
138
"Switch between tasks every %1 Recommended: 60 minutes %2",
139
"<br><span class=note>",
142
"cpu_scheduling_period_minutes",
143
new NUM_SPEC(tra("minutes"), 1, 9999, 60)
146
tra("On multiprocessors, use at most"),
148
new NUM_SPEC(tra("processors"), 0, 9999, 0)
152
"On multiprocessors, use at most %1 Enforced by version 6.1+ %2",
153
"<br><span class=note>",
157
new NUM_SPEC(tra("% of the processors"), 0, 100, 100)
161
"Use at most %1 Can be used to reduce CPU heat %2",
162
"<br><span class=note>",
166
new NUM_SPEC(tra("% of CPU time"), 0, 100, 100)
170
$dp = get_disk_space_config();
174
tra("Disk: use at most"),
176
new NUM_SPEC(tra("GB"), 0, 9999999, $dp->disk_max_used_gb)
179
tra("Disk: leave free at least %1 Values smaller than %2 are ignored %3",
180
"<br><span class=note>",
185
new NUM_SPEC(tra("GB"), 0.001, 9999999, $dp->disk_min_free_gb)
188
tra("Disk: use at most"),
190
new NUM_SPEC(tra("% of total"), 0, 100, $dp->disk_max_used_pct)
193
tra("Tasks checkpoint to disk at most every"),
195
new NUM_SPEC(tra("seconds"), 0, 9999999, 60)
198
tra("Swap space: use at most"),
200
new NUM_SPEC(tra("% of total"), 0, 100, 75)
203
tra("Memory: when computer is in use, use at most"),
204
"ram_max_used_busy_pct",
205
new NUM_SPEC(tra("% of total"), 0, 100, 50)
208
tra("Memory: when computer is not in use, use at most"),
209
"ram_max_used_idle_pct",
210
new NUM_SPEC(tra("% of total"), 0, 100, 90)
217
"Computer is connected to the Internet about every %1 Leave blank or 0 if always connected. %2 BOINC will try to maintain at least this much work. %3",
218
"<br><span class=note>",
223
new NUM_SPEC(tra("days"), 0, 10, 0)
226
tra("Maintain enough work for an additional"),
227
"work_buf_additional_days",
228
new NUM_SPEC(tra("days"), 0, 10, .25)
232
"Confirm before connecting to Internet? %1 Matters only if you have a modem, ISDN or VPN connection %2",
233
"<br><span class=note>",
236
"confirm_before_connecting",
241
"Disconnect when done? %1 Matters only if you have a modem, ISDN or VPN connection %2",
242
"<br><span class=note>",
249
tra("Maximum download rate:"),
250
"max_bytes_sec_down",
251
new NUM_SPEC(tra("Kbytes/sec"), 0, 9999999, 0, 1000)
254
tra("Maximum upload rate:"),
256
new NUM_SPEC(tra("Kbytes/sec"), 0, 9999999, 0, 1000)
259
tra("Use network only between the hours of"),
260
"net_start_hour", "net_end_hour"
263
tra("Transfer at most %1 Enforced by version 6.10.46+ %2",
264
"<br><span class=note>",
267
"daily_xfer_limit_mb",
268
"daily_xfer_period_days",
269
new NUM_SPEC(tra("Mbytes every"), 0, 9999999, 0),
270
new NUM_SPEC(tra("days"), 0, 9999999, 0)
274
"Skip image file verification? %1 Check this ONLY if your Internet provider modifies image files (UMTS does this, for example). %2 Skipping verification reduces the security of BOINC. %3",
275
"<br><span class=note>",
279
"dont_verify_images",
284
$project_pref_descs = array(
287
"Resource share %1 Determines the proportion of your computer's resources allocated to this project. Example: if you participate in two BOINC projects with resource shares of 100 and 200, the first will get 1/3 of your resources and the second will get 2/3. %2",
288
"<br><span class=note>",
292
new NUM_SPEC("", 0, 9999999, 100)
296
if ($app_types->count > 1) {
297
if ($app_types->cpu) {
298
$project_pref_descs[] = new PREF_BOOL (
300
"Use CPU %1 Enforced by version 6.10+ %2",
301
"<br><span class=note>",
309
if ($app_types->ati) {
310
$project_pref_descs[] = new PREF_BOOL (
312
"Use ATI GPU %1 Enforced by version 6.10+ %2",
313
"<br><span class=note>",
321
if ($app_types->cuda) {
322
$project_pref_descs[] = new PREF_BOOL (
324
"Use NVIDIA GPU %1 Enforced by version 6.10+ %2",
325
"<br><span class=note>",
335
if (isset($project_has_beta) && $project_has_beta) {
336
$project_pref_descs[] = new PREF_BOOL(
338
"Run test applications? %1 This helps us develop applications, but may cause jobs to fail on your computer %2",
339
"<br><span class=note>",
346
if (defined("EMAIL_FROM")) {
347
$x = "<br><span class=note>".tra("Emails will be sent from %1; make sure your spam filter accepts this address.", EMAIL_FROM)."</span>";
352
$privacy_pref_descs = array (
354
tra("Is it OK for %1 and your team (if any) to email you?", PROJECT).$x,
360
tra("Should %1 show your computers on its web site?", PROJECT),
367
define("DISK_LIMIT_DESC", tra("Disk and memory usage"));
368
define("CPU_LIMIT_DESC", tra("Processor usage"));
369
define("NETWORK_LIMIT_DESC", tra("Network usage"));
143
371
// These texts are used in multiple places in prefs_edit.php and add_venue.php
144
define("PREFS_FORM_DESC1", "These preferences apply to all the BOINC projects in which you participate.<br><br>");
145
define("PREFS_FORM_ERROR_DESC", "<b>Unable to update preferences.</b> The values marked in red below were out of range or not numeric.<br><br>");
372
define("PREFS_FORM_DESC1", tra("These preferences apply to all the BOINC projects in which you participate.")."<br><br>");
373
define("PREFS_FORM_ERROR_DESC",
375
"%1Unable to update preferences.%2 The values marked in red below were out of range or not numeric.",
148
383
global $parse_result;
149
384
global $top_parse_result;
150
385
global $in_project_specific;
151
386
global $venue_name;
155
388
// get default settings for disk space usage so the default user
156
389
// preferences match the settings used by the scheduler.
309
function get_bool() {
311
return (trim($text) != '0');
314
510
function element_end_global($parser, $name) {
316
512
global $parse_result;
317
513
global $top_parse_result;
318
514
global $venue_name;
520
foreach ($cpu_prefs as $p) {
521
if ($p->xml_parse($parse_result, $name, $text)) {
525
foreach ($disk_prefs as $p) {
526
if ($p->xml_parse($parse_result, $name, $text)) {
530
foreach ($net_prefs as $p) {
531
if ($p->xml_parse($parse_result, $name, $text)) {
322
537
$top_parse_result->$venue_name = $parse_result;
323
538
$parse_result = $top_parse_result;
325
case "run_on_batteries":
326
// deprecated, but parse anyway
327
$parse_result->suspend_while_on_batteries = !get_bool();
329
case "suspend_while_on_batteries":
330
$parse_result->suspend_while_on_batteries = get_bool();
332
case "run_if_user_active":
333
$parse_result->suspend_if_user_active = false;
335
case "idle_time_to_run":
336
$parse_result->idle_time_to_run = $text;
338
case "suspend_if_no_recent_input":
339
$parse_result->suspend_if_no_recent_input = $text;
342
$parse_result->start_hour = $text;
345
$parse_result->end_hour = $text;
347
case "leave_apps_in_memory":
348
$parse_result->leave_apps_in_memory = true;
350
case "cpu_scheduling_period_minutes":
351
$parse_result->cpu_scheduling_period_minutes = $text;
353
case "confirm_before_connecting":
354
$parse_result->confirm_before_connecting = true;
356
case "hangup_if_dialed":
357
$parse_result->hangup_if_dialed = true;
359
case "work_buf_min_days":
360
$parse_result->work_buf_min_days = $text;
362
case "work_buf_additional_days":
363
$parse_result->work_buf_additional_days = $text;
366
$parse_result->max_cpus = $text;
368
case "max_ncpus_pct":
369
$parse_result->max_ncpus_pct = $text;
371
case "cpu_usage_limit":
372
if (!$text) $text=100;
373
$parse_result->cpu_usage_limit = $text;
375
case "disk_interval":
376
$parse_result->disk_interval = $text;
378
case "disk_max_used_gb":
379
$parse_result->disk_max_used_gb = $text;
381
case "disk_max_used_pct":
382
$parse_result->disk_max_used_pct = $text;
384
case "disk_min_free_gb":
385
$parse_result->disk_min_free_gb = $text;
387
case "vm_max_used_pct":
388
$parse_result->vm_max_used_pct = $text;
390
case "ram_max_used_busy_pct":
391
$parse_result->ram_max_used_busy_pct = $text;
393
case "ram_max_used_idle_pct":
394
$parse_result->ram_max_used_idle_pct = $text;
396
case "max_bytes_sec_down":
397
$parse_result->max_bytes_sec_down = $text;
399
case "max_bytes_sec_up":
400
$parse_result->max_bytes_sec_up = $text;
402
case "net_start_hour":
403
$parse_result->net_start_hour = $text;
406
$parse_result->net_end_hour = $text;
408
case "dont_verify_images":
409
$parse_result->dont_verify_images = true;
412
541
$parse_result->mod_time = $text;
427
// state of prefs for new users
556
// state of prefs before parsing; defines prefs for new users
429
558
function default_prefs_global() {
431
$p->suspend_while_on_batteries = true;
432
$p->suspend_if_user_active = false;
433
$p->idle_time_to_run = 3;
434
$p->suspend_if_no_recent_input = 0;
437
$p->leave_apps_in_memory = false;
438
$p->cpu_scheduling_period_minutes = 60;
439
$p->confirm_before_connecting = false;
440
$p->hangup_if_dialed = true;
441
$p->work_buf_min_days = 0;
442
$p->work_buf_additional_days = 0.25;
444
$p->max_ncpus_pct = 100;
445
$p->cpu_usage_limit = 100;
446
$p->disk_interval = 60;
447
$dp = get_disk_space_config();
448
$p->disk_max_used_gb = $dp->disk_max_used_gb;
449
$p->disk_max_used_pct = $dp->disk_max_used_pct;
450
$p->disk_min_free_gb = $dp->disk_min_free_gb;
451
$p->vm_max_used_pct = 75;
452
$p->ram_max_used_busy_pct = 50;
453
$p->ram_max_used_idle_pct = 90;
454
$p->max_bytes_sec_down = 0;
455
$p->max_bytes_sec_up = 0;
456
$p->net_start_hour = 0;
457
$p->net_end_hour = 0;
458
$p->dont_verify_images = false;
564
foreach ($cpu_prefs as $pref) {
565
$pref->set_default($p);
567
foreach ($disk_prefs as $pref) {
568
$pref->set_default($p);
570
foreach ($net_prefs as $pref) {
571
$pref->set_default($p);
462
576
function default_prefs_project() {
577
global $project_pref_descs;
464
$p->resource_share = 100;
465
$p->allow_beta_work = false;
466
$p->allow_beta_work_text = "no";
580
foreach($project_pref_descs as $pref) {
581
$pref->set_default($p);
467
583
$p->project_specific = project_specific_prefs_default();
471
// state of prefs before parsing; initialize booleans
473
function initialize_prefs_before_parsing_global() {
474
$p = default_prefs_global();
475
$p->suspend_while_on_batteries = true;
476
$p->suspend_if_user_active = true;
477
$p->leave_apps_in_memory = false;
478
$p->confirm_before_connecting = false;
479
$p->hangup_if_dialed = false;
480
$p->dont_verify_images = false;
485
function initialize_prefs_before_parsing_project() {
486
$p = default_prefs_project();
490
587
// parse prefs from XML to a struct
492
589
function prefs_parse_project($prefs_xml) {
493
590
global $parse_result;
494
$parse_result = initialize_prefs_before_parsing_project();
591
$parse_result = default_prefs_project();
495
592
$xml_parser = xml_parser_create();
496
593
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
497
594
xml_set_element_handler($xml_parser, "element_start_project", "element_end_project");
503
600
function prefs_parse_global($prefs_xml) {
504
601
global $parse_result;
505
$parse_result = initialize_prefs_before_parsing_global();
506
//echo "AFTER INIT: <pre>";
507
//var_dump($parse_result);
602
$parse_result = default_prefs_global();
509
603
$xml_parser = xml_parser_create();
510
604
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
511
605
xml_set_element_handler($xml_parser, "element_start_global", "element_end_global");
512
606
xml_set_character_data_handler($xml_parser, "char_handler");
513
607
xml_parse($xml_parser, $prefs_xml, 1);
514
//echo "AFTER PARSE: <pre>";
515
//var_dump($parse_result);
517
608
return $parse_result;
520
function hour_str($x) {
524
function hour_select($x, $name) {
526
$s = $s. "<select name=$name>\n";
527
for ($i=0; $i<24; $i++) {
529
$sel = ($x == $i)?"selected":"";
530
$s = $s."<option value=$i $sel> $y";
532
$s = $s."</select>\n";
536
611
////////////////////////////////////////////
538
613
// display preference subsets as Columns
540
615
function row_top($x, $ncols=6, $class="heading") {
541
616
echo "<tr><td class=$class width=35%>$x</td>";
542
echo "<td class=$class width=10%><b>Default</b></td>
543
<td class=$class width=10%><b>Home</b></td>
544
<td class=$class width=10%><b>School</b></td>
545
<td class=$class width=10%><b>Work</b></td>";
617
echo "<td class=$class width=10%><b>".tra("Default")."</b></td>
618
<td class=$class width=10%><b>".tra("Home")."</b></td>
619
<td class=$class width=10%><b>".tra("School")."</b></td>
620
<td class=$class width=10%><b>".tra("Work")."</b></td>";
546
621
echo "<td width=15%><br></td></tr>\n";
550
// hour_range - Produce range string for given venue
552
function hour_range($venue, $type) {
553
if ($type == "run") {
554
$s_hour = $venue->start_hour;
555
$e_hour = $venue->end_hour;
557
if ($type == "net") {
558
$s_hour = $venue->net_start_hour;
559
$e_hour = $venue->net_end_hour;
561
if ($s_hour == $e_hour) {
564
$s = hour_str($s_hour);
565
$e = hour_str($e_hour);
572
625
// row_defs - Display a value for all 4 venues in one row
574
627
function row_defs($pre, $item, $post, $type, $prefs) {
575
628
$gen = $prefs->$item;
576
$hom = isset($prefs->home) ? $prefs->home->$item : "--";
577
$schl = isset($prefs->school) ? $prefs->school->$item : "--";
578
$wrk = isset($prefs->work) ? $prefs->work->$item : "--";
629
$hom = (isset($prefs->home) && isset($prefs->home->$item)) ? $prefs->home->$item : "--";
630
$schl = (isset($prefs->school) && isset($prefs->school->$item)) ? $prefs->school->$item : "--";
631
$wrk = (isset($prefs->work) && isset($prefs->work->$item)) ? $prefs->work->$item : "--";
580
633
echo "<tr><td class=fieldname>$pre</td>";
581
634
row_field($gen, $type);
668
707
echo "<td><br></td></tr>\n";
673
// prefs_show_columns_global - Display all venues as columns next to descriptions
710
// Display all venues as columns next to descriptions
675
712
function prefs_show_columns_global($prefs) {
676
717
row_top(CPU_LIMIT_DESC);
677
row_defs(SUSPEND_WHILE_ON_BATTERIES_DESC, "suspend_while_on_batteries", "", "yesno", $prefs);
678
row_defs(RUN_IF_USER_ACTIVE_DESC, "suspend_if_user_active", "", "yesno", $prefs);
679
row_defs(IDLE_TIME_TO_RUN_DESC, "idle_time_to_run", " minutes", "", $prefs);
681
row_defs(SUSPEND_IF_NO_RECENT_INPUT_DESC, "suspend_if_no_recent_input", "minutes", "minutes", $prefs);
683
row_hours(START_END_DESC, "run", $prefs);
685
row_defs(LEAVE_APPS_IN_MEMORY_DESC, "leave_apps_in_memory", "", "yesno", $prefs);
686
row_defs(CPU_SCHEDULING_DESC, "cpu_scheduling_period_minutes", " minutes", "", $prefs);
687
row_defs(MAX_CPUS_DESC, "max_cpus", MAX_CPUS_DESC2, "", $prefs);
688
row_defs(MAX_NCPUS_PCT_DESC, "max_ncpus_pct", MAX_NCPUS_PCT_DESC2, "", $prefs);
689
row_defs(USE_AT_MOST2, "cpu_usage_limit", CPU_USAGE_LIMIT_DESC2, "", $prefs);
718
foreach ($cpu_prefs as $p) {
719
$p->show_cols($prefs);
691
721
row_top(DISK_LIMIT_DESC);
692
row_defs(USE_AT_MOST, "disk_max_used_gb", " GB disk space", "", $prefs);
693
row_defs(DISK_MIN_FREE_GB_DESC, "disk_min_free_gb", " GB disk space free", "", $prefs);
694
row_defs(USE_AT_MOST, "disk_max_used_pct", DISK_MAX_USED_PCT_DESC2, "", $prefs);
695
row_defs(DISK_INTERVAL_DESC, "disk_interval", " seconds", "", $prefs);
696
row_defs(USE_AT_MOST, "vm_max_used_pct", VM_MAX_USED_PCT_DESC2, "", $prefs);
697
row_defs(USE_AT_MOST3, "ram_max_used_busy_pct", RAM_MAX_USED_BUSY_PCT_DESC2, "", $prefs);
698
row_defs(USE_AT_MOST3, "ram_max_used_idle_pct", RAM_MAX_USED_IDLE_PCT_DESC2, "", $prefs);
722
foreach ($disk_prefs as $p) {
723
$p->show_cols($prefs);
700
725
row_top(NETWORK_LIMIT_DESC);
701
row_defs(WORK_BUF_MIN_DAYS_DESC, "work_buf_min_days", " days", "", $prefs);
702
row_defs(WORK_BUF_ADDITIONAL_DAYS_DESC, "work_buf_additional_days", " days", "", $prefs);
703
row_defs(CONFIRM_BEFORE_CONNECTING_DESC, "confirm_before_connecting", "", "yesno", $prefs);
704
row_defs(HANGUP_IF_DIALED_DESC, "hangup_if_dialed", "", "yesno", $prefs);
705
row_defs(MAX_BYTES_SEC_DOWN_DESC, "max_bytes_sec_down", "", "limit", $prefs);
706
row_defs(MAX_BYTES_SEC_UP_DESC, "max_bytes_sec_up", "", "limit", $prefs);
707
row_hours(NET_START_END_DESC, "net", $prefs);
708
row_defs(DONT_VERIFY_IMAGES_DESC, "dont_verify_images", "", "yesno", $prefs);
726
foreach ($net_prefs as $p) {
727
$p->show_cols($prefs);
710
729
row_links("global", $prefs);
713
function show_double($x) {
718
732
function prefs_show_global($prefs) {
719
737
row1(CPU_LIMIT_DESC);
720
row2(SUSPEND_WHILE_ON_BATTERIES_DESC, $prefs->suspend_while_on_batteries?"yes":"no");
721
row2(RUN_IF_USER_ACTIVE_DESC, $prefs->suspend_if_user_active?"yes":"no");
722
row2(IDLE_TIME_TO_RUN_DESC, "$prefs->idle_time_to_run minutes");
724
$x = show_double($prefs->suspend_if_no_recent_input);
725
row2(SUSPEND_IF_NO_RECENT_INPUT_DESC, "$x minutes");
727
if ($prefs->start_hour == $prefs->end_hour) {
728
$x = "(no restriction)";
730
$s = hour_str($prefs->start_hour);
731
$e = hour_str($prefs->end_hour);
738
foreach ($cpu_prefs as $p) {
734
row2(START_END_DESC, $x);
735
row2(LEAVE_APPS_IN_MEMORY_DESC, $prefs->leave_apps_in_memory?"yes":"no");
736
row2(CPU_SCHEDULING_DESC, "$prefs->cpu_scheduling_period_minutes minutes");
737
$x = $prefs->max_cpus?$prefs->max_cpus:'---';
738
row2(MAX_CPUS_DESC, "$x ".MAX_CPUS_DESC2);
739
$x = $prefs->max_ncpus_pct?$prefs->max_ncpus_pct:'---';
740
row2(MAX_NCPUS_PCT_DESC, "$x ".MAX_NCPUS_PCT_DESC2);
741
row2(USE_AT_MOST2, "$prefs->cpu_usage_limit ".CPU_USAGE_LIMIT_DESC2);
742
741
row1(DISK_LIMIT_DESC);
743
row2(USE_AT_MOST, "$prefs->disk_max_used_gb GB disk space");
745
$dp = get_disk_space_config();
748
if ($dp->new_sched_flag) {
749
$msg = DISK_SCHED_MIN_FREE_DESC1.$dp->sched_disk_min_free_gb.DISK_SCHED_MIN_FREE_DESC2;
742
foreach ($disk_prefs as $p) {
751
row2(DISK_MIN_FREE_GB_DESC.$msg, "$prefs->disk_min_free_gb GB disk space free");
752
row2(USE_AT_MOST, "$prefs->disk_max_used_pct".DISK_MAX_USED_PCT_DESC2);
753
row2(DISK_INTERVAL_DESC, "$prefs->disk_interval seconds");
754
row2(USE_AT_MOST, "$prefs->vm_max_used_pct".VM_MAX_USED_PCT_DESC2);
755
row2(USE_AT_MOST3, "$prefs->ram_max_used_busy_pct".RAM_MAX_USED_BUSY_PCT_DESC2);
756
row2(USE_AT_MOST3, "$prefs->ram_max_used_idle_pct".RAM_MAX_USED_IDLE_PCT_DESC2);
757
745
row1(NETWORK_LIMIT_DESC);
758
row2(WORK_BUF_MIN_DAYS_DESC, "$prefs->work_buf_min_days days");
759
row2(WORK_BUF_ADDITIONAL_DAYS_DESC, "$prefs->work_buf_additional_days days");
760
row2(CONFIRM_BEFORE_CONNECTING_DESC, $prefs->confirm_before_connecting?"yes":"no");
761
row2(HANGUP_IF_DIALED_DESC, $prefs->hangup_if_dialed?"yes":"no");
762
$x = max_bytes_display_mode($prefs->max_bytes_sec_down);
763
$y = "$x " . BYTE_ABBR;
764
row2(MAX_BYTES_SEC_DOWN_DESC, $x?"$y":"no limit");
765
$x = max_bytes_display_mode($prefs->max_bytes_sec_up);
766
$y = "$x " . BYTE_ABBR;
767
row2(MAX_BYTES_SEC_UP_DESC, $x?"$y":"no limit");
768
if ($prefs->net_start_hour == $prefs->net_end_hour) {
769
$x = "(no restriction)";
771
$s = hour_str($prefs->net_start_hour);
772
$e = hour_str($prefs->net_end_hour);
775
row2(NET_START_END_DESC, $x);
776
row2(DONT_VERIFY_IMAGES_DESC, $prefs->dont_verify_images?"yes":"no");
779
function prefs_show_resource($prefs, $columns=false) {
780
$x = "Resource share<br>
781
<span class=note>If you participate in multiple BOINC projects,
782
this is the proportion of your resources used by ".PROJECT."</span>";
784
row_defs($x, "resource_share", "", "" ,$prefs);
786
row2($x, $prefs->resource_share);
790
function prefs_show_beta($prefs, $columns=false) {
792
row_defs(ALLOW_BETA_WORK, "allow_beta_work_text", "", "" ,$prefs);
794
row2(ALLOW_BETA_WORK, $prefs->allow_beta_work_text);
798
function prefs_show_privacy($user) {
800
if (defined('EMAIL_FROM')) {
801
$x = "<br><span class=note>Emails will be sent from ".EMAIL_FROM.";
802
make sure your spam filter accepts this address.</span>";
804
row2("Is it OK for ".PROJECT." and your team (if any) to email you? $x",
805
$user->send_email?"yes":"no"
807
row2("Should ".PROJECT." show your computers on its web site?", $user->show_hosts?"yes":"no");
746
foreach ($net_prefs as $p) {
810
751
function prefs_show_project($prefs, $columns=false) {
752
global $project_pref_descs;
754
foreach ($project_pref_descs as $p) {
755
$p->show_cols($prefs);
758
foreach ($project_pref_descs as $p) {
764
function prefs_show_privacy($user, $columns) {
765
global $privacy_pref_descs;
767
foreach ($privacy_pref_descs as $p) {
768
$p->show_cols($user);
771
foreach ($privacy_pref_descs as $p) {
777
function prefs_show_project_specific($prefs, $columns=false) {
812
779
$project_specific_prefs = project_specific_prefs_parse($prefs->project_specific);
813
780
$project_specific_prefs->home = isset($prefs->home) ? project_specific_prefs_parse($prefs->home->project_specific) : "";
822
789
function subset_name($subset) {
823
if ($subset == "global") return "Computing";
790
if ($subset == "global") return tra("Computing");
827
794
function prefs_display_venue($prefs, $venue, $subset) {
828
global $project_has_beta;
829
795
global $g_logged_in_user;
830
796
$tokens = url_tokens($g_logged_in_user->authenticator);
832
798
if (isset($prefs->$venue)) $x = $prefs->$venue;
835
row1("Separate preferences for $venue", 2, "heading");
801
row1(tra("Separate preferences for %1", $venue), 2, "heading");
836
802
echo "<tr><td colspan=2>";
838
804
if ($subset == "global") {
839
805
prefs_show_global($x);
841
prefs_show_resource($x);
842
if ($project_has_beta) prefs_show_beta($x);
843
807
prefs_show_project($x);
808
prefs_show_project_specific($x);
845
row2("<br>", "<a href=prefs_edit.php?venue=$venue&subset=$subset$tokens>Edit preferences</a> | <a href=prefs_remove.php?venue=$venue&subset=$subset$tokens>Remove</a>");
810
row2("<br>", "<a href=prefs_edit.php?venue=$venue&subset=$subset$tokens>".tra("Edit preferences")."</a> | <a href=prefs_remove.php?venue=$venue&subset=$subset$tokens>".tra("Remove")."</a>");
847
812
echo "</td></tr>\n";
849
//$x = subset_name($subset);
850
row1("<a href=add_venue.php?venue=$venue&subset=$subset$tokens>Add separate preferences for $venue</a>", 2, "heading");
814
row1("<a href=add_venue.php?venue=$venue&subset=$subset$tokens>".tra("Add separate preferences for %1", $venue)."</a>", 2, "heading");
854
818
function print_prefs_display_project($user, $columns=false) {
855
global $project_has_beta;
856
819
$project_prefs = prefs_parse_project($user->project_prefs);
859
$switch_link = " <font size=\"-2\"><a href=prefs.php?subset=project&cols=". (int)!$columns .">(Switch View)</a></font>";
822
$switch_link = " <font size=\"-2\"><a href=prefs.php?subset=project&cols=". (int)!$columns .">".tra("(Switch View)")."</a></font>";
861
row1("Combined preferences".$switch_link, 2, "heading");
824
row1(tra("Combined preferences").$switch_link, 2, "heading");
862
825
echo "<tr><td colspan=2>";
864
prefs_show_privacy($user);
827
prefs_show_privacy($user, true);
865
828
venue_show($user);
866
row_top("Project specific settings");
867
prefs_show_resource($project_prefs, true);
868
if ($project_has_beta) prefs_show_beta($project_prefs, true);
829
row_top(tra("Project specific settings"));
869
830
prefs_show_project($project_prefs, true);
831
prefs_show_project_specific($project_prefs, true);
870
832
row_links("project", $project_prefs);
872
834
echo "</td></tr>\n";
874
836
if (isset($project_prefs->home) || isset($project_prefs->work) || isset($project_prefs->school)) {
875
row1("Primary (default) preferences".$switch_link, 2, "heading");
837
row1(tra("Primary (default) preferences").$switch_link, 2, "heading");
877
839
echo "<tr><td colspan=2>";
879
prefs_show_resource($project_prefs, false);
880
if ($project_has_beta) prefs_show_beta($project_prefs, false);
881
prefs_show_privacy($user);
883
841
prefs_show_project($project_prefs, false);
842
prefs_show_privacy($user, false);
844
prefs_show_project_specific($project_prefs, false);
884
845
$tokens = url_tokens($user->authenticator);
885
row2("", "<a href=prefs_edit.php?subset=project$tokens>Edit ".PROJECT." preferences</a>");
846
row2("", "<a href=prefs_edit.php?subset=project$tokens>".tra("Edit %1 preferences", PROJECT)."</a>");
887
848
echo "</td></tr>\n";
888
849
prefs_display_venue($project_prefs, "home", "project");
998
948
// Functions to display preference subsets as forms
1000
950
function prefs_form_global($user, $prefs, $error=false) {
1001
//echo "IN PREFS_FORM_GLOBAL: <pre>";
1004
955
row1(CPU_LIMIT_DESC);
1005
$y = "yes <input type=radio name=suspend_while_on_batteries value=yes "
1006
.($prefs->suspend_while_on_batteries?"checked":"")
1007
."> no <input type=radio name=suspend_while_on_batteries value=no "
1008
.($prefs->suspend_while_on_batteries?"":"checked")
1011
row2(SUSPEND_WHILE_ON_BATTERIES_DESC, $y);
1013
$y = "yes <input type=radio name=suspend_if_user_active value=yes "
1014
.($prefs->suspend_if_user_active?"checked":"")
1015
."> no <input type=radio name=suspend_if_user_active value=no "
1016
.($prefs->suspend_if_user_active?"":"checked")
1019
row2(RUN_IF_USER_ACTIVE_DESC, $y);
1021
$y = "<input size=5 name=idle_time_to_run value='$prefs->idle_time_to_run'> minutes ";
1022
$show_error = false;
1023
if (isset($error->idle_time_to_run)) $show_error= true;
1024
row2(IDLE_TIME_TO_RUN_DESC, $y, $show_error);
1026
$y = "<input size=5 name=suspend_if_no_recent_input value='$prefs->suspend_if_no_recent_input'> minutes ";
1027
$show_error = false;
1028
if (isset($error->suspend_if_no_recent_input)) $show_error= true;
1029
row2(SUSPEND_IF_NO_RECENT_INPUT_DESC, $y, $show_error);
1031
$x = START_END_DESC.START_END_DESC2;
1032
$y = hour_select($prefs->start_hour, "start_hour")."and".hour_select($prefs->end_hour, "end_hour");
1035
$x = LEAVE_APPS_IN_MEMORY_DESC;
1036
$y = "yes <input type=radio name=leave_apps_in_memory value=yes "
1037
.($prefs->leave_apps_in_memory?"checked":"")
1038
."> no <input type=radio name=leave_apps_in_memory value=no "
1039
.($prefs->leave_apps_in_memory?"":"checked")
1044
$y = "<input size=5 name=cpu_scheduling_period_minutes value='$prefs->cpu_scheduling_period_minutes'> minutes ";
1045
$show_error = false;
1046
if (isset($error->cpu_scheduling_period_minutes)) $show_error= true;
1047
row2(CPU_SCHEDULING_DESC, $y, $show_error);
1049
$show_error = false;
1050
if (isset($error->max_cpus)) $show_error= true;
1052
"<input size=4 name=max_cpus value=$prefs->max_cpus> ".MAX_CPUS_DESC2,
1056
$show_error = false;
1057
if (isset($error->max_ncpus_pct)) $show_error= true;
1058
row2(MAX_NCPUS_PCT_DESC,
1059
"<input size=4 name=max_ncpus_pct value=$prefs->max_ncpus_pct> ".MAX_NCPUS_PCT_DESC2,
1063
$show_error = false;
1064
if (isset($error->cpu_usage_limit)) $show_error= true;
1066
"<input size=4 name=cpu_usage_limit value=$prefs->cpu_usage_limit> ".CPU_USAGE_LIMIT_DESC2,
956
foreach ($cpu_prefs as $p) {
957
$p->show_form_row($prefs, $error);
1070
959
row1(DISK_LIMIT_DESC);
1072
$show_error = false;
1073
if (isset($error->disk_max_used_gb)) $show_error= true;
1075
"<input size=7 name=disk_max_used_gb value='$prefs->disk_max_used_gb'> Gbytes",
1079
$dp = get_disk_space_config();
1082
if ($dp->new_sched_flag) {
1083
$msg = DISK_SCHED_MIN_FREE_DESC1.$dp->sched_disk_min_free_gb.DISK_SCHED_MIN_FREE_DESC2;
1086
$show_error = false;
1087
if (isset($error->disk_min_free_gb)) $show_error= true;
1088
row2(DISK_MIN_FREE_GB_DESC.$msg,
1089
"<input size=7 name=disk_min_free_gb value='$prefs->disk_min_free_gb'> Gbytes free",
1093
$show_error = false;
1094
if (isset($error->disk_max_used_pct)) $show_error= true;
1096
"<input size=5 name=disk_max_used_pct value='$prefs->disk_max_used_pct'> ".DISK_MAX_USED_PCT_DESC2,
1100
$show_error = false;
1101
if (isset($error->disk_interval)) $show_error= true;
1102
row2(DISK_INTERVAL_DESC,
1103
"<input size=6 name=disk_interval value=$prefs->disk_interval> seconds",
1107
$show_error = false;
1108
if (isset($error->vm_max_used_pct)) $show_error= true;
1110
"<input size=5 name=vm_max_used_pct value='$prefs->vm_max_used_pct'> ".VM_MAX_USED_PCT_DESC2,
1114
$show_error = false;
1115
if (isset($error->ram_max_used_busy_pct)) $show_error= true;
1117
"<input size=5 name=ram_max_used_busy_pct value='$prefs->ram_max_used_busy_pct'> ".RAM_MAX_USED_BUSY_PCT_DESC2,
1121
$show_error = false;
1122
if (isset($error->ram_max_used_idle_pct)) $show_error= true;
1124
"<input size=5 name=ram_max_used_idle_pct value='$prefs->ram_max_used_idle_pct'> ".RAM_MAX_USED_IDLE_PCT_DESC2,
960
foreach ($disk_prefs as $p) {
961
$p->show_form_row($prefs, $error);
1128
963
row1(NETWORK_LIMIT_DESC);
1129
$x = WORK_BUF_MIN_DAYS_DESC;
1130
$y = "<input size=5 name=work_buf_min_days value='$prefs->work_buf_min_days'> days";
1131
$show_error = false;
1132
if (isset($error->work_buf_min_days)) $show_error= true;
1133
row2($x, $y, $show_error);
1135
$x = WORK_BUF_ADDITIONAL_DAYS_DESC;
1136
$y = "<input size=5 name=work_buf_additional_days value='$prefs->work_buf_additional_days'> days";
1137
$show_error = false;
1138
if (isset($error->work_buf_additional_days)) $show_error= true;
1139
row2($x, $y, $show_error);
1141
$x = CONFIRM_BEFORE_CONNECTING_DESC;
1142
$y = "yes <input type=radio name=confirm_before_connecting value=yes "
1143
.($prefs->confirm_before_connecting?"checked":"")
1144
."> no <input type=radio name=confirm_before_connecting value=no "
1145
.($prefs->confirm_before_connecting?"":"checked")
1150
$x = HANGUP_IF_DIALED_DESC;
1151
$y = "yes <input type=radio name=hangup_if_dialed value=yes "
1152
.($prefs->hangup_if_dialed?"checked":"")
1153
."> no <input type=radio name=hangup_if_dialed value=no "
1154
.($prefs->hangup_if_dialed?"":"checked")
1159
$d = max_bytes_display_mode($prefs->max_bytes_sec_down);
1161
$u = max_bytes_display_mode($prefs->max_bytes_sec_up);
1164
$show_error = false;
1165
if (isset($error->max_bytes_sec_down)) $show_error= true;
1166
row2(MAX_BYTES_SEC_DOWN_DESC,
1167
"<input size=7 name=max_bytes_sec_down value='$dt'> " . BYTE_UNITS,
1171
$show_error = false;
1172
if (isset($error->max_bytes_sec_up)) $show_error= true;
1173
row2(MAX_BYTES_SEC_UP_DESC,
1174
"<input size=7 name=max_bytes_sec_up value='$ut'> " . BYTE_UNITS,
1178
$x = NET_START_END_DESC.START_END_DESC2;
1179
$y = hour_select($prefs->net_start_hour, "net_start_hour")."and".hour_select($prefs->net_end_hour, "net_end_hour");
1181
$x = DONT_VERIFY_IMAGES_DESC;
1182
$y = "yes <input type=radio name=dont_verify_images value=yes "
1183
.($prefs->dont_verify_images?"checked":"")
1184
."> no <input type=radio name=dont_verify_images value=no "
1185
.($prefs->dont_verify_images?"":"checked")
964
foreach ($net_prefs as $p) {
965
$p->show_form_row($prefs, $error);
1192
969
function prefs_form_privacy($user) {
1193
$y = "yes <input type=radio name=send_email value=yes "
1194
.($user->send_email?"checked":"")
1195
."> no <input type=radio name=send_email value=no "
1196
.($user->send_email?"":"checked")
1199
row2("Is it OK for ".PROJECT." and your team (if any) to email you?", $y);
1201
$y = "yes <input type=radio name=show_hosts value=yes "
1202
.($user->show_hosts?"checked":"")
1203
."> no <input type=radio name=show_hosts value=no "
1204
.($user->show_hosts?"":"checked")
1207
row2("Should ".PROJECT." show your computers on its web site?", $y);
1210
function prefs_form_resource($prefs, $error=false) {
1211
$show_error = false;
1212
if (isset($error->resource_share)) $show_error= true;
1214
"<b>Resource share:</b>
1215
<span class=note><br>Determines the proportion of your computer's resources
1216
allocated to this project.
1217
Example: if you participate in two BOINC projects with
1218
resource shares of 100 and 200,
1219
the first will get 1/3 of your resources and the second will get 2/3.
1221
"<input name=resource_share value='$prefs->resource_share'>",
1226
function prefs_form_beta($prefs, $error=false) {
1227
$ychecked = $prefs->allow_beta_work?"checked":"";
1228
$nchecked = $prefs->allow_beta_work?"":"checked";
1231
"yes <input type=radio checkbox name=allow_beta_work value=1 $ychecked>
1232
no <input type=radio checkbox name=allow_beta_work value=0 $nchecked>"
1236
function prefs_form_project($prefs_xml, $error=false) {
970
global $privacy_pref_descs;
971
foreach ($privacy_pref_descs as $p) {
972
$p->show_form_row($user, false);
976
function prefs_form_project($prefs, $error=false) {
977
global $project_pref_descs;
978
foreach ($project_pref_descs as $p) {
979
$p->show_form_row($prefs, $error);
983
function prefs_form_project_specific($prefs_xml, $error=false) {
1237
984
$prefs = project_specific_prefs_parse($prefs_xml);
1238
985
project_specific_prefs_edit($prefs, $error);
988
// returns a set of translated yes/no radio buttons for editing prefs forms
989
// Example: prefs_form_radio_buttons("allow_beta_work", $user->allow_beta_work);
991
// @param string $name name of the radio buttons
992
// @param bool $yesno toggles the preset of the buttons; true=yes, false=no
994
function prefs_form_radio_buttons($name, $yesno) {
995
$rb = tra("yes")." <input type=radio name=$name value=yes "
996
.($yesno?"checked":"")
997
."> ".tra("no")." <input type=radio name=$name value=no "
998
.($yesno?"":"checked")
1241
1003
function venue_show($user) {
1242
1004
$venue = $user->venue;
1243
1005
if ($venue =='') $venue = '---';
1244
row2("Default computer location", $venue);
1006
row2(tra("Default computer location"), $venue);
1247
1009
function venue_form($user) {
1275
1037
// returns an object with errorvalues or false in success case
1277
1039
function prefs_global_parse_form(&$prefs) {
1278
1044
$error = false;
1279
$suspend_while_on_batteries = $_GET["suspend_while_on_batteries"];
1280
$suspend_if_user_active = $_GET["suspend_if_user_active"];
1281
$idle_time_to_run = $_GET["idle_time_to_run"];
1282
$suspend_if_no_recent_input = $_GET["suspend_if_no_recent_input"];
1283
$start_hour = $_GET["start_hour"];
1284
$end_hour = $_GET["end_hour"];
1285
$leave_apps_in_memory = $_GET["leave_apps_in_memory"];
1286
$cpu_scheduling_period_minutes = $_GET["cpu_scheduling_period_minutes"];
1287
$max_cpus = $_GET["max_cpus"];
1288
$max_ncpus_pct = $_GET["max_ncpus_pct"];
1289
$cpu_usage_limit = $_GET["cpu_usage_limit"];
1290
$disk_max_used_gb = $_GET["disk_max_used_gb"];
1291
$disk_min_free_gb = $_GET["disk_min_free_gb"];
1292
$disk_max_used_pct = $_GET["disk_max_used_pct"];
1293
$disk_interval = $_GET["disk_interval"];
1294
$vm_max_used_pct = $_GET["vm_max_used_pct"];
1295
$ram_max_used_busy_pct = $_GET["ram_max_used_busy_pct"];
1296
$ram_max_used_idle_pct = $_GET["ram_max_used_idle_pct"];
1297
$work_buf_min_days = $_GET["work_buf_min_days"];
1298
$work_buf_additional_days = $_GET["work_buf_additional_days"];
1299
$confirm_before_connecting = $_GET["confirm_before_connecting"];
1300
$hangup_if_dialed = $_GET["hangup_if_dialed"];
1301
$max_bytes_sec_down = $_GET["max_bytes_sec_down"];
1302
$max_bytes_sec_up = $_GET["max_bytes_sec_up"];
1303
$net_start_hour = $_GET["net_start_hour"];
1304
$net_end_hour = $_GET["net_end_hour"];
1305
$dont_verify_images = $_GET["dont_verify_images"];
1306
// Verification of all user input values
1307
if (!verify_numeric($idle_time_to_run, 1)) $error->idle_time_to_run = true;
1308
if (!verify_numeric($suspend_if_no_recent_input, 0)) $error->suspend_if_no_recent_input = true;
1309
if (!verify_numeric($start_hour, 0)) $error->start_hour = true;
1310
if (!verify_numeric($end_hour, 0)) $error->end_hour = true;
1311
if (!verify_numeric($cpu_scheduling_period_minutes, 1)) $error->cpu_scheduling_period_minutes = true;;
1312
if (!verify_numeric($max_cpus, 0)) $error->max_cpus = true;
1313
if (!verify_numeric($max_ncpus_pct, 0, 100)) $error->max_ncpus_pct = true;
1314
if (!verify_numeric($cpu_usage_limit, 0, 100)) $error->cpu_usage_limit = true;
1315
if (!verify_numeric($disk_max_used_gb, 0)) $error->disk_max_used_gb = true;
1316
if (!verify_numeric($disk_min_free_gb, 0.001)) $error->disk_min_free_gb = true;
1317
if (!verify_numeric($disk_max_used_pct, 0, 100)) $error->disk_max_used_pct = true;
1318
if (!verify_numeric($disk_interval, 0)) $error->disk_interval = true;
1319
if (!verify_numeric($vm_max_used_pct, 0, 100)) $error->vm_max_used_pct = true;
1320
if (!verify_numeric($ram_max_used_busy_pct, 0, 100)) $error->ram_max_used_busy_pct = true;
1321
if (!verify_numeric($ram_max_used_idle_pct, 0, 100)) $error->ram_max_used_idle_pct = true;
1322
if (!verify_numeric($work_buf_min_days, 0, 10)) $error->work_buf_min_days = true;
1323
if (!verify_numeric($work_buf_additional_days, 0, 10)) $error->work_buf_additional_days = true;
1324
if (!verify_numeric($max_bytes_sec_down, '')) $error->max_bytes_sec_down = true;
1325
if (!verify_numeric($max_bytes_sec_up, '')) $error->max_bytes_sec_up = true;
1326
if (!verify_numeric($net_start_hour, 0)) $error->net_start_hour = true;
1327
if (!verify_numeric($net_end_hour, 0)) $error->net_end_hour = true;
1328
// Modify all values within the supplied Object
1329
$prefs->suspend_while_on_batteries = ($suspend_while_on_batteries == "yes");
1330
$prefs->suspend_if_user_active = ($suspend_if_user_active == "yes");
1331
$prefs->idle_time_to_run = $idle_time_to_run;
1332
$prefs->suspend_if_no_recent_input = $suspend_if_no_recent_input;
1333
$prefs->start_hour = $start_hour;
1334
$prefs->end_hour = $end_hour;
1335
$prefs->leave_apps_in_memory = ($leave_apps_in_memory == "yes");
1336
$prefs->cpu_scheduling_period_minutes = $cpu_scheduling_period_minutes;
1337
$prefs->max_cpus = $max_cpus;
1338
$prefs->max_ncpus_pct = $max_ncpus_pct;
1339
$prefs->cpu_usage_limit = $cpu_usage_limit;
1340
$prefs->disk_max_used_gb = $disk_max_used_gb;
1341
$prefs->disk_min_free_gb = $disk_min_free_gb;
1342
$prefs->disk_max_used_pct = $disk_max_used_pct;
1343
$prefs->disk_interval = $disk_interval;
1344
$prefs->vm_max_used_pct = $vm_max_used_pct;
1345
$prefs->ram_max_used_busy_pct = $ram_max_used_busy_pct;
1346
$prefs->ram_max_used_idle_pct = $ram_max_used_idle_pct;
1347
$prefs->work_buf_min_days = $work_buf_min_days;
1348
$prefs->work_buf_additional_days = $work_buf_additional_days;
1349
$prefs->confirm_before_connecting = ($confirm_before_connecting == "yes");
1350
$prefs->hangup_if_dialed = ($hangup_if_dialed == "yes");
1351
$prefs->max_bytes_sec_down = max_bytes_db_mode($max_bytes_sec_down);
1352
$prefs->max_bytes_sec_up = max_bytes_db_mode($max_bytes_sec_up);
1353
$prefs->net_start_hour = $net_start_hour;
1354
$prefs->net_end_hour = $net_end_hour;
1355
$prefs->dont_verify_images = ($dont_verify_images == "yes");
1045
foreach ($cpu_prefs as $p) {
1046
$p->parse_form($prefs, $error);
1048
foreach ($disk_prefs as $p) {
1049
$p->parse_form($prefs, $error);
1051
foreach ($net_prefs as $p) {
1052
$p->parse_form($prefs, $error);
1360
// This functions parses and verifies the resource value
1361
// @param object &$prefs reference to object that stores prefs
1362
// @return object an object with errorvalues or false in success case
1363
1057
function prefs_resource_parse_form(&$prefs) {
1058
global $project_pref_descs;
1364
1059
$error = false;
1365
$resource_share = $_GET['resource_share'];
1366
if (!verify_numeric($resource_share, 0)) $error->resource_share = true;
1367
$prefs->resource_share = $resource_share;
1060
foreach ($project_pref_descs as $p) {
1061
$p->parse_form($prefs, $error);
1372
function prefs_beta_parse_form(&$prefs) {
1373
$prefs->allow_beta_work = false;
1374
$prefs->allow_beta_work_text = "no";
1375
$x = $_GET['allow_beta_work'];
1377
$prefs->allow_beta_work = true;
1378
$prefs->allow_beta_work_text = "yes";
1382
1066
function prefs_privacy_parse_form(&$user) {
1383
$user->send_email = ($_GET['send_email'] == "yes")?1:0;
1384
$user->show_hosts = ($_GET['show_hosts'] == "yes")?1:0;
1067
global $privacy_pref_descs;
1069
foreach ($privacy_pref_descs as $p) {
1070
$p->parse_form($user, $error);
1387
// This function parses the project specific prefs form.
1388
// For details look into project/project_specific_prefs.inc
1389
// @param object &$prefs refernce to preference object
1390
// @return object an object with errorvalues or false in success case
1075
// Parse the project specific prefs form.
1076
// For details see project/project_specific_prefs.inc
1391
1078
function prefs_project_parse_form(&$prefs) {
1392
1079
$error = false;
1393
1080
$prefs->project_specific = project_specific_prefs_parse_form($error);
1400
1087
// convert prefs from structure to XML
1402
1089
function global_prefs_make_xml($prefs, $primary=true) {
1403
// N.B.: each XML entry must end with \n due to the sloppy parsing by the
1406
1095
if ($primary) {
1407
1096
$xml = "<global_preferences>\n";
1409
1098
$xml = $xml."<mod_time>$now</mod_time>\n";
1411
if (!$prefs->suspend_while_on_batteries) {
1412
$xml = $xml."<run_on_batteries/>\n";
1414
if (!$prefs->suspend_if_user_active) {
1415
$xml = $xml."<run_if_user_active/>\n";
1417
$xml = $xml."<idle_time_to_run>$prefs->idle_time_to_run</idle_time_to_run>\n";
1418
$xml = $xml."<suspend_if_no_recent_input>$prefs->suspend_if_no_recent_input</suspend_if_no_recent_input>\n";
1420
if ($prefs->start_hour != $prefs->end_hour) {
1421
$xml = $xml."<start_hour>$prefs->start_hour</start_hour>\n"
1422
."<end_hour>$prefs->end_hour</end_hour>\n";
1424
if ($prefs->leave_apps_in_memory) {
1425
$xml = $xml."<leave_apps_in_memory/>\n";
1427
$xml = $xml."<cpu_scheduling_period_minutes>$prefs->cpu_scheduling_period_minutes</cpu_scheduling_period_minutes>\n";
1428
if ($prefs->confirm_before_connecting) {
1429
$xml = $xml."<confirm_before_connecting/>\n";
1431
if ($prefs->hangup_if_dialed) {
1432
$xml = $xml."<hangup_if_dialed/>\n";
1435
."<work_buf_min_days>$prefs->work_buf_min_days</work_buf_min_days>\n"
1436
."<work_buf_additional_days>$prefs->work_buf_additional_days</work_buf_additional_days>\n"
1437
."<max_cpus>$prefs->max_cpus</max_cpus>\n"
1438
."<max_ncpus_pct>$prefs->max_ncpus_pct</max_ncpus_pct>\n"
1439
."<cpu_usage_limit>$prefs->cpu_usage_limit</cpu_usage_limit>\n"
1440
."<disk_interval>$prefs->disk_interval</disk_interval>\n";
1442
."<disk_max_used_gb>$prefs->disk_max_used_gb</disk_max_used_gb>\n"
1443
."<disk_max_used_pct>$prefs->disk_max_used_pct</disk_max_used_pct>\n"
1444
."<disk_min_free_gb>$prefs->disk_min_free_gb</disk_min_free_gb>\n"
1445
."<vm_max_used_pct>$prefs->vm_max_used_pct</vm_max_used_pct>\n"
1446
."<ram_max_used_busy_pct>$prefs->ram_max_used_busy_pct</ram_max_used_busy_pct>\n"
1447
."<ram_max_used_idle_pct>$prefs->ram_max_used_idle_pct</ram_max_used_idle_pct>\n"
1448
."<max_bytes_sec_down>$prefs->max_bytes_sec_down</max_bytes_sec_down>\n"
1449
."<max_bytes_sec_up>$prefs->max_bytes_sec_up</max_bytes_sec_up>\n";
1450
if ($prefs->net_start_hour != $prefs->net_end_hour) {
1451
$xml = $xml."<net_start_hour>$prefs->net_start_hour</net_start_hour>\n"
1452
."<net_end_hour>$prefs->net_end_hour</net_end_hour>\n";
1454
if ($prefs->dont_verify_images) {
1455
$xml = $xml."<dont_verify_images/>\n";
1101
foreach ($cpu_prefs as $p) {
1102
$xml .= $p->xml_string($prefs);
1104
foreach ($disk_prefs as $p) {
1105
$xml .= $p->xml_string($prefs);
1107
foreach ($net_prefs as $p) {
1108
$xml .= $p->xml_string($prefs);
1457
1111
if (isset($prefs->home)) {
1458
1112
$xml = $xml."<venue name=\"home\">\n".global_prefs_make_xml($prefs->home, false)."</venue>\n";