@@ -30,6 +30,11 @@ discard block |
||
30 | 30 | // $brand: the text or image to show at left of navbar |
31 | 31 | // If text, put it in <a class="navbar-brand" ... |
32 | 32 | // |
33 | +/** |
|
34 | + * @param string $brand |
|
35 | + * @param boolean $fixed |
|
36 | + * @param boolean $inverse |
|
37 | + */ |
|
33 | 38 | function navbar_start($brand, $fixed, $inverse) { |
34 | 39 | global $fixed_navbar; |
35 | 40 | $class = "navbar"; |
@@ -99,6 +104,9 @@ discard block |
||
99 | 104 | |
100 | 105 | // add a dropdown menu |
101 | 106 | // |
107 | +/** |
|
108 | + * @param string $name |
|
109 | + */ |
|
102 | 110 | function navbar_menu($name, $items) { |
103 | 111 | echo ' |
104 | 112 | <li class="dropdown"> |
@@ -218,6 +226,10 @@ discard block |
||
218 | 226 | // output a panel. |
219 | 227 | // $content_func is a function that generates the panel contents |
220 | 228 | // |
229 | +/** |
|
230 | + * @param string|null $title |
|
231 | + * @param Closure $content_func |
|
232 | + */ |
|
221 | 233 | function panel($title, $content_func, $class="panel-primary") { |
222 | 234 | echo sprintf('<div class="panel %s"> |
223 | 235 | ', $class |
@@ -244,6 +256,11 @@ discard block |
||
244 | 256 | // are functions that generate the top, left, and right content |
245 | 257 | // $left_width is the width of left column in 1/12 units. |
246 | 258 | // |
259 | +/** |
|
260 | + * @param boolean $top_func |
|
261 | + * @param Closure $left_func |
|
262 | + * @param Closure $right_func |
|
263 | + */ |
|
247 | 264 | function grid($top_func, $left_func, $right_func, $left_width=6) { |
248 | 265 | echo ' |
249 | 266 | <div class="container-fluid"> |
@@ -277,6 +294,9 @@ discard block |
||
277 | 294 | '; |
278 | 295 | } |
279 | 296 | |
297 | +/** |
|
298 | + * @param string $action |
|
299 | + */ |
|
280 | 300 | function form_start($action, $method='get') { |
281 | 301 | echo sprintf( |
282 | 302 | '<div class="container"> |
@@ -286,6 +306,9 @@ discard block |
||
286 | 306 | ); |
287 | 307 | } |
288 | 308 | |
309 | +/** |
|
310 | + * @param string $name |
|
311 | + */ |
|
289 | 312 | function form_input_hidden($name, $value) { |
290 | 313 | echo '<input type="hidden" name="'.$name.'" value="'.$value.'"> |
291 | 314 | '; |
@@ -301,6 +324,10 @@ discard block |
||
301 | 324 | define('FORM_LEFT_OFFSET', 'col-sm-offset-4'); |
302 | 325 | define('FORM_RIGHT_CLASS', 'col-sm-8'); |
303 | 326 | |
327 | +/** |
|
328 | + * @param string $label |
|
329 | + * @param string $name |
|
330 | + */ |
|
304 | 331 | function form_input_text($label, $name, $value='', $type='text', $attrs='', $extra='') { |
305 | 332 | echo sprintf(' |
306 | 333 | <div class="form-group"> |
@@ -343,6 +370,11 @@ discard block |
||
343 | 370 | |
344 | 371 | // $items is either a string of <option> elements, or an array |
345 | 372 | // |
373 | +/** |
|
374 | + * @param string $label |
|
375 | + * @param string $name |
|
376 | + * @param string $items |
|
377 | + */ |
|
346 | 378 | function form_select($label, $name, $items) { |
347 | 379 | echo sprintf(' |
348 | 380 | <div class="form-group"> |
@@ -387,6 +419,9 @@ discard block |
||
387 | 419 | |
388 | 420 | // $items is list of (name, label, checked) |
389 | 421 | // |
422 | +/** |
|
423 | + * @param string $label |
|
424 | + */ |
|
390 | 425 | function form_checkboxes($label, $items, $attrs='') { |
391 | 426 | echo sprintf(' |
392 | 427 | <div class="form-group"> |
@@ -434,6 +469,10 @@ discard block |
||
434 | 469 | '; |
435 | 470 | } |
436 | 471 | |
472 | +/** |
|
473 | + * @param string $label |
|
474 | + * @param string $item |
|
475 | + */ |
|
437 | 476 | function form_general($label, $item) { |
438 | 477 | echo ' |
439 | 478 | <div class="form-group"> |
@@ -456,6 +495,9 @@ discard block |
||
456 | 495 | '; |
457 | 496 | } |
458 | 497 | |
498 | +/** |
|
499 | + * @param string $text |
|
500 | + */ |
|
459 | 501 | function form_submit($text, $attrs='') { |
460 | 502 | form_general( |
461 | 503 | "", |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | // prefix for links; needed for pages not in top dir |
139 | 139 | $user, |
140 | 140 | // logged-in user, if any |
141 | - $fixed=false, |
|
141 | + $fixed = false, |
|
142 | 142 | // if true, navbar is fixed at top of page. |
143 | 143 | // NOTE: if you do this, you must set a global var $fixed_navbar |
144 | 144 | // to true at compile time |
145 | 145 | // (it needs to be set when page_head() is called). |
146 | - $inverse=false |
|
146 | + $inverse = false |
|
147 | 147 | // white on black? |
148 | 148 | ) { |
149 | 149 | global $master_url; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | // output a panel. |
219 | 219 | // $content_func is a function that generates the panel contents |
220 | 220 | // |
221 | -function panel($title, $content_func, $class="panel-primary") { |
|
221 | +function panel($title, $content_func, $class = "panel-primary") { |
|
222 | 222 | echo sprintf('<div class="panel %s"> |
223 | 223 | ', $class |
224 | 224 | ); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | // are functions that generate the top, left, and right content |
245 | 245 | // $left_width is the width of left column in 1/12 units. |
246 | 246 | // |
247 | -function grid($top_func, $left_func, $right_func, $left_width=6) { |
|
247 | +function grid($top_func, $left_func, $right_func, $left_width = 6) { |
|
248 | 248 | echo ' |
249 | 249 | <div class="container-fluid"> |
250 | 250 | '; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | </div> |
260 | 260 | '; |
261 | 261 | } |
262 | - $right_width = 12-$left_width; |
|
262 | + $right_width = 12 - $left_width; |
|
263 | 263 | echo ' |
264 | 264 | <div class="row"> |
265 | 265 | <div class="col-sm-'.$left_width.'"> |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | '; |
278 | 278 | } |
279 | 279 | |
280 | -function form_start($action, $method='get') { |
|
280 | +function form_start($action, $method = 'get') { |
|
281 | 281 | echo sprintf( |
282 | 282 | '<div class="container"> |
283 | 283 | <form class="form-horizontal" method="%s" action="%s">' |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | define('FORM_LEFT_OFFSET', 'col-sm-offset-4'); |
302 | 302 | define('FORM_RIGHT_CLASS', 'col-sm-8'); |
303 | 303 | |
304 | -function form_input_text($label, $name, $value='', $type='text', $attrs='', $extra='') { |
|
304 | +function form_input_text($label, $name, $value = '', $type = 'text', $attrs = '', $extra = '') { |
|
305 | 305 | echo sprintf(' |
306 | 306 | <div class="form-group"> |
307 | 307 | <label class="control-label %s">%s</label> |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | ); |
329 | 329 | } |
330 | 330 | |
331 | -function form_input_textarea($label, $name, $value='') { |
|
331 | +function form_input_textarea($label, $name, $value = '') { |
|
332 | 332 | echo sprintf(' |
333 | 333 | <div class="form-group"> |
334 | 334 | <label class="control-label %s" for="%s">%s</label> |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | ); |
378 | 378 | $n = 0; |
379 | 379 | foreach ($items as $i) { |
380 | - $s = ($flags && $flags[$n])?'selected':''; |
|
380 | + $s = ($flags && $flags[$n]) ? 'selected' : ''; |
|
381 | 381 | echo '<option '.$s.' value="'.$i[0].'">'.$i[1].'</option> |
382 | 382 | '; |
383 | 383 | $n++; |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | |
388 | 388 | // $items is list of (name, label, checked) |
389 | 389 | // |
390 | -function form_checkboxes($label, $items, $attrs='') { |
|
390 | +function form_checkboxes($label, $items, $attrs = '') { |
|
391 | 391 | echo sprintf(' |
392 | 392 | <div class="form-group"> |
393 | 393 | <label class="control-label %s">%s</label> |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | } |
405 | 405 | echo sprintf('<input %s type="checkbox" name="%s" %s> %s |
406 | 406 | ', |
407 | - $attrs, $i[0], $i[2]?"checked":"", $i[1] |
|
407 | + $attrs, $i[0], $i[2] ? "checked" : "", $i[1] |
|
408 | 408 | ); |
409 | 409 | } |
410 | 410 | echo '</div> |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | FORM_LEFT_CLASS, $label, FORM_RIGHT_CLASS |
424 | 424 | ); |
425 | 425 | foreach ($items as $i) { |
426 | - $checked = ($selected == $i[0])?"checked":""; |
|
426 | + $checked = ($selected == $i[0]) ? "checked" : ""; |
|
427 | 427 | echo sprintf('<input type="radio" name="%s" value="%s" %s> %s <br> |
428 | 428 | ', |
429 | 429 | $name, $i[0], $checked, $i[1] |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | '; |
457 | 457 | } |
458 | 458 | |
459 | -function form_submit($text, $attrs='') { |
|
459 | +function form_submit($text, $attrs = '') { |
|
460 | 460 | form_general( |
461 | 461 | "", |
462 | 462 | sprintf('<button %s type="submit" class="btn btn-success">%s</button>', |
@@ -465,11 +465,11 @@ discard block |
||
465 | 465 | ); |
466 | 466 | } |
467 | 467 | |
468 | -function form_checkbox($label, $name, $checked=false) { |
|
468 | +function form_checkbox($label, $name, $checked = false) { |
|
469 | 469 | echo sprintf(' |
470 | 470 | <div class="form-group"> |
471 | 471 | <input type="checkbox" name="%s" %s> <span class="lead">%s</span> |
472 | 472 | </div> |
473 | - ', $name, $checked?"checked":"", $label |
|
473 | + ', $name, $checked ? "checked" : "", $label |
|
474 | 474 | ); |
475 | 475 | } |
@@ -56,7 +56,7 @@ |
||
56 | 56 | if (!parse_bool($config, "disable_account_creation") |
57 | 57 | && !parse_bool($config, "no_web_account_creation") |
58 | 58 | ) { |
59 | - echo tra("or %1 create an account %2.", "<a href=\"create_account_form.php?next_url=$next_url\">","</a>"); |
|
59 | + echo tra("or %1 create an account %2.", "<a href=\"create_account_form.php?next_url=$next_url\">", "</a>"); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | page_tail(); |
@@ -55,7 +55,7 @@ |
||
55 | 55 | echo tra("Invalid password."); |
56 | 56 | } else { |
57 | 57 | $passwd_hash = md5($passwd.$email_addr); |
58 | - $database_passwd_hash = password_hash($passwd_hash , PASSWORD_DEFAULT); |
|
58 | + $database_passwd_hash = password_hash($passwd_hash, PASSWORD_DEFAULT); |
|
59 | 59 | $email_addr = BoincDb::escape_string($email_addr); |
60 | 60 | $result = $user->update( |
61 | 61 | "email_addr='$email_addr', passwd_hash='$database_passwd_hash', email_validated=0" |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | tra("Must be at least %1 characters", $min_passwd_length), |
98 | 98 | tra("Password") |
99 | 99 | ), |
100 | - "passwd", "", "password",'id="passwd"',passwd_visible_checkbox("passwd") |
|
100 | + "passwd", "", "password", 'id="passwd"', passwd_visible_checkbox("passwd") |
|
101 | 101 | ); |
102 | 102 | form_select( |
103 | 103 | sprintf('<span title="%s">%s</span>', |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | } else { |
124 | 124 | $x = tra("Email address:"); |
125 | 125 | } |
126 | - form_input_text($x, "email_addr", '', 'text', $attrs='autofocus tabindex="1"'); |
|
126 | + form_input_text($x, "email_addr", '', 'text', $attrs = 'autofocus tabindex="1"'); |
|
127 | 127 | form_input_text( |
128 | - tra("Password:").'<br><small><a href="get_passwd.php">' . tra("forgot password?") . "</a></small>", |
|
128 | + tra("Password:").'<br><small><a href="get_passwd.php">'.tra("forgot password?")."</a></small>", |
|
129 | 129 | "passwd", |
130 | 130 | "", |
131 | 131 | "password", |
@@ -25,6 +25,9 @@ |
||
25 | 25 | include_once("../inc/recaptchalib.php"); |
26 | 26 | require_once("../inc/password_compat/password.inc"); |
27 | 27 | |
28 | +/** |
|
29 | + * @param string $passwd_hash |
|
30 | + */ |
|
28 | 31 | function do_passwd_rehash($user, $passwd_hash) { |
29 | 32 | $database_passwd_hash = password_hash($passwd_hash, PASSWORD_DEFAULT); |
30 | 33 | $result = $user->update(" passwd_hash='$database_passwd_hash' "); |
@@ -50,47 +50,47 @@ discard block |
||
50 | 50 | } |
51 | 51 | $resultLength = 0; |
52 | 52 | switch ($algo) { |
53 | - case PASSWORD_BCRYPT: |
|
54 | - $cost = PASSWORD_BCRYPT_DEFAULT_COST; |
|
55 | - if (isset($options['cost'])) { |
|
56 | - $cost = (int) $options['cost']; |
|
57 | - if ($cost < 4 || $cost > 31) { |
|
58 | - trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING); |
|
59 | - return null; |
|
60 | - } |
|
53 | + case PASSWORD_BCRYPT: |
|
54 | + $cost = PASSWORD_BCRYPT_DEFAULT_COST; |
|
55 | + if (isset($options['cost'])) { |
|
56 | + $cost = (int) $options['cost']; |
|
57 | + if ($cost < 4 || $cost > 31) { |
|
58 | + trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING); |
|
59 | + return null; |
|
61 | 60 | } |
62 | - // The length of salt to generate |
|
63 | - $raw_salt_len = 16; |
|
64 | - // The length required in the final serialization |
|
65 | - $required_salt_len = 22; |
|
66 | - $hash_format = sprintf("$2y$%02d$", $cost); |
|
67 | - // The expected length of the final crypt() output |
|
68 | - $resultLength = 60; |
|
69 | - break; |
|
70 | - default: |
|
71 | - trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING); |
|
72 | - return null; |
|
61 | + } |
|
62 | + // The length of salt to generate |
|
63 | + $raw_salt_len = 16; |
|
64 | + // The length required in the final serialization |
|
65 | + $required_salt_len = 22; |
|
66 | + $hash_format = sprintf("$2y$%02d$", $cost); |
|
67 | + // The expected length of the final crypt() output |
|
68 | + $resultLength = 60; |
|
69 | + break; |
|
70 | + default: |
|
71 | + trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING); |
|
72 | + return null; |
|
73 | 73 | } |
74 | 74 | $salt_req_encoding = false; |
75 | 75 | if (isset($options['salt'])) { |
76 | 76 | switch (gettype($options['salt'])) { |
77 | - case 'NULL': |
|
78 | - case 'boolean': |
|
79 | - case 'integer': |
|
80 | - case 'double': |
|
81 | - case 'string': |
|
77 | + case 'NULL': |
|
78 | + case 'boolean': |
|
79 | + case 'integer': |
|
80 | + case 'double': |
|
81 | + case 'string': |
|
82 | + $salt = (string) $options['salt']; |
|
83 | + break; |
|
84 | + case 'object': |
|
85 | + if (method_exists($options['salt'], '__tostring')) { |
|
82 | 86 | $salt = (string) $options['salt']; |
83 | 87 | break; |
84 | - case 'object': |
|
85 | - if (method_exists($options['salt'], '__tostring')) { |
|
86 | - $salt = (string) $options['salt']; |
|
87 | - break; |
|
88 | - } |
|
89 | - case 'array': |
|
90 | - case 'resource': |
|
91 | - default: |
|
92 | - trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING); |
|
93 | - return null; |
|
88 | + } |
|
89 | + case 'array': |
|
90 | + case 'resource': |
|
91 | + default: |
|
92 | + trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING); |
|
93 | + return null; |
|
94 | 94 | } |
95 | 95 | if (PasswordCompat\binary\_strlen($salt) < $required_salt_len) { |
96 | 96 | trigger_error(sprintf("password_hash(): Provided salt is too short: %d expecting %d", PasswordCompat\binary\_strlen($salt), $required_salt_len), E_USER_WARNING); |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | return true; |
213 | 213 | } |
214 | 214 | switch ($algo) { |
215 | - case PASSWORD_BCRYPT: |
|
216 | - $cost = isset($options['cost']) ? (int) $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST; |
|
217 | - if ($cost !== $info['options']['cost']) { |
|
218 | - return true; |
|
219 | - } |
|
220 | - break; |
|
215 | + case PASSWORD_BCRYPT: |
|
216 | + $cost = isset($options['cost']) ? (int) $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST; |
|
217 | + if ($cost !== $info['options']['cost']) { |
|
218 | + return true; |
|
219 | + } |
|
220 | + break; |
|
221 | 221 | } |
222 | 222 | return false; |
223 | 223 | } |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | return null; |
39 | 39 | } |
40 | 40 | if (is_null($password) || is_int($password)) { |
41 | - $password = (string) $password; |
|
41 | + $password = (string)$password; |
|
42 | 42 | } |
43 | 43 | if (!is_string($password)) { |
44 | 44 | trigger_error("password_hash(): Password must be a string", E_USER_WARNING); |
45 | 45 | return null; |
46 | 46 | } |
47 | 47 | if (!is_int($algo)) { |
48 | - trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING); |
|
48 | + trigger_error("password_hash() expects parameter 2 to be long, ".gettype($algo)." given", E_USER_WARNING); |
|
49 | 49 | return null; |
50 | 50 | } |
51 | 51 | $resultLength = 0; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | case PASSWORD_BCRYPT: |
54 | 54 | $cost = PASSWORD_BCRYPT_DEFAULT_COST; |
55 | 55 | if (isset($options['cost'])) { |
56 | - $cost = (int) $options['cost']; |
|
56 | + $cost = (int)$options['cost']; |
|
57 | 57 | if ($cost < 4 || $cost > 31) { |
58 | 58 | trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING); |
59 | 59 | return null; |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | case 'integer': |
80 | 80 | case 'double': |
81 | 81 | case 'string': |
82 | - $salt = (string) $options['salt']; |
|
82 | + $salt = (string)$options['salt']; |
|
83 | 83 | break; |
84 | 84 | case 'object': |
85 | 85 | if (method_exists($options['salt'], '__tostring')) { |
86 | - $salt = (string) $options['salt']; |
|
86 | + $salt = (string)$options['salt']; |
|
87 | 87 | break; |
88 | 88 | } |
89 | 89 | case 'array': |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | if ($read >= $raw_salt_len) { |
127 | 127 | $buffer_valid = true; |
128 | 128 | } |
129 | - $buffer = str_pad($buffer, $raw_salt_len, "\0") ^ str_pad($local_buffer, $raw_salt_len, "\0"); |
|
129 | + $buffer = str_pad($buffer, $raw_salt_len, "\0")^str_pad($local_buffer, $raw_salt_len, "\0"); |
|
130 | 130 | } |
131 | 131 | if (!$buffer_valid || PasswordCompat\binary\_strlen($buffer) < $raw_salt_len) { |
132 | 132 | $buffer_length = PasswordCompat\binary\_strlen($buffer); |
133 | 133 | for ($i = 0; $i < $raw_salt_len; $i++) { |
134 | 134 | if ($i < $buffer_length) { |
135 | - $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255)); |
|
135 | + $buffer[$i] = $buffer[$i]^chr(mt_rand(0, 255)); |
|
136 | 136 | } else { |
137 | 137 | $buffer .= chr(mt_rand(0, 255)); |
138 | 138 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } |
154 | 154 | $salt = PasswordCompat\binary\_substr($salt, 0, $required_salt_len); |
155 | 155 | |
156 | - $hash = $hash_format . $salt; |
|
156 | + $hash = $hash_format.$salt; |
|
157 | 157 | |
158 | 158 | $ret = crypt($password, $hash); |
159 | 159 | |
@@ -208,12 +208,12 @@ discard block |
||
208 | 208 | */ |
209 | 209 | function password_needs_rehash($hash, $algo, array $options = array()) { |
210 | 210 | $info = password_get_info($hash); |
211 | - if ($info['algo'] !== (int) $algo) { |
|
211 | + if ($info['algo'] !== (int)$algo) { |
|
212 | 212 | return true; |
213 | 213 | } |
214 | 214 | switch ($algo) { |
215 | 215 | case PASSWORD_BCRYPT: |
216 | - $cost = isset($options['cost']) ? (int) $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST; |
|
216 | + $cost = isset($options['cost']) ? (int)$options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST; |
|
217 | 217 | if ($cost !== $info['options']['cost']) { |
218 | 218 | return true; |
219 | 219 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | $status = 0; |
244 | 244 | for ($i = 0; $i < PasswordCompat\binary\_strlen($ret); $i++) { |
245 | - $status |= (ord($ret[$i]) ^ ord($hash[$i])); |
|
245 | + $status |= (ord($ret[$i])^ord($hash[$i])); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | return $status === 0; |
@@ -299,7 +299,7 @@ |
||
299 | 299 | * @return boolean the check result |
300 | 300 | */ |
301 | 301 | function check() { |
302 | - static $pass = NULL; |
|
302 | + static $pass = null; |
|
303 | 303 | |
304 | 304 | if (is_null($pass)) { |
305 | 305 | if (function_exists('crypt')) { |