@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | echo "can't add user"; |
36 | 36 | exit(); |
37 | 37 | } |
38 | - $sex = rand(1,2); |
|
38 | + $sex = rand(1, 2); |
|
39 | 39 | $birth_year = rand(1938, 1998); |
40 | 40 | BoltUser::insert("(user_id, sex, birth_year) values ($uid, $sex, $birth_year)"); |
41 | 41 | return $uid; |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | // Score for alternative X is C +- D |
64 | 64 | // |
65 | 65 | function compare_gen( |
66 | - $select_name, // name of select unit |
|
67 | - $xset_name, // name of exercise set |
|
68 | - $n, // number of records to create |
|
69 | - $a1, $d1, // avg and dev of default score |
|
70 | - $x, // name of chosen alternative |
|
66 | + $select_name, // name of select unit |
|
67 | + $xset_name, // name of exercise set |
|
68 | + $n, // number of records to create |
|
69 | + $a1, $d1, // avg and dev of default score |
|
70 | + $x, // name of chosen alternative |
|
71 | 71 | $a2, $d2 // avg and dev of score for chosen alternative |
72 | 72 | ) { |
73 | 73 | global $course; |
@@ -76,12 +76,12 @@ discard block |
||
76 | 76 | if (!$select_unit) error_page("no such select unit"); |
77 | 77 | if (!lookup_unit($top_unit, $xset_name)) error_page("no such xset"); |
78 | 78 | $m = count($select_unit->units); |
79 | - for ($i=0; $i<$n; $i++) { |
|
79 | + for ($i = 0; $i < $n; $i++) { |
|
80 | 80 | $uid = random_student(); |
81 | 81 | $t1 = time(); |
82 | - $t2 = $t1+1; |
|
82 | + $t2 = $t1 + 1; |
|
83 | 83 | |
84 | - $j = rand(0, $m-1); |
|
84 | + $j = rand(0, $m - 1); |
|
85 | 85 | $child = $select_unit->units[$j]; |
86 | 86 | BoltSelectFinished::insert("(user_id, course_id, end_time, name, selected_unit) values ($uid, $course->id, $t1, '$select_name', '$child->name')"); |
87 | 87 | |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | global $course; |
110 | 110 | |
111 | 111 | $top_unit = require_once($course->doc_file()); |
112 | - for ($i=0; $i<$n; $i++) { |
|
112 | + for ($i = 0; $i < $n; $i++) { |
|
113 | 113 | $uid = random_student(); |
114 | 114 | $user = BoincUser::lookup_id($uid); |
115 | 115 | BoltUser::lookup($user); |
116 | - $sb = ($sel->categorize($user) == $sel_cat)?$sb2:$sb1; |
|
116 | + $sb = ($sel->categorize($user) == $sel_cat) ? $sb2 : $sb1; |
|
117 | 117 | map_gen_uid($uid, $top_unit, $sb); |
118 | 118 | } |
119 | 119 | } |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | |
208 | 208 | if (1) { |
209 | 209 | compare_gen( |
210 | - 'Conifer/deciduous alternative', // select name |
|
211 | - 'Intro exercises', // xset name |
|
212 | - 50, // # of records to create |
|
213 | - .5, .3, // mean and dev of default score |
|
214 | - 'conifer_decid2.php', // name of chosen alternative |
|
210 | + 'Conifer/deciduous alternative', // select name |
|
211 | + 'Intro exercises', // xset name |
|
212 | + 50, // # of records to create |
|
213 | + .5, .3, // mean and dev of default score |
|
214 | + 'conifer_decid2.php', // name of chosen alternative |
|
215 | 215 | .8, .2 // mean and dev of score for that alternative |
216 | 216 | ); |
217 | 217 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | function mean($x) { |
33 | 33 | $sum = 0; |
34 | 34 | $n = count($x); |
35 | - for ($i=0; $i<$n; $i++) { |
|
35 | + for ($i = 0; $i < $n; $i++) { |
|
36 | 36 | $sum += $x[$i]; |
37 | 37 | } |
38 | 38 | return $sum/$n; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $sum = 0; |
43 | 43 | $n = count($x); |
44 | 44 | $m = mean($x); |
45 | - for ($i=0; $i<$n; $i++) { |
|
45 | + for ($i = 0; $i < $n; $i++) { |
|
46 | 46 | $d = $x[$i] - $m; |
47 | 47 | $sum += $d*$d; |
48 | 48 | //echo "$x[$i] "; |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | // returns the claimed credit for a given result/host and FP weight |
57 | 57 | // |
58 | 58 | function cc($x, $fpw) { |
59 | - $cps = $x->p_fpops*$fpw + $x->p_iops*(1-$fpw); |
|
59 | + $cps = $x->p_fpops*$fpw + $x->p_iops*(1 - $fpw); |
|
60 | 60 | $cps /= 1e9; |
61 | 61 | $cps /= 864; |
62 | - $cc = $x->cpu_time * $cps; |
|
62 | + $cc = $x->cpu_time*$cps; |
|
63 | 63 | return $cc; |
64 | 64 | } |
65 | 65 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $nwus = 4000; |
85 | 85 | |
86 | 86 | $sum = array(); |
87 | - for ($i=0; $i<=10; $i++) { |
|
87 | + for ($i = 0; $i <= 10; $i++) { |
|
88 | 88 | $sum[] = 0; |
89 | 89 | } |
90 | 90 | $r1 = _mysql_query( |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $r2 = _mysql_query("select * from result where workunitid=$wu->id"); |
97 | 97 | $found_zero = false; |
98 | 98 | while ($result = _mysql_fetch_object($r2)) { |
99 | - if ($result->granted_credit==0) continue; // skip invalid |
|
99 | + if ($result->granted_credit == 0) continue; // skip invalid |
|
100 | 100 | $host = BoincHost::lookup_id($result->hostid); |
101 | 101 | $r = new StdClass; |
102 | 102 | $r->cpu_time = $result->cpu_time; |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | $results[] = $r; |
106 | 106 | } |
107 | 107 | //echo "Wu $wu->id -------------\n"; |
108 | - if (count($results)<2) continue; |
|
109 | - for ($i=0; $i<=10; $i++) { |
|
108 | + if (count($results) < 2) continue; |
|
109 | + for ($i = 0; $i <= 10; $i++) { |
|
110 | 110 | $fpw = $i/10.; |
111 | 111 | $sum[$i] += fpw_var($results, $fpw); |
112 | 112 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | Number of workunits analyzed: $n |
121 | 121 | |
122 | 122 | "; |
123 | - for ($i=0; $i<=10; $i++) { |
|
123 | + for ($i = 0; $i <= 10; $i++) { |
|
124 | 124 | $fpw = $i/10.; |
125 | 125 | $r = $sum[$i]/$n; |
126 | 126 | echo "FP weight $fpw: variance is $r\n"; |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $cli_only = true; |
23 | 23 | require_once("../inc/util_ops.inc"); |
24 | 24 | |
25 | -$max_age_days = 90; // lock threads older than this |
|
25 | +$max_age_days = 90; // lock threads older than this |
|
26 | 26 | if ($argc > 2) { |
27 | 27 | if ($argv[1] == "--ndays") { |
28 | 28 | $max_age_days = $argv[2]; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | return $lines; |
42 | 42 | } |
43 | 43 | |
44 | -function write_count_file($n,$m) { |
|
44 | +function write_count_file($n, $m) { |
|
45 | 45 | $f = fopen("nresults", "w"); |
46 | 46 | if (!$f) return false; |
47 | 47 | $x = sprintf("%d\n%d\n", $n, $m); |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | } |
81 | 81 | $n = read_count_file(); |
82 | 82 | if ($n == false) { |
83 | - write_count_file($m,$p); |
|
83 | + write_count_file($m, $p); |
|
84 | 84 | exit(); |
85 | 85 | } |
86 | 86 | if (trim($n[0]) == $m && trim($n[1]) == $p) { |
87 | 87 | fail("Result count hasn't changed\n"); |
88 | 88 | } |
89 | - write_count_file($m,$p); |
|
89 | + write_count_file($m, $p); |
|
90 | 90 | |
91 | 91 | ?> |
@@ -63,7 +63,7 @@ |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | $calibration = false; |
66 | -for ($i=1; $i<$argc; $i++) { |
|
66 | +for ($i = 1; $i < $argc; $i++) { |
|
67 | 67 | if ($argv[$i] == '--app_name') $app_name = $argv[++$i]; |
68 | 68 | elseif ($argv[$i] == '--dir') $dir = $argv[++$i]; |
69 | 69 | elseif ($argv[$i] == '--calibration') $calibration = true; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | function find_oldest() { |
44 | - $result=_mysql_query("select name,create_time from result where server_state=2 order by create_time limit 1"); |
|
44 | + $result = _mysql_query("select name,create_time from result where server_state=2 order by create_time limit 1"); |
|
45 | 45 | $x = _mysql_fetch_object($result); |
46 | 46 | return $x->create_time; |
47 | 47 | } |
@@ -88,25 +88,25 @@ discard block |
||
88 | 88 | |
89 | 89 | |
90 | 90 | |
91 | -$dbrc = db_init(1); // 1=soft, remember that DB might be down |
|
91 | +$dbrc = db_init(1); // 1=soft, remember that DB might be down |
|
92 | 92 | |
93 | -page_head(PROJECT . " - Server Status"); |
|
93 | +page_head(PROJECT." - Server Status"); |
|
94 | 94 | |
95 | 95 | |
96 | 96 | // Date stamp |
97 | 97 | |
98 | 98 | |
99 | -echo "<br ALIGN=RIGHT> ".PROJECT. " server status as of ". |
|
100 | - date("g:i A T"). " on ". date("l, j F Y ") . |
|
99 | +echo "<br ALIGN=RIGHT> ".PROJECT." server status as of ". |
|
100 | + date("g:i A T")." on ".date("l, j F Y "). |
|
101 | 101 | " (updated every $Nmin minutes).\n"; |
102 | 102 | |
103 | -$proc_uptime=exec("cat /proc/uptime | cut -d\" \" -f-1"); |
|
103 | +$proc_uptime = exec("cat /proc/uptime | cut -d\" \" -f-1"); |
|
104 | 104 | $days = (int)($proc_uptime/86400); |
105 | -$hours=(int)($proc_uptime/3600); |
|
106 | -$hours=$hours % 24; |
|
107 | -$minutes=(int)($proc_uptime/60); |
|
108 | -$minutes=$minutes % 60; |
|
109 | -echo "<br ALIGN=RIGHT>The ".PROJECT. " main server has been continuously up for ". "$days"." days "."$hours"." hours "."$minutes"." minutes.\n<P>"; |
|
105 | +$hours = (int)($proc_uptime/3600); |
|
106 | +$hours = $hours%24; |
|
107 | +$minutes = (int)($proc_uptime/60); |
|
108 | +$minutes = $minutes%60; |
|
109 | +echo "<br ALIGN=RIGHT>The ".PROJECT." main server has been continuously up for "."$days"." days "."$hours"." hours "."$minutes"." minutes.\n<P>"; |
|
110 | 110 | |
111 | 111 | // tables side by side |
112 | 112 | echo "<TABLE><TR><TD align=center> \n"; |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | if ($dbrc) { |
153 | 153 | echo "The database server is not accessable"; |
154 | 154 | } else { |
155 | - $now=time(0); |
|
156 | - $s_day=24*3600; |
|
157 | - $d_ago=$now-$s_day; |
|
158 | - $s_week=7*$s_day; |
|
159 | - $w_ago=$now-$s_week; |
|
155 | + $now = time(0); |
|
156 | + $s_day = 24*3600; |
|
157 | + $d_ago = $now - $s_day; |
|
158 | + $s_week = 7*$s_day; |
|
159 | + $w_ago = $now - $s_week; |
|
160 | 160 | |
161 | 161 | echo " |
162 | 162 | <table border=2 cellpadding=6> |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | <tr><td>invalid</td><td>".number_format($n)."</td></tr> |
277 | 277 | "; |
278 | 278 | |
279 | - $n = time(0)-find_oldest(); |
|
279 | + $n = time(0) - find_oldest(); |
|
280 | 280 | $days = (int)($n/86400); |
281 | - $hours=(int)($n/3600); |
|
282 | - $hours=$hours % 24; |
|
283 | - $minutes=(int)($n/60); |
|
284 | - $minutes=$minutes % 60; |
|
281 | + $hours = (int)($n/3600); |
|
282 | + $hours = $hours%24; |
|
283 | + $minutes = (int)($n/60); |
|
284 | + $minutes = $minutes%60; |
|
285 | 285 | echo " |
286 | 286 | <tr><td>Oldest Unsent Result</td><td>".$days." d ".$hours." h ".$minutes." m</td></tr> |
287 | 287 | "; |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | |
298 | 298 | // Display cgi-bin restriction status |
299 | 299 | |
300 | -if ( file_exists("../../cgi-bin/.htaccess") ) { |
|
300 | +if (file_exists("../../cgi-bin/.htaccess")) { |
|
301 | 301 | echo "<P><font color=RED> |
302 | 302 | <b>The ".PROJECT." scheduler is currently restricted |
303 | 303 | to uwm.edu and a few other domains. |
@@ -27,7 +27,7 @@ |
||
27 | 27 | $nresults_per_code = get_int('nresults_per_code', true); |
28 | 28 | if (!$nresults_per_code) $nresults_per_code = 10; |
29 | 29 | |
30 | -function compare ($x, $y) { |
|
30 | +function compare($x, $y) { |
|
31 | 31 | return $x->count < $y->count; |
32 | 32 | } |
33 | 33 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | // show the home page of app user from envvar |
36 | 36 | |
37 | 37 | $valid = $_GET['id']; |
38 | - if (!$valid || $valid!="whatever-validation-key-you-want") { |
|
38 | + if (!$valid || $valid != "whatever-validation-key-you-want") { |
|
39 | 39 | echo "User id (t.php?id=###) missing!"; |
40 | 40 | exit(); // can't do much without a userid! |
41 | 41 | } |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | |
47 | 47 | // keep a 'running tab' in wapstr in case exceeds 1K WAP limit |
48 | 48 | |
49 | - $wapstr = PROJECT . "<br/>Status Info on<br/>" . wap_timestamp() . "<br/><br/>"; |
|
49 | + $wapstr = PROJECT."<br/>Status Info on<br/>".wap_timestamp()."<br/><br/>"; |
|
50 | 50 | |
51 | - $wapstr .= "#Users: " . getSingleQuery("select count(*) from user") . "<br/>"; |
|
52 | - $wapstr .= "#Hosts: " . getSingleQuery("select count(*) from host") . "<br/>"; |
|
53 | - $wapstr .= "#ModYr: " . sprintf("%ld", getSingleQuery("select sum(total_credit)/(.007*17280.0) from host")) . "<br/>"; |
|
54 | - $wapstr .= "#Cobbl: " . sprintf("%ld", getSingleQuery("select sum(total_credit) from host")) . "<br/>"; |
|
51 | + $wapstr .= "#Users: ".getSingleQuery("select count(*) from user")."<br/>"; |
|
52 | + $wapstr .= "#Hosts: ".getSingleQuery("select count(*) from host")."<br/>"; |
|
53 | + $wapstr .= "#ModYr: ".sprintf("%ld", getSingleQuery("select sum(total_credit)/(.007*17280.0) from host"))."<br/>"; |
|
54 | + $wapstr .= "#Cobbl: ".sprintf("%ld", getSingleQuery("select sum(total_credit) from host"))."<br/>"; |
|
55 | 55 | // I consider a host active if it's trickled in the last week |
56 | 56 | //$wapstr .= "#Activ: " . getSingleQuery("select count(distinct hostid) from cpdnexpt.trickle " |
57 | 57 | // . "where trickledate>=" . sprintf("%d", mktime() - (3600*24*7))) . "<br/>"; |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | //$wapstr .= show_trickles("a", 0, 5, 1); |
61 | 61 | |
62 | 62 | // limit wap output to 1KB |
63 | - if (strlen($wapstr)>1024) |
|
64 | - echo substr($wapstr,0,1024); |
|
63 | + if (strlen($wapstr) > 1024) |
|
64 | + echo substr($wapstr, 0, 1024); |
|
65 | 65 | else |
66 | 66 | echo $wapstr; |
67 | 67 |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | // joined to the host |
38 | 38 | |
39 | 39 | $db = BoincDb::get(); |
40 | - $query = "select et_avg, host.on_frac, host.active_frac, host.gpu_active_frac, app_version.plan_class " . |
|
41 | - " from DBNAME.host_app_version, DBNAME.host, DBNAME.app_version " . |
|
42 | - " where host_app_version.app_version_id = app_version.id " . |
|
43 | - " and app_version.appid = $app->id " . |
|
44 | - " and et_n > 0 and et_avg > 0 " . |
|
45 | - " and host.id = host_app_version.host_id " . |
|
40 | + $query = "select et_avg, host.on_frac, host.active_frac, host.gpu_active_frac, app_version.plan_class ". |
|
41 | + " from DBNAME.host_app_version, DBNAME.host, DBNAME.app_version ". |
|
42 | + " where host_app_version.app_version_id = app_version.id ". |
|
43 | + " and app_version.appid = $app->id ". |
|
44 | + " and et_n > 0 and et_avg > 0 ". |
|
45 | + " and host.id = host_app_version.host_id ". |
|
46 | 46 | " and host.expavg_credit > 10"; |
47 | 47 | $result = $db->do_query($query); |
48 | 48 | $a = array(); |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | $av *= $x->active_frac; |
56 | 56 | } |
57 | 57 | } else { |
58 | - $av = $x->on_frac * $x->active_frac; |
|
58 | + $av = $x->on_frac*$x->active_frac; |
|
59 | 59 | } |
60 | - $a[] = (1/$x->et_avg) * $av; |
|
60 | + $a[] = (1/$x->et_avg)*$av; |
|
61 | 61 | } |
62 | 62 | _mysql_free_result($result); |
63 | 63 | sort($a); |
64 | 64 | $n = count($a); |
65 | 65 | $f = fopen("../../size_census_".$app->name, "w"); |
66 | - for ($i=1; $i<$app->n_size_classes; $i++) { |
|
66 | + for ($i = 1; $i < $app->n_size_classes; $i++) { |
|
67 | 67 | $k = (int)(($i*$n)/$app->n_size_classes); |
68 | 68 | fprintf($f, "%e\n", $a[$k]); |
69 | 69 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | echo "Starting: ", time_str(time()), "\n"; |
74 | 74 | |
75 | -if ($argc == 2 && $argv[1]=="--all_apps") { |
|
75 | +if ($argc == 2 && $argv[1] == "--all_apps") { |
|
76 | 76 | $apps = BoincApp::enum("deprecated=0"); |
77 | 77 | } else { |
78 | 78 | $apps = BoincApp::enum("deprecated=0 and n_size_classes>1"); |