Completed
Pull Request — master (#2135)
by Christian
10:38
created
html/inc/bolt_ex.inc 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -240,6 +240,10 @@  discard block
 block discarded – undo
240 240
 
241 241
 class BoltFitbField {
242 242
     public $textarea, $nrows, $ncols;
243
+
244
+    /**
245
+     * @param boolean $textarea
246
+     */
243 247
     function __construct($textarea, $nrows, $ncols) {
244 248
         $this->textarea = $textarea;
245 249
         $this->nrows = $nrows;
@@ -258,6 +262,10 @@  discard block
 block discarded – undo
258 262
 class BoltFitbAnswer {
259 263
     public $type;   // 0=constant, 1=regexp, 2=func
260 264
     public $ans;
265
+
266
+    /**
267
+     * @param integer $type
268
+     */
261 269
     function __construct($type, $ans) {
262 270
         $this->type = $type;
263 271
         $this->ans = $ans;
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
 // The following is a global var accessed by exercise functions.
22 22
 //
23 23
 $bolt_ex = null;
24
-$bolt_ex->mode = 0;     // input: SHOW/SCORE/ANSWER
25
-$bolt_ex->index = 0;    // input: sequence of this exercise in file
26
-$bolt_ex->score = 0;    // input/output: cumulative score (if mode = SCORE)
27
-$bolt_ex->weight = 0;   // input/output: cumulative weight
28
-$bolt_ex->query_string = "";    // user's response (if SCORE or ANSWER)
24
+$bolt_ex->mode = 0; // input: SHOW/SCORE/ANSWER
25
+$bolt_ex->index = 0; // input: sequence of this exercise in file
26
+$bolt_ex->score = 0; // input/output: cumulative score (if mode = SCORE)
27
+$bolt_ex->weight = 0; // input/output: cumulative weight
28
+$bolt_ex->query_string = ""; // user's response (if SCORE or ANSWER)
29 29
 
30 30
 function weight($w) {
31 31
     return array('weight', $w);
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
             $response = isset($$key);
171 171
             $r = $choice[1];
172 172
             $correct = ($r && $response) || (!$r && !$response);
173
-            $color = $correct?"#88ff88":"#ff8888";
174
-            table_row($c, $r?"yes":"no",
175
-                array($response?"yes":"no", "bgcolor=$color")
173
+            $color = $correct ? "#88ff88" : "#ff8888";
174
+            table_row($c, $r ? "yes" : "no",
175
+                array($response ? "yes" : "no", "bgcolor=$color")
176 176
             );
177 177
             $i++;
178 178
         }
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
         if ($y > $rect[3]) $right = false;
216 216
         $cx = $rect[0];
217 217
         $cy = $rect[2];
218
-        $sizex = $rect[1]-$rect[0];
219
-        $sizey = $rect[3]-$rect[2];
220
-        $ax = $x-4;
221
-        $ay = $y-4;
222
-        $color = $right?"green":"red";
218
+        $sizex = $rect[1] - $rect[0];
219
+        $sizey = $rect[3] - $rect[2];
220
+        $ax = $x - 4;
221
+        $ay = $y - 4;
222
+        $color = $right ? "green" : "red";
223 223
         if ($right) {
224 224
             echo "The point you selected (shown in green) is correct.";
225 225
         } else {
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 }
257 257
 
258 258
 class BoltFitbAnswer {
259
-    public $type;   // 0=constant, 1=regexp, 2=func
259
+    public $type; // 0=constant, 1=regexp, 2=func
260 260
     public $ans;
261 261
     function __construct($type, $ans) {
262 262
         $this->type = $type;
Please login to merge, or discard this patch.
html/inc/bolt_select.inc 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -52,6 +52,9 @@
 block discarded – undo
52 52
     }
53 53
 }
54 54
 
55
+/**
56
+ * @param string $n
57
+ */
55 58
 function valuator($n) {
56 59
     return array('valuator', $n);
57 60
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
 function select_cmp($a, $b) {
20 20
     if ($a->value == $b->value) return 0;
21
-    return ($a->value < $b->value)?1:-1;
21
+    return ($a->value < $b->value) ? 1 : -1;
22 22
 }
23 23
 
24 24
 class BoltSelect extends BoltSet {
Please login to merge, or discard this patch.
html/inc/bolt_snap.inc 1 patch
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -45,6 +45,9 @@  discard block
 block discarded – undo
45 45
     return "../bolt_snap/compare_snapshot_$x";
46 46
 }
47 47
 
48
+/**
49
+ * @param null|integer $dur
50
+ */
48 51
 function write_compare_snapshot($course_id, $select_name, $xset_name, $dur) {
49 52
     $now = time();
50 53
     $start = $now - $dur*86400;
@@ -127,6 +130,9 @@  discard block
 block discarded – undo
127 130
     return "../bolt_snap/map_snapshot_".$course_id;
128 131
 }
129 132
 
133
+/**
134
+ * @param null|integer $dur
135
+ */
130 136
 function write_map_snapshot($course_id, $dur) {
131 137
     $now = time();
132 138
     $start = $now - $dur*86400;
Please login to merge, or discard this patch.
html/inc/bolt_util_ops.inc 2 patches
Doc Comments   +21 added lines patch added patch discarded remove patch
@@ -23,6 +23,9 @@  discard block
 block discarded – undo
23 23
 
24 24
 // get names of units of a given type
25 25
 
26
+/**
27
+ * @param string $type
28
+ */
26 29
 function units_of_type($unit, $type) {
27 30
     $names = array();
28 31
     if (get_class($unit) == $type) {
@@ -118,6 +121,10 @@  discard block
 block discarded – undo
118 121
 
119 122
 //////////// graph drawing
120 123
 
124
+/**
125
+ * @param integer $n
126
+ * @param integer $width
127
+ */
121 128
 function compare_bar($title, $n, $width, $lo, $hi) {
122 129
     $x1 = $width*$lo;
123 130
     $x2 = $width*($hi-$lo);
@@ -137,6 +144,9 @@  discard block
 block discarded – undo
137 144
     ";
138 145
 }
139 146
 
147
+/**
148
+ * @param integer $width
149
+ */
140 150
 function compare_bar_insuff($title, $width) {
141 151
     return "
142 152
         <tr>
@@ -150,6 +160,10 @@  discard block
 block discarded – undo
150 160
     ";
151 161
 }
152 162
 
163
+/**
164
+ * @param integer[] $x
165
+ * @param integer $width
166
+ */
153 167
 function outcome_graph($x, $width) {
154 168
     $n = $x[0]+$x[1]+$x[2];
155 169
     if (!$n) return empty_cell();
@@ -182,6 +196,9 @@  discard block
 block discarded – undo
182 196
     return $s;
183 197
 }
184 198
 
199
+/**
200
+ * @param integer $w
201
+ */
185 202
 function time_graph($t, $w) {
186 203
     if ($t == 0) return "<td>---</td>";
187 204
     $x = (log10($t)+2)*$w/4;
@@ -193,6 +210,10 @@  discard block
 block discarded – undo
193 210
     </td>";
194 211
 }
195 212
 
213
+/**
214
+ * @param integer $t
215
+ * @param integer $w
216
+ */
196 217
 function score_graph($t, $w) {
197 218
     if ($t == 0) return "<td>---</td>";
198 219
     $x = $t*$w;
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
         $n++;
90 90
         $delta = $x - $m;
91 91
         $m += $delta/$n;
92
-        $m2 += $delta*($x-$m);
92
+        $m2 += $delta*($x - $m);
93 93
     }
94 94
     $mean = $m;
95
-    $stdev = sqrt($m2/($n-1));
95
+    $stdev = sqrt($m2/($n - 1));
96 96
 }
97 97
 
98 98
 // approximate the 90% confidence interval for the mean of an array
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
 
104 104
     // I'm too lazy to compute the t distribution
105 105
     $t_90 = 1.7;
106
-    $d = $t_90 * $stdev / sqrt($n);
106
+    $d = $t_90*$stdev/sqrt($n);
107 107
     $lo = $mean - $d;
108 108
     $hi = $mean + $d;
109 109
 }
110 110
 
111 111
 function test_stats() {
112
-    $a = array(1,1,1,1,0,1,1,1,3, 1, 1, 1, 1);
112
+    $a = array(1, 1, 1, 1, 0, 1, 1, 1, 3, 1, 1, 1, 1);
113 113
     mean_stdev($a, $mean, $stdev);
114 114
     echo "mean: $mean stdev: $stdev\n";
115 115
     conf_int_90($a, $lo, $hi);
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
 function compare_bar($title, $n, $width, $lo, $hi) {
122 122
     $x1 = $width*$lo;
123
-    $x2 = $width*($hi-$lo);
123
+    $x2 = $width*($hi - $lo);
124 124
     $a1 = number_format($lo*100);
125 125
     $a2 = number_format($hi*100);
126 126
     return "
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
 }
152 152
 
153 153
 function outcome_graph($x, $width) {
154
-    $n = $x[0]+$x[1]+$x[2];
154
+    $n = $x[0] + $x[1] + $x[2];
155 155
     if (!$n) return empty_cell();
156 156
     $x0 = $width*$x[1]/$n;
157 157
     $x1 = $width*$x[0]/$n;
158 158
     $x2 = $width*$x[2]/$n;
159
-    if ($x[1]/$n>0.05) {
159
+    if ($x[1]/$n > 0.05) {
160 160
         $t0 = number_format(100*$x[1]/$n)."%";
161 161
     } else {
162 162
         $t0 = "";
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 
185 185
 function time_graph($t, $w) {
186 186
     if ($t == 0) return "<td>---</td>";
187
-    $x = (log10($t)+2)*$w/4;
187
+    $x = (log10($t) + 2)*$w/4;
188 188
     $t = number_format($t, 1);
189 189
     return "<td>
190 190
         <table class=bolt_bar><tr>
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 function score_graph($t, $w) {
197 197
     if ($t == 0) return "<td>---</td>";
198 198
     $x = $t*$w;
199
-    $y = (1-$t)*$w;
199
+    $y = (1 - $t)*$w;
200 200
     $t = number_format($t*100);
201 201
     $s = "<td>
202 202
         <table class=bolt_bar><tr>
Please login to merge, or discard this patch.
html/inc/bolt_xset.inc 3 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -22,6 +22,9 @@  discard block
 block discarded – undo
22 22
     public $weight;
23 23
     public $callback;
24 24
 
25
+    /**
26
+     * @param null|BoltRefresh $refresh
27
+     */
25 28
     function __construct(
26 29
         $name, $units, $number, $repeats, $refresh, $attrs, $callback, $weight
27 30
     ) {
@@ -156,10 +159,16 @@  discard block
 block discarded – undo
156 159
 define('REPEAT', 2);
157 160
 define('NEXT', 4);
158 161
 
162
+/**
163
+ * @param integer $f
164
+ */
159 165
 function repeat($s, $u, $f) {
160 166
     return new BoltRepeat($s, $u, $f);
161 167
 }
162 168
 
169
+/**
170
+ * @param integer[] $a
171
+ */
163 172
 function refresh($a) {
164 173
     return new BoltRefresh($a);
165 174
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         $nshown = $state_rec['nshown'];
53 53
         $state_rec['scores'][$nshown] = $score;
54 54
         $iter->state[$this->name] = $state_rec;
55
-        $is_last = ($nshown+1 == $this->ntoshow);
55
+        $is_last = ($nshown + 1 == $this->ntoshow);
56 56
         if (!$is_last) {
57 57
             return false;
58 58
         }
@@ -62,15 +62,15 @@  discard block
 block discarded – undo
62 62
         //   - optionally create or update bolt_refresh record
63 63
         //
64 64
         $total_score = 0;
65
-        for ($i=0; $i<$nshown+1; $i++) {
65
+        for ($i = 0; $i < $nshown + 1; $i++) {
66 66
             $total_score += $state_rec['scores'][$i];
67 67
         }
68
-        $avg_score = $total_score/($nshown+1);
68
+        $avg_score = $total_score/($nshown + 1);
69 69
 
70 70
         $repeat = null;
71 71
         $least = 2;
72 72
         foreach ($this->repeats as $r) {
73
-            if ($avg_score < $r->score && $r->score<$least) {
73
+            if ($avg_score < $r->score && $r->score < $least) {
74 74
                 $repeat = $r;
75 75
                 $least = $r->score;
76 76
             }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     }
135 135
 }
136 136
 
137
-class BoltRefresh{
137
+class BoltRefresh {
138 138
     public $intervals;
139 139
     function __construct($i) {
140 140
         $this->intervals = $i;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
             } else if (get_class($arg) == "BoltRepeat") {
192 192
                 $repeats[] = $arg;
193 193
             } else if (get_class($arg) == "BoltRefresh") {
194
-                $refresh= $arg;
194
+                $refresh = $arg;
195 195
             } else {
196 196
                 echo "Can't include object of type ".get_class($arg)." within an exercise set.";
197 197
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@
 block discarded – undo
134 134
     }
135 135
 }
136 136
 
137
-class BoltRefresh{
137
+class BoltRefresh {
138 138
     public $intervals;
139 139
     function __construct($i) {
140 140
         $this->intervals = $i;
Please login to merge, or discard this patch.
html/inc/bossa.inc 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -38,6 +38,9 @@
 block discarded – undo
38 38
     return $job->insert($clause);
39 39
 }
40 40
 
41
+/**
42
+ * @param string $name
43
+ */
41 44
 function bossa_batch_create($appid, $name, $calibration) {
42 45
     $now = time();
43 46
     $c = $calibration?"1":"0";
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
 
41 41
 function bossa_batch_create($appid, $name, $calibration) {
42 42
     $now = time();
43
-    $c = $calibration?"1":"0";
43
+    $c = $calibration ? "1" : "0";
44 44
     return BossaBatch::insert("(create_time, app_id, name, calibration) values ($now, $appid, '$name', $c)");
45 45
 }
46 46
 
Please login to merge, or discard this patch.
html/inc/cache.inc 4 patches
Doc Comments   +17 added lines patch added patch discarded remove patch
@@ -59,6 +59,9 @@  discard block
 block discarded – undo
59 59
     return $path;
60 60
 }
61 61
 
62
+/**
63
+ * @param string $dir
64
+ */
62 65
 function disk_usage($dir) {
63 66
     $usage=0;
64 67
     if ($handle=@opendir($dir)) {
@@ -76,6 +79,10 @@  discard block
 block discarded – undo
76 79
     return $usage;
77 80
 }
78 81
 
82
+/**
83
+ * @param integer $max_age
84
+ * @param string $dir
85
+ */
79 86
 function clean_cache($max_age, $dir) {
80 87
     $start_dir = getcwd();
81 88
     if (!chdir($dir)) {
@@ -116,6 +123,9 @@  discard block
 block discarded – undo
116 123
     clean_cache($x, "../cache");
117 124
 }
118 125
 
126
+/**
127
+ * @param string $path
128
+ */
119 129
 function cache_need_to_regenerate($path, $max_age){
120 130
     $regenerate = false;
121 131
     $request = apache_request_headers();
@@ -139,6 +149,9 @@  discard block
 block discarded – undo
139 149
 }
140 150
 
141 151
 // Returns cached data or false if nothing was found
152
+/**
153
+ * @param integer $max_age
154
+ */
142 155
 function get_cached_data($max_age, $params=""){
143 156
     global $no_cache;
144 157
 
@@ -253,6 +266,10 @@  discard block
 block discarded – undo
253 266
     }
254 267
 }
255 268
 
269
+/**
270
+ * @param integer $max_age
271
+ * @param string $data
272
+ */
256 273
 function set_cached_data($max_age, $data, $params=""){
257 274
     // for the benefit of hackers
258 275
     if (strstr($params, "..")) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@
 block discarded – undo
99 99
                 }
100 100
             }
101 101
         }
102
-       @closedir($handle);
102
+        @closedir($handle);
103 103
     }
104 104
     chdir($start_dir);
105 105
 } 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
         mkdir("../cache", 0770);
33 33
         chmod("../cache", 0770);
34 34
     }
35
-    for ($i=0;$i<256;$i++) {
36
-        $j=sprintf("%02x",$i);
35
+    for ($i = 0; $i < 256; $i++) {
36
+        $j = sprintf("%02x", $i);
37 37
         if (!@filemtime("../cache/$j")) {
38 38
             mkdir("../cache/$j", 0770);
39 39
             chmod("../cache/$j", 0770);
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     }
42 42
 }
43 43
 
44
-function get_path($params, $phpfile=null) {
44
+function get_path($params, $phpfile = null) {
45 45
     if (!@filemtime("../cache/00")) make_cache_dirs();
46 46
     if ($phpfile) {
47 47
         $z = $phpfile;
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     }
52 52
 
53 53
     // add a layer of subdirectories for reducing file lookup time
54
-    $sz = substr(md5($z."_".urlencode($params)),1,2);
54
+    $sz = substr(md5($z."_".urlencode($params)), 1, 2);
55 55
     $path = "../cache/".$sz."/".$z;
56 56
     if ($params) {
57 57
         $path = $path."_".urlencode($params);
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 }
61 61
 
62 62
 function disk_usage($dir) {
63
-    $usage=0;
64
-    if ($handle=@opendir($dir)) {
65
-        while ($file=readdir($handle)) {
63
+    $usage = 0;
64
+    if ($handle = @opendir($dir)) {
65
+        while ($file = readdir($handle)) {
66 66
             if (($file != ".") && ($file != "..")) {
67 67
                 if (@is_dir($dir."/".$file)) {
68
-                    $usage+=disk_usage($dir."/".$file);
68
+                    $usage += disk_usage($dir."/".$file);
69 69
                 } else {
70
-                    $usage+=@filesize($dir."/".$file);
70
+                    $usage += @filesize($dir."/".$file);
71 71
                 }
72 72
             }
73 73
         }
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     if (!chdir($dir)) {
82 82
         return;
83 83
     }
84
-    if ($handle=@opendir(".")) {
85
-        while ($file=readdir($handle)) {
84
+    if ($handle = @opendir(".")) {
85
+        while ($file = readdir($handle)) {
86 86
             if ($file == ".") continue;
87 87
             if ($file == "..") continue;
88 88
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             if (@is_dir($file)) {
94 94
                 clean_cache($max_age, $file);
95 95
             } else {
96
-                if ((time()-@filemtime($file))>$max_age) {
96
+                if ((time() - @filemtime($file)) > $max_age) {
97 97
                     //echo "unlinking ".getcwd()."/$file\n";
98 98
                     @unlink($file);
99 99
                 }
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 
108 108
 // check cache size every once in a while, purge if too big
109 109
 //
110
-function cache_check_diskspace(){
111
-    if ((rand() % CACHE_SIZE_CHECK_FREQ)) return;
110
+function cache_check_diskspace() {
111
+    if ((rand()%CACHE_SIZE_CHECK_FREQ)) return;
112 112
     if (disk_usage("../cache") < MAX_CACHE_USAGE) return;
113 113
     $x = max(TEAM_PAGE_TTL, USER_PAGE_TTL, USER_HOST_TTL,
114 114
         USER_PROFILE_TTL, TOP_PAGES_TTL, INDEX_PAGE_TTL
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     clean_cache($x, "../cache");
117 117
 }
118 118
 
119
-function cache_need_to_regenerate($path, $max_age){
119
+function cache_need_to_regenerate($path, $max_age) {
120 120
     $regenerate = false;
121 121
     $request = apache_request_headers();
122 122
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         // and touch the cached copy so other processes
129 129
         // don't regenerate at the same time
130 130
         //
131
-        if ($lastmodified<time()-$max_age) {
131
+        if ($lastmodified < time() - $max_age) {
132 132
             $regenerate = true;
133 133
             @touch($path);
134 134
         }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 }
140 140
 
141 141
 // Returns cached data or false if nothing was found
142
-function get_cached_data($max_age, $params=""){
142
+function get_cached_data($max_age, $params = "") {
143 143
     global $no_cache;
144 144
 
145 145
     if ($no_cache) return;
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             }
156 156
         } else {
157 157
             cache_check_diskspace();
158
-            $regenerate=cache_need_to_regenerate($path, $max_age);
158
+            $regenerate = cache_need_to_regenerate($path, $max_age);
159 159
             if (!$regenerate) {
160 160
                 return file_get_contents($path);
161 161
             }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 }
166 166
 
167 167
 // DEPRECATED
168
-function start_cache($max_age, $params=""){
168
+function start_cache($max_age, $params = "") {
169 169
     global $no_cache, $caching, $memcache;
170 170
 
171 171
     if ($no_cache) return;
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
             $regenerate = cache_need_to_regenerate($path, $max_age);
189 189
         }
190 190
         //Is the stored version too old, do we need to regenerate it?
191
-        if ($regenerate){
191
+        if ($regenerate) {
192 192
             // If cached version is too old (or non-existent)
193 193
             // generate the page and write to cache
194 194
             //
195 195
             ob_start();
196 196
             ob_implicit_flush(0);
197
-            Header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
198
-            Header("Expires: " . gmdate("D, d M Y H:i:s",time()+$max_age) . " GMT");
199
-            Header("Cache-Control: public, max-age=" . $max_age); 
197
+            Header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
198
+            Header("Expires: ".gmdate("D, d M Y H:i:s", time() + $max_age)." GMT");
199
+            Header("Cache-Control: public, max-age=".$max_age); 
200 200
 
201 201
             // allow the calling page to see cache period
202 202
             //
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
             if (strstr($params, "format=xml")) {
209 209
                 header('Content-type: text/xml');
210 210
             }
211
-            Header("Last-Modified: " . gmdate("D, d M Y H:i:s",$lastmodified) . " GMT");
212
-            Header("Expires: " . gmdate("D, d M Y H:i:s",$lastmodified+$max_age) . " GMT");
213
-            Header("Cache-Control: public, max-age=" . $max_age );
211
+            Header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastmodified)." GMT");
212
+            Header("Expires: ".gmdate("D, d M Y H:i:s", $lastmodified + $max_age)." GMT");
213
+            Header("Cache-Control: public, max-age=".$max_age);
214 214
             if ($cache && $cache->content) {
215 215
                 echo $cache->content;
216 216
                 exit;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
 // write output buffer both to client and to cache
230 230
 // DEPRECATED
231
-function end_cache($max_age,$params=""){
231
+function end_cache($max_age, $params = "") {
232 232
     global $no_cache;
233 233
     if ($no_cache) return;
234 234
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     }
254 254
 }
255 255
 
256
-function set_cached_data($max_age, $data, $params=""){
256
+function set_cached_data($max_age, $data, $params = "") {
257 257
     // for the benefit of hackers
258 258
     if (strstr($params, "..")) {
259 259
         return "bad params";
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
             self::$instance->setOption(Memcached::OPT_PREFIX_KEY, MEMCACHE_PREFIX);
295 295
         }
296 296
         $servers = explode('|', MEMCACHE_SERVERS);
297
-        foreach($servers as &$server) {
297
+        foreach ($servers as &$server) {
298 298
             list($ip, $port) = explode(':', $server);
299 299
             if (!$port) { $port = 11211; }
300 300
             $server = array($ip, $port);
Please login to merge, or discard this patch.
Braces   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
 // check cache size every once in a while, purge if too big
109 109
 //
110
-function cache_check_diskspace(){
110
+function cache_check_diskspace() {
111 111
     if ((rand() % CACHE_SIZE_CHECK_FREQ)) return;
112 112
     if (disk_usage("../cache") < MAX_CACHE_USAGE) return;
113 113
     $x = max(TEAM_PAGE_TTL, USER_PAGE_TTL, USER_HOST_TTL,
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     clean_cache($x, "../cache");
117 117
 }
118 118
 
119
-function cache_need_to_regenerate($path, $max_age){
119
+function cache_need_to_regenerate($path, $max_age) {
120 120
     $regenerate = false;
121 121
     $request = apache_request_headers();
122 122
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 }
140 140
 
141 141
 // Returns cached data or false if nothing was found
142
-function get_cached_data($max_age, $params=""){
142
+function get_cached_data($max_age, $params="") {
143 143
     global $no_cache;
144 144
 
145 145
     if ($no_cache) return;
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 }
166 166
 
167 167
 // DEPRECATED
168
-function start_cache($max_age, $params=""){
168
+function start_cache($max_age, $params="") {
169 169
     global $no_cache, $caching, $memcache;
170 170
 
171 171
     if ($no_cache) return;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
             $regenerate = cache_need_to_regenerate($path, $max_age);
189 189
         }
190 190
         //Is the stored version too old, do we need to regenerate it?
191
-        if ($regenerate){
191
+        if ($regenerate) {
192 192
             // If cached version is too old (or non-existent)
193 193
             // generate the page and write to cache
194 194
             //
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
 // write output buffer both to client and to cache
230 230
 // DEPRECATED
231
-function end_cache($max_age,$params=""){
231
+function end_cache($max_age,$params="") {
232 232
     global $no_cache;
233 233
     if ($no_cache) return;
234 234
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     }
254 254
 }
255 255
 
256
-function set_cached_data($max_age, $data, $params=""){
256
+function set_cached_data($max_age, $data, $params="") {
257 257
     // for the benefit of hackers
258 258
     if (strstr($params, "..")) {
259 259
         return "bad params";
Please login to merge, or discard this patch.
html/inc/cert.inc 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -37,6 +37,9 @@
 block discarded – undo
37 37
     $ops = number_format($ops, 2);
38 38
 }
39 39
 
40
+/**
41
+ * @param boolean $bolden
42
+ */
40 43
 function credit_string($credit, $bolden) {
41 44
     $cobbs = number_format($credit, 0);
42 45
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@
 block discarded – undo
43 43
     credit_to_ops($credit, $ops, $unit);
44 44
       
45 45
     if ($bolden) {
46
-        $lbold="[[";
47
-        $rbold="]]";
46
+        $lbold = "[[";
47
+        $rbold = "]]";
48 48
     } else {
49
-        $lbold="";        $rbold="";
49
+        $lbold = ""; $rbold = "";
50 50
     } 
51 51
     return " $lbold$cobbs Cobblestones$rbold of computation ($ops $unit floating-point operations)";
52 52
 }
Please login to merge, or discard this patch.
html/inc/db.inc 3 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -69,6 +69,10 @@  discard block
 block discarded – undo
69 69
     function _mysql_fetch_row($r) {
70 70
         return mysqli_fetch_row($r);
71 71
     }
72
+
73
+    /**
74
+     * @param resource $r
75
+     */
72 76
     function _mysql_fetch_assoc($r) {
73 77
         return mysqli_fetch_assoc($r);
74 78
     }
@@ -132,6 +136,10 @@  discard block
 block discarded – undo
132 136
     function _mysql_fetch_row($r) {
133 137
         return mysql_fetch_row($r);
134 138
     }
139
+
140
+    /**
141
+     * @param resource $r
142
+     */
135 143
     function _mysql_fetch_assoc($r) {
136 144
         return mysql_fetch_assoc($r);
137 145
     }
Please login to merge, or discard this patch.
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -86,14 +86,14 @@
 block discarded – undo
86 86
     function _mysql_field_attrs($r, $i) {
87 87
         $x = mysqli_fetch_field_direct($r, $i);
88 88
         switch ($x->type) {
89
-            case 1: $x->type = 'tinyint'; break;
90
-            case 2: $x->type = 'smallint'; break;
91
-            case 3: $x->type = 'int'; break;
92
-            case 5: $x->type = 'double'; break;
93
-            case 7: $x->type = 'timestamp'; break;
94
-            case 252: $x->type = 'blob'; break;
95
-            case 253: $x->type = 'varchar'; break;
96
-            case 254: $x->type = 'char'; break;
89
+        case 1: $x->type = 'tinyint'; break;
90
+        case 2: $x->type = 'smallint'; break;
91
+        case 3: $x->type = 'int'; break;
92
+        case 5: $x->type = 'double'; break;
93
+        case 7: $x->type = 'timestamp'; break;
94
+        case 252: $x->type = 'blob'; break;
95
+        case 253: $x->type = 'varchar'; break;
96
+        case 254: $x->type = 'char'; break;
97 97
         }
98 98
         return $x;
99 99
     }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     function _mysql_connect($host, $user, $pass, $dbname) {
44 44
         global $mysqli;
45 45
         $x = explode(":", $host);
46
-        if (sizeof($x)>1) {
46
+        if (sizeof($x) > 1) {
47 47
             $host = $x[0];
48 48
             $port = $x[1];
49 49
         } else {
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     }
163 163
 }
164 164
 
165
-function db_init_aux($try_replica=false) {
165
+function db_init_aux($try_replica = false) {
166 166
     $config = get_config();
167 167
     $user = parse_config($config, "<db_user>");
168 168
     $pass = parse_config($config, "<db_passwd>");
Please login to merge, or discard this patch.