@@ -38,6 +38,9 @@ |
||
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"; |
@@ -59,6 +59,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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, "..")) { |
@@ -37,6 +37,9 @@ |
||
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 |
@@ -69,6 +69,10 @@ discard block |
||
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 |
||
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 | } |
@@ -26,6 +26,9 @@ discard block |
||
26 | 26 | var $db_name; |
27 | 27 | var $readonly; |
28 | 28 | |
29 | + /** |
|
30 | + * @param boolean $readonly |
|
31 | + */ |
|
29 | 32 | function init_conn($user, $passwd, $host, $name, $readonly) { |
30 | 33 | if (MYSQLI) { |
31 | 34 | $x = explode(":", $host); |
@@ -112,6 +115,10 @@ discard block |
||
112 | 115 | return $this->lookup_fields($table, $classname, "*", $clause); |
113 | 116 | } |
114 | 117 | |
118 | + /** |
|
119 | + * @param string $table |
|
120 | + * @param string $classname |
|
121 | + */ |
|
115 | 122 | function lookup_id($id, $table, $classname) { |
116 | 123 | $id = (int)$id; |
117 | 124 | return $this->lookup($table, $classname, "id=$id"); |
@@ -146,28 +153,51 @@ discard block |
||
146 | 153 | return $this->enum_general($classname,$query); |
147 | 154 | } |
148 | 155 | |
156 | + /** |
|
157 | + * @param string $table |
|
158 | + * @param string $classname |
|
159 | + */ |
|
149 | 160 | function enum($table, $classname, $where_clause=null, $order_clause=null) { |
150 | 161 | return self::enum_fields( |
151 | 162 | $table, $classname, '*', $where_clause, $order_clause |
152 | 163 | ); |
153 | 164 | } |
154 | 165 | |
166 | + /** |
|
167 | + * @param string $table |
|
168 | + */ |
|
155 | 169 | function update($obj, $table, $clause) { |
156 | 170 | $query = "update DBNAME.$table set $clause where id=$obj->id"; |
157 | 171 | return $this->do_query($query); |
158 | 172 | } |
173 | + |
|
174 | + /** |
|
175 | + * @param string $table |
|
176 | + */ |
|
159 | 177 | function update_aux($table, $clause) { |
160 | 178 | $query = "update DBNAME.$table set $clause"; |
161 | 179 | return $this->do_query($query); |
162 | 180 | } |
181 | + |
|
182 | + /** |
|
183 | + * @param string $table |
|
184 | + */ |
|
163 | 185 | function insert($table, $clause) { |
164 | 186 | $query = "insert into DBNAME.$table $clause"; |
165 | 187 | return $this->do_query($query); |
166 | 188 | } |
189 | + |
|
190 | + /** |
|
191 | + * @param string $table |
|
192 | + */ |
|
167 | 193 | function delete($obj, $table) { |
168 | 194 | $query = "delete from DBNAME.$table where id=$obj->id"; |
169 | 195 | return $this->do_query($query); |
170 | 196 | } |
197 | + |
|
198 | + /** |
|
199 | + * @param string $table |
|
200 | + */ |
|
171 | 201 | function delete_aux($table, $clause) { |
172 | 202 | $query = "delete from DBNAME.$table where $clause"; |
173 | 203 | return $this->do_query($query); |
@@ -179,6 +209,10 @@ discard block |
||
179 | 209 | return mysql_insert_id($this->db_conn); |
180 | 210 | } |
181 | 211 | } |
212 | + |
|
213 | + /** |
|
214 | + * @param string $field |
|
215 | + */ |
|
182 | 216 | function get_int($query, $field) { |
183 | 217 | $result = $this->do_query($query); |
184 | 218 | if (!$result) error_page("database error on query $query"); |
@@ -209,14 +243,26 @@ discard block |
||
209 | 243 | $query = "select count(*) as total from DBNAME.$table where $clause"; |
210 | 244 | return $this->get_int($query, 'total'); |
211 | 245 | } |
246 | + |
|
247 | + /** |
|
248 | + * @param string $table |
|
249 | + */ |
|
212 | 250 | function sum($table, $field, $clause="") { |
213 | 251 | $query = "select sum($field) as total from DBNAME.$table $clause"; |
214 | 252 | return $this->get_double($query, 'total'); |
215 | 253 | } |
254 | + |
|
255 | + /** |
|
256 | + * @param string $table |
|
257 | + */ |
|
216 | 258 | function max($table, $field, $clause="") { |
217 | 259 | $query = "select max($field) as total from DBNAME.$table $clause"; |
218 | 260 | return $this->get_double($query, 'total'); |
219 | 261 | } |
262 | + |
|
263 | + /** |
|
264 | + * @param string $table |
|
265 | + */ |
|
220 | 266 | function percentile($table, $field, $clause, $pct) { |
221 | 267 | $n = $this->count($table, $clause); |
222 | 268 | if (!$n) return false; |
@@ -224,6 +270,10 @@ discard block |
||
224 | 270 | $query = "select $field from DBNAME.$table where $clause order by $field limit $m,1"; |
225 | 271 | return $this->get_double($query, $field); |
226 | 272 | } |
273 | + |
|
274 | + /** |
|
275 | + * @param string $table |
|
276 | + */ |
|
227 | 277 | function replace($table, $clause) { |
228 | 278 | $query = "replace into DBNAME.$table set $clause"; |
229 | 279 | return $this->do_query($query); |
@@ -103,6 +103,9 @@ discard block |
||
103 | 103 | |
104 | 104 | // Function prints a description of $table |
105 | 105 | // |
106 | +/** |
|
107 | + * @param integer $which |
|
108 | + */ |
|
106 | 109 | function print_describe_table_onecol($table, $which, $columns) { |
107 | 110 | $db = BoincDb::get(true); |
108 | 111 | $result = $db->do_query("SELECT * from $table LIMIT 1"); |
@@ -262,6 +265,10 @@ discard block |
||
262 | 265 | $this->urlquery .= "&clauses=$clause"; |
263 | 266 | } |
264 | 267 | } |
268 | + |
|
269 | + /** |
|
270 | + * @param string $name |
|
271 | + */ |
|
265 | 272 | function addeq($name) { |
266 | 273 | if (isset($_GET[$name])) { |
267 | 274 | $value = $_GET[$name]; |
@@ -273,6 +280,10 @@ discard block |
||
273 | 280 | $this->urlquery .= "&$name=".urlencode($value); |
274 | 281 | } |
275 | 282 | } |
283 | + |
|
284 | + /** |
|
285 | + * @param string $name |
|
286 | + */ |
|
276 | 287 | function addeq_not_CHOOSE_ALL($name) { |
277 | 288 | if (isset($_GET[$name])) { |
278 | 289 | $value = $_GET[$name]; |
@@ -287,6 +298,10 @@ discard block |
||
287 | 298 | $this->urlquery .= "&$name=".urlencode($value); |
288 | 299 | } |
289 | 300 | } |
301 | + |
|
302 | + /** |
|
303 | + * @param string $name |
|
304 | + */ |
|
290 | 305 | function addgt($name) { |
291 | 306 | if (isset($_GET[$name])) { |
292 | 307 | $value = $_GET[$name]; |
@@ -298,6 +313,11 @@ discard block |
||
298 | 313 | $this->urlquery .= "&$name=".urlencode($value); |
299 | 314 | } |
300 | 315 | } |
316 | + |
|
317 | + /** |
|
318 | + * @param string $name |
|
319 | + * @param string $order |
|
320 | + */ |
|
301 | 321 | function addsort($name, $order) { |
302 | 322 | if (isset($_GET[$name])) { |
303 | 323 | $value = $_GET[$name]; |
@@ -375,6 +395,9 @@ discard block |
||
375 | 395 | } |
376 | 396 | |
377 | 397 | |
398 | +/** |
|
399 | + * @param string $mq |
|
400 | + */ |
|
378 | 401 | function link_results($n, $mq, $query, $clauses) { |
379 | 402 | if ($n == '0') { // intentional compare by string |
380 | 403 | return "0"; |
@@ -824,6 +847,9 @@ discard block |
||
824 | 847 | return number_format($x/86400, 2)." days"; |
825 | 848 | } |
826 | 849 | |
850 | +/** |
|
851 | + * @param integer $x |
|
852 | + */ |
|
827 | 853 | function resource_name($x) { |
828 | 854 | switch ($x) { |
829 | 855 | case 2: return "CPU"; |
@@ -36,6 +36,9 @@ |
||
36 | 36 | return "$dirpath/$filename"; |
37 | 37 | } |
38 | 38 | |
39 | +/** |
|
40 | + * @param string $base |
|
41 | + */ |
|
39 | 42 | function dir_hier_url($filename, $base, $fanout) { |
40 | 43 | $dir = filename_hash($filename, $fanout); |
41 | 44 | return "$base/$dir/$filename"; |
@@ -208,6 +208,9 @@ discard block |
||
208 | 208 | // (to accommodate long [pre] lines) |
209 | 209 | // and the left column (author info) has fixed size |
210 | 210 | // |
211 | +/** |
|
212 | + * @param string[] $headings |
|
213 | + */ |
|
211 | 214 | function start_forum_table($headings) { |
212 | 215 | $a = array(); |
213 | 216 | foreach ($headings as $h) { |
@@ -488,6 +491,9 @@ discard block |
||
488 | 491 | // Display an individual post. |
489 | 492 | // Generates a table row with two cells: author and message |
490 | 493 | // |
494 | +/** |
|
495 | + * @param integer $controls |
|
496 | + */ |
|
491 | 497 | function show_post( |
492 | 498 | $post, $thread, $forum, $logged_in_user, $latest_viewed, |
493 | 499 | $controls=FORUM_CONTROLS, $filter=true |
@@ -852,6 +858,9 @@ discard block |
||
852 | 858 | // These take care of counts and timestamps. |
853 | 859 | // Don't do these things directly - use these functions |
854 | 860 | // |
861 | +/** |
|
862 | + * @param integer $parent_id |
|
863 | + */ |
|
855 | 864 | function create_post($content, $parent_id, $user, $forum, $thread, $signature) { |
856 | 865 | $content = substr($content, 0, 64000); |
857 | 866 | $content = BoincDb::escape_string($content); |
@@ -1084,6 +1093,9 @@ discard block |
||
1084 | 1093 | // $sort_style - string (checked by switch statement) |
1085 | 1094 | // $show_hidden - bool (not directly passed to SQL) |
1086 | 1095 | // |
1096 | +/** |
|
1097 | + * @param boolean $show_hidden |
|
1098 | + */ |
|
1087 | 1099 | function get_thread_posts($threadid, $sort_style, $show_hidden) { |
1088 | 1100 | $sql = "thread=$threadid"; |
1089 | 1101 | if (!$show_hidden) { |
@@ -1109,6 +1121,9 @@ discard block |
||
1109 | 1121 | // Show links for post moderation actions; |
1110 | 1122 | // logged in user has moderation rights. |
1111 | 1123 | // |
1124 | +/** |
|
1125 | + * @param string $config |
|
1126 | + */ |
|
1112 | 1127 | function show_post_moderation_links( |
1113 | 1128 | $config, $logged_in_user, $post, $forum, $tokens |
1114 | 1129 | ){ |
@@ -115,6 +115,10 @@ discard block |
||
115 | 115 | $db = BoincDb::get(); |
116 | 116 | return $db->enum('post', 'BoincPost', $clause); |
117 | 117 | } |
118 | + |
|
119 | + /** |
|
120 | + * @param string $query |
|
121 | + */ |
|
118 | 122 | static function enum_general($query) { |
119 | 123 | $db = BoincDb::get(); |
120 | 124 | return $db->enum_general('BoincPost', $query); |
@@ -175,6 +179,10 @@ discard block |
||
175 | 179 | $db = BoincDb::get(); |
176 | 180 | return $db->delete_aux('forum_preferences', "userid=$this->userid"); |
177 | 181 | } |
182 | + |
|
183 | + /** |
|
184 | + * @param string $clause |
|
185 | + */ |
|
178 | 186 | static function enum($clause=null) { |
179 | 187 | $db = BoincDb::get(); |
180 | 188 | return $db->enum('forum_preferences', 'BoincForumPrefs', $clause); |
@@ -290,6 +298,10 @@ discard block |
||
290 | 298 | } |
291 | 299 | |
292 | 300 | class BoincNotify { |
301 | + |
|
302 | + /** |
|
303 | + * @param string $clause |
|
304 | + */ |
|
293 | 305 | static function insert($clause) { |
294 | 306 | $db = BoincDb::get(); |
295 | 307 | $ret = $db->insert('notify', $clause); |
@@ -304,6 +316,10 @@ discard block |
||
304 | 316 | $db = BoincDb::get(); |
305 | 317 | return $db->enum('notify', 'BoincNotify', $clause); |
306 | 318 | } |
319 | + |
|
320 | + /** |
|
321 | + * @param integer $type |
|
322 | + */ |
|
307 | 323 | static function lookup($userid, $type, $opaque) { |
308 | 324 | $db = BoincDb::get(); |
309 | 325 | return $db->lookup('notify', 'BoincNotify', "userid=$userid and type=$type and opaque=$opaque"); |
@@ -316,6 +332,10 @@ discard block |
||
316 | 332 | $db = BoincDb::get(); |
317 | 333 | $db->delete_aux('notify', $clause); |
318 | 334 | } |
335 | + |
|
336 | + /** |
|
337 | + * @param string $query |
|
338 | + */ |
|
319 | 339 | static function enum_general($query) { |
320 | 340 | $db = BoincDb::get(); |
321 | 341 | return $db->enum_general('BoincNotify', $query); |