@@ -12,26 +12,26 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | |
15 | - require_once('./includes/bootstrap.inc'); |
|
16 | - drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
|
17 | - require_boinc('db'); |
|
15 | + require_once('./includes/bootstrap.inc'); |
|
16 | + drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
|
17 | + require_boinc('db'); |
|
18 | 18 | |
19 | - // Parse arguments |
|
20 | - $import_lurkers = isset($argv[1]) ? $argv[1] : false; |
|
21 | - $record_offset = isset($argv[2]) ? $argv[2] : 0; |
|
22 | - $chunk_size = isset($argv[3]) ? $argv[3] : 100; |
|
19 | + // Parse arguments |
|
20 | + $import_lurkers = isset($argv[1]) ? $argv[1] : false; |
|
21 | + $record_offset = isset($argv[2]) ? $argv[2] : 0; |
|
22 | + $chunk_size = isset($argv[3]) ? $argv[3] : 100; |
|
23 | 23 | |
24 | - // Construct sql conditions |
|
25 | - $limit = sprintf('LIMIT %d,%d', $record_offset, $chunk_size); |
|
24 | + // Construct sql conditions |
|
25 | + $limit = sprintf('LIMIT %d,%d', $record_offset, $chunk_size); |
|
26 | 26 | |
27 | - $count = 0; |
|
27 | + $count = 0; |
|
28 | 28 | |
29 | - db_set_active('boinc_rw'); |
|
30 | - if ($import_lurkers) { |
|
29 | + db_set_active('boinc_rw'); |
|
30 | + if ($import_lurkers) { |
|
31 | 31 | $boinc_accounts = db_query('SELECT id FROM user ORDER BY id %s', $limit); |
32 | - } |
|
33 | - //else $boinc_accounts = db_query('SELECT DISTINCT user AS boinc_id FROM post ORDER BY boinc_id %s', $limit); |
|
34 | - else { |
|
32 | + } |
|
33 | + //else $boinc_accounts = db_query('SELECT DISTINCT user AS boinc_id FROM post ORDER BY boinc_id %s', $limit); |
|
34 | + else { |
|
35 | 35 | // Need to import any user who is currently ignored in order to keep them |
36 | 36 | // ignored... not particularly clean (ignored users are stored in a string) |
37 | 37 | $ignored_user_list = array(); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | ORDER BY userid ASC" |
43 | 43 | ); |
44 | 44 | while ($ignoring_user = db_fetch_object($ignoring_users)) { |
45 | - $ignored_user_list = $ignored_user_list + array_fill_keys(explode('|', trim($ignoring_user->ignorelist, '|')), 1); |
|
45 | + $ignored_user_list = $ignored_user_list + array_fill_keys(explode('|', trim($ignoring_user->ignorelist, '|')), 1); |
|
46 | 46 | } |
47 | 47 | $ignored_user_list = array_keys($ignored_user_list); |
48 | 48 | $boinc_accounts = db_query(" |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | (SELECT DISTINCT senderid FROM {private_messages}) |
59 | 59 | ) AS usersToImport ORDER BY id ASC %s", implode(',', $ignored_user_list), $limit |
60 | 60 | ); |
61 | - } |
|
62 | - db_set_active('default'); |
|
61 | + } |
|
62 | + db_set_active('default'); |
|
63 | 63 | |
64 | - while ($boinc_account = db_fetch_object($boinc_accounts)) { |
|
64 | + while ($boinc_account = db_fetch_object($boinc_accounts)) { |
|
65 | 65 | // Grab the BOINC user object and create a Drupal user from it |
66 | 66 | if (boincuser_register_make_drupal_user($boinc_account->id)) { |
67 | - $count++; |
|
67 | + $count++; |
|
68 | + } |
|
68 | 69 | } |
69 | - } |
|
70 | 70 | |
71 | - echo $count; |
|
71 | + echo $count; |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | */ |
115 | 115 | require_once('dbconfig.php'); |
116 | 116 | if (!isset($dbserver) || empty($dbserver)) |
117 | - $dbserver='localhost'; |
|
117 | + $dbserver='localhost'; |
|
118 | 118 | $db_url = array( |
119 | - 'default' => "{$dbtype}://{$dbuser}:".urlencode($dbpass)."@{$dbserver}/{$dbname}", |
|
120 | - 'boinc_rw' => "{$boinc_rw_dbtype}://{$boinc_rw_dbuser}:".urlencode($boinc_rw_dbpass)."@{$boinc_rw_dbserver}/{$boinc_rw_dbname}" |
|
119 | + 'default' => "{$dbtype}://{$dbuser}:".urlencode($dbpass)."@{$dbserver}/{$dbname}", |
|
120 | + 'boinc_rw' => "{$boinc_rw_dbtype}://{$boinc_rw_dbuser}:".urlencode($boinc_rw_dbpass)."@{$boinc_rw_dbserver}/{$boinc_rw_dbname}" |
|
121 | 121 | ); |
122 | 122 | $db_prefix = ''; |
123 | 123 | |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | // 'boinc_rw' entry as 'boinc_ro'. |
126 | 126 | |
127 | 127 | if (isset($boinc_ro_dbtype) && isset($boinc_ro_dbuser) && isset($boinc_ro_dbpass) && isset($boinc_ro_dbserver) && isset($boinc_ro_dbname)) { |
128 | - $db_url['boinc_ro'] = "{$boinc_ro_dbtype}://{$boinc_ro_dbuser}:".urlencode($boinc_ro_dbpass)."@{$boinc_ro_dbserver}/{$boinc_ro_dbname}"; |
|
128 | + $db_url['boinc_ro'] = "{$boinc_ro_dbtype}://{$boinc_ro_dbuser}:".urlencode($boinc_ro_dbpass)."@{$boinc_ro_dbserver}/{$boinc_ro_dbname}"; |
|
129 | 129 | } |
130 | 130 | else { |
131 | - $db_url['boinc_ro'] = $db_url['boinc_rw']; |
|
131 | + $db_url['boinc_ro'] = $db_url['boinc_rw']; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -216,5 +216,5 @@ discard block |
||
216 | 216 | */ |
217 | 217 | |
218 | 218 | if (stream_resolve_include_path('settings.local.php')) { |
219 | - include 'settings.local.php'; |
|
219 | + include 'settings.local.php'; |
|
220 | 220 | } |
@@ -126,8 +126,7 @@ |
||
126 | 126 | |
127 | 127 | if (isset($boinc_ro_dbtype) && isset($boinc_ro_dbuser) && isset($boinc_ro_dbpass) && isset($boinc_ro_dbserver) && isset($boinc_ro_dbname)) { |
128 | 128 | $db_url['boinc_ro'] = "{$boinc_ro_dbtype}://{$boinc_ro_dbuser}:".urlencode($boinc_ro_dbpass)."@{$boinc_ro_dbserver}/{$boinc_ro_dbname}"; |
129 | -} |
|
130 | -else { |
|
129 | +} else { |
|
131 | 130 | $db_url['boinc_ro'] = $db_url['boinc_rw']; |
132 | 131 | } |
133 | 132 |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | require_once('dbconfig.php'); |
116 | 116 | if (!isset($dbserver) || empty($dbserver)) |
117 | - $dbserver='localhost'; |
|
117 | + $dbserver = 'localhost'; |
|
118 | 118 | $db_url = array( |
119 | 119 | 'default' => "{$dbtype}://{$dbuser}:".urlencode($dbpass)."@{$dbserver}/{$dbname}", |
120 | 120 | 'boinc_rw' => "{$boinc_rw_dbtype}://{$boinc_rw_dbuser}:".urlencode($boinc_rw_dbpass)."@{$boinc_rw_dbserver}/{$boinc_rw_dbname}" |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | * settings are used there. Settings defined here should not be |
163 | 163 | * duplicated there so as to avoid conflict issues. |
164 | 164 | */ |
165 | -ini_set('session.cache_expire', 200000); |
|
166 | -ini_set('session.cache_limiter', 'none'); |
|
167 | -ini_set('session.cookie_lifetime', 2000000); |
|
168 | -ini_set('session.gc_maxlifetime', 200000); |
|
169 | -ini_set('session.save_handler', 'user'); |
|
165 | +ini_set('session.cache_expire', 200000); |
|
166 | +ini_set('session.cache_limiter', 'none'); |
|
167 | +ini_set('session.cookie_lifetime', 2000000); |
|
168 | +ini_set('session.gc_maxlifetime', 200000); |
|
169 | +ini_set('session.save_handler', 'user'); |
|
170 | 170 | ini_set('session.use_only_cookies', 1); |
171 | -ini_set('session.use_trans_sid', 0); |
|
172 | -ini_set('url_rewriter.tags', ''); |
|
171 | +ini_set('session.use_trans_sid', 0); |
|
172 | +ini_set('url_rewriter.tags', ''); |
|
173 | 173 | ini_set('memory_limit', '128M'); |
174 | 174 | ini_set('post_max_size', '8MB'); |
175 | 175 | ini_set('upload_max_filesize', '8MB'); |
@@ -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(); |
@@ -105,8 +105,7 @@ discard block |
||
105 | 105 | $drupalnid = boincteam_lookup_nid($result->id); |
106 | 106 | if ($drupalnid) { |
107 | 107 | $tlink = l($result->name, '/community/teams/' . $drupalnid); |
108 | - } |
|
109 | - else { |
|
108 | + } else { |
|
110 | 109 | $tlink = ''; |
111 | 110 | } |
112 | 111 | // only keys no values |
@@ -181,8 +180,7 @@ discard block |
||
181 | 180 | drupal_render($form['link'][$key]), |
182 | 181 | ); |
183 | 182 | } |
184 | - } |
|
185 | - else { |
|
183 | + } else { |
|
186 | 184 | $rows[] = array(array('data' => '<div class="error">No teams found</div>', 'colspan' => 5)); |
187 | 185 | } |
188 | 186 | $output .= theme('table', $header, $rows); |
@@ -230,8 +228,7 @@ discard block |
||
230 | 228 | if ($success) { |
231 | 229 | $message = 'Info: Delete SPAM Teams utility- ' . count($results) . ' team(s) deleted.'; |
232 | 230 | drupal_set_message($message, 'info'); |
233 | - } |
|
234 | - else { |
|
231 | + } else { |
|
235 | 232 | // An error occurred. |
236 | 233 | // $operations contains the operations that remained unprocessed. |
237 | 234 | $error_operation = reset($operations); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $form['help'] = array( |
23 | 23 | '#type' => 'fieldset', |
24 | 24 | '#title' => t('Help'), |
25 | - '#collapsible' => TRUE, |
|
25 | + '#collapsible' => true, |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | $form['help']['text'] = array( |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | $form['checkboxes'] = array('#type' => 'checkboxes', '#options' => $checkboxes); |
130 | - $form['pager'] = array('#value' => theme('pager', NULL, $limit, 0)); |
|
130 | + $form['pager'] = array('#value' => theme('pager', null, $limit, 0)); |
|
131 | 131 | |
132 | 132 | return $form; |
133 | 133 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | // An error occurred. |
236 | 236 | // $operations contains the operations that remained unprocessed. |
237 | 237 | $error_operation = reset($operations); |
238 | - $message = 'Error: An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
|
238 | + $message = 'Error: An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], true); |
|
239 | 239 | drupal_set_message($message, 'error'); |
240 | 240 | } |
241 | 241 | } |
242 | 242 | \ No newline at end of file |
@@ -17,15 +17,15 @@ discard block |
||
17 | 17 | * Utility Form to delete teams suspected of being spammers. |
18 | 18 | */ |
19 | 19 | function boincteam_utility_delete(&$form_state) { |
20 | - $form = array(); |
|
20 | + $form = array(); |
|
21 | 21 | |
22 | - $form['help'] = array( |
|
22 | + $form['help'] = array( |
|
23 | 23 | '#type' => 'fieldset', |
24 | 24 | '#title' => t('Help'), |
25 | 25 | '#collapsible' => TRUE, |
26 | - ); |
|
26 | + ); |
|
27 | 27 | |
28 | - $form['help']['text'] = array( |
|
28 | + $form['help']['text'] = array( |
|
29 | 29 | '#type' => 'item', |
30 | 30 | '#description' => t('This utility page will help in identifying BOINC teams created by SPAMMERs which can be deleted. The search will find BOINC teams that meet the following criteria. |
31 | 31 | <ul> |
@@ -38,19 +38,19 @@ discard block |
||
38 | 38 | <p> <i>How teams are deleted</i>: Select the teams to be deleted from the table below. Click "Delete Selected Teams" button to begin a batch operation to delete the teams. If you select teams, and then page through to another page of the table, your selections will be lost. I.e., only the teams select on the current page will be deleted. |
39 | 39 | <p> The site must be offline/in maintenance mode before searching for and deleting teams. If not, the delete button below is disabled. |
40 | 40 | '), |
41 | - ); |
|
41 | + ); |
|
42 | 42 | |
43 | - // This variable name has been changed for Drupal 7/8. |
|
44 | - $maintenance_mode = variable_get('site_offline'); |
|
45 | - if (!$maintenance_mode) { |
|
43 | + // This variable name has been changed for Drupal 7/8. |
|
44 | + $maintenance_mode = variable_get('site_offline'); |
|
45 | + if (!$maintenance_mode) { |
|
46 | 46 | drupal_set_message(t('WARNING: Site is online (not in maintenance mode)! Deleting teams is only allowed when site is offline. Change this setting in ') . l(t('Site maintenance'), '/admin/settings/site-maintenance'), 'warning'); |
47 | - } |
|
47 | + } |
|
48 | 48 | |
49 | - $form['teamdelete'] = array( |
|
49 | + $form['teamdelete'] = array( |
|
50 | 50 | '#type' => 'fieldset', |
51 | 51 | '#title' => t('Teams to delete'), |
52 | - ); |
|
53 | - $form['teamdelete']['deleteall'] = array( |
|
52 | + ); |
|
53 | + $form['teamdelete']['deleteall'] = array( |
|
54 | 54 | '#type' => 'submit', |
55 | 55 | '#disabled' => !($maintenance_mode), |
56 | 56 | '#value' => t('Delete Selected Teams'), |
@@ -58,101 +58,101 @@ discard block |
||
58 | 58 | '#attributes' => array( |
59 | 59 | 'onclick' => 'return confirm(\'' . t('You are about to delete the selected teams suspected of being SPAM. Do you want to continue?') . '\')', |
60 | 60 | ), |
61 | - ); |
|
62 | - $form['teamdelete']['results_table'] = array( |
|
61 | + ); |
|
62 | + $form['teamdelete']['results_table'] = array( |
|
63 | 63 | '#value' => drupal_get_form('boincteam_utility_team_table'), |
64 | - ); |
|
64 | + ); |
|
65 | 65 | |
66 | - return $form; |
|
66 | + return $form; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | function boincteam_utility_team_table() { |
70 | 70 | |
71 | - $limit=50; |
|
72 | - $sql = "SELECT team.id AS id, team.name AS name, team.nusers AS nusers FROM {team} WHERE team.nusers<2 AND team.total_credit=0 AND team.seti_id=0 AND team.description REGEXP '<a href'"; |
|
71 | + $limit=50; |
|
72 | + $sql = "SELECT team.id AS id, team.name AS name, team.nusers AS nusers FROM {team} WHERE team.nusers<2 AND team.total_credit=0 AND team.seti_id=0 AND team.description REGEXP '<a href'"; |
|
73 | 73 | |
74 | - // @todo - add bts() or t() |
|
75 | - $resultheader = array( |
|
74 | + // @todo - add bts() or t() |
|
75 | + $resultheader = array( |
|
76 | 76 | array( |
77 | - 'data' => 'Team ID', |
|
78 | - 'field' => 'id', |
|
79 | - 'sort' => 'asc', |
|
77 | + 'data' => 'Team ID', |
|
78 | + 'field' => 'id', |
|
79 | + 'sort' => 'asc', |
|
80 | 80 | ), |
81 | 81 | array( |
82 | - 'data' => 'Team Name', |
|
83 | - 'field' => 'name', |
|
82 | + 'data' => 'Team Name', |
|
83 | + 'field' => 'name', |
|
84 | 84 | ), |
85 | 85 | array( |
86 | - 'data' => 'Num Users', |
|
87 | - 'field' => 'nusers', |
|
86 | + 'data' => 'Num Users', |
|
87 | + 'field' => 'nusers', |
|
88 | 88 | ), |
89 | 89 | array( |
90 | - 'data' => 'Link to Team', |
|
91 | - 'field' => 'link', |
|
90 | + 'data' => 'Link to Team', |
|
91 | + 'field' => 'link', |
|
92 | 92 | ), |
93 | - ); |
|
93 | + ); |
|
94 | 94 | |
95 | - $tablesort = tablesort_sql($resultheader); |
|
96 | - db_set_active('boinc_rw'); |
|
97 | - $db_res = pager_query($sql . $tablesort, $limit); |
|
98 | - db_set_active('default'); |
|
95 | + $tablesort = tablesort_sql($resultheader); |
|
96 | + db_set_active('boinc_rw'); |
|
97 | + $db_res = pager_query($sql . $tablesort, $limit); |
|
98 | + db_set_active('default'); |
|
99 | 99 | |
100 | - $form = array(); |
|
101 | - $form['options'] = array(); |
|
102 | - $checkboxes = array(); |
|
103 | - if ($db_res) { |
|
100 | + $form = array(); |
|
101 | + $form['options'] = array(); |
|
102 | + $checkboxes = array(); |
|
103 | + if ($db_res) { |
|
104 | 104 | while ($result = db_fetch_object($db_res)) { |
105 | - $drupalnid = boincteam_lookup_nid($result->id); |
|
106 | - if ($drupalnid) { |
|
105 | + $drupalnid = boincteam_lookup_nid($result->id); |
|
106 | + if ($drupalnid) { |
|
107 | 107 | $tlink = l($result->name, '/community/teams/' . $drupalnid); |
108 | - } |
|
109 | - else { |
|
108 | + } |
|
109 | + else { |
|
110 | 110 | $tlink = ''; |
111 | - } |
|
112 | - // only keys no values |
|
113 | - $checkboxes[$result->id] = ''; |
|
111 | + } |
|
112 | + // only keys no values |
|
113 | + $checkboxes[$result->id] = ''; |
|
114 | 114 | |
115 | - $form['id'][$result->id] = array( |
|
115 | + $form['id'][$result->id] = array( |
|
116 | 116 | '#value' => $result->id, |
117 | - ); |
|
118 | - $form['name'][$result->id] = array( |
|
117 | + ); |
|
118 | + $form['name'][$result->id] = array( |
|
119 | 119 | '#value' => $result->name, |
120 | - ); |
|
121 | - $form['nusers'][$result->id] = array( |
|
120 | + ); |
|
121 | + $form['nusers'][$result->id] = array( |
|
122 | 122 | '#value' => $result->nusers, |
123 | - ); |
|
124 | - $form['link'][$result->id] = array( |
|
123 | + ); |
|
124 | + $form['link'][$result->id] = array( |
|
125 | 125 | '#value' => $tlink, |
126 | - ); |
|
126 | + ); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | $form['checkboxes'] = array('#type' => 'checkboxes', '#options' => $checkboxes); |
130 | 130 | $form['pager'] = array('#value' => theme('pager', NULL, $limit, 0)); |
131 | 131 | |
132 | 132 | return $form; |
133 | - } |
|
134 | - return "<p>No teams matched the criteria for a SPAM team.</p>"; |
|
133 | + } |
|
134 | + return "<p>No teams matched the criteria for a SPAM team.</p>"; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
138 | 138 | * Submit handler - also creates the batch job to delete the teams. |
139 | 139 | */ |
140 | 140 | function boincteam_utility_delete_team($form, &$form_state) { |
141 | - $checkedteamids = $form_state['clicked_button']['#post']['checkboxes']; |
|
142 | - // Use batch to delete teams |
|
143 | - $operations = array(); |
|
144 | - foreach ($checkedteamids as $id) { |
|
141 | + $checkedteamids = $form_state['clicked_button']['#post']['checkboxes']; |
|
142 | + // Use batch to delete teams |
|
143 | + $operations = array(); |
|
144 | + foreach ($checkedteamids as $id) { |
|
145 | 145 | $operations[] = array('boincteam_utility_batch_process', array($id)); |
146 | - } |
|
147 | - $batch = array( |
|
146 | + } |
|
147 | + $batch = array( |
|
148 | 148 | 'title' => t('Processing BOINC Teams'), |
149 | 149 | 'operations' => $operations, |
150 | 150 | 'init_message' => t('Starting team deletion'), |
151 | 151 | 'finished' => 'boincteam_utility_batch_finished', |
152 | 152 | 'file' => drupal_get_path('module', 'boincteam') . '/boincteam.admin.inc', |
153 | - ); |
|
154 | - batch_set($batch); |
|
155 | - //batch_process('/admin/boinc/utility-team-delete'); |
|
153 | + ); |
|
154 | + batch_set($batch); |
|
155 | + //batch_process('/admin/boinc/utility-team-delete'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /* |
@@ -163,37 +163,37 @@ discard block |
||
163 | 163 | * Input form (table) |
164 | 164 | */ |
165 | 165 | function theme_boincteam_utility_team_table($form) { |
166 | - //define table header |
|
167 | - $header = array( |
|
166 | + //define table header |
|
167 | + $header = array( |
|
168 | 168 | theme('table_select_header_cell'), //using that previously empty field |
169 | 169 | array('data' => t('Team ID'), 'field' => 'id', 'sort' => 'asc'), |
170 | 170 | array('data' => t('Name'), 'field' => 'name'), |
171 | 171 | array('data' => t('Num Users'), 'field' => 'nusers'), |
172 | 172 | array('data' => t('Link to Team'), 'field' => 'link'), |
173 | - ); |
|
174 | - $rows = array(); |
|
175 | - $output = ""; |
|
176 | - if(!empty($form['checkboxes']['#options'])) { |
|
173 | + ); |
|
174 | + $rows = array(); |
|
175 | + $output = ""; |
|
176 | + if(!empty($form['checkboxes']['#options'])) { |
|
177 | 177 | foreach (element_children($form['id']) as $key) { |
178 | - $rows[] = array( |
|
178 | + $rows[] = array( |
|
179 | 179 | drupal_render($form['checkboxes'][$key]), |
180 | 180 | drupal_render($form['id'][$key]), |
181 | 181 | drupal_render($form['name'][$key]), |
182 | 182 | drupal_render($form['nusers'][$key]), |
183 | 183 | drupal_render($form['link'][$key]), |
184 | - ); |
|
184 | + ); |
|
185 | + } |
|
185 | 186 | } |
186 | - } |
|
187 | - else { |
|
187 | + else { |
|
188 | 188 | $rows[] = array(array('data' => '<div class="error">No teams found</div>', 'colspan' => 5)); |
189 | - } |
|
190 | - $output .= theme('table', $header, $rows); |
|
191 | - if ($form['pager']['#value']) { |
|
189 | + } |
|
190 | + $output .= theme('table', $header, $rows); |
|
191 | + if ($form['pager']['#value']) { |
|
192 | 192 | $output .= drupal_render($form['pager']); |
193 | - } |
|
193 | + } |
|
194 | 194 | |
195 | - $output .= drupal_render($form); |
|
196 | - return $output; |
|
195 | + $output .= drupal_render($form); |
|
196 | + return $output; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -202,26 +202,26 @@ discard block |
||
202 | 202 | * table. It also removes the team's drupal page (node) if found. |
203 | 203 | */ |
204 | 204 | function boincteam_utility_batch_process($id, &$context) { |
205 | - $boincteam = boincteam_load($id); |
|
206 | - $drupalid = boincteam_lookup_nid($id); |
|
205 | + $boincteam = boincteam_load($id); |
|
206 | + $drupalid = boincteam_lookup_nid($id); |
|
207 | 207 | |
208 | - // Delete entry in team table |
|
209 | - db_set_active('boinc_rw'); |
|
210 | - $sql1='DELETE FROM {team} WHERE id=%d'; |
|
211 | - $db_res = db_query($sql1, $id); |
|
212 | - db_set_active('default'); |
|
208 | + // Delete entry in team table |
|
209 | + db_set_active('boinc_rw'); |
|
210 | + $sql1='DELETE FROM {team} WHERE id=%d'; |
|
211 | + $db_res = db_query($sql1, $id); |
|
212 | + db_set_active('default'); |
|
213 | 213 | |
214 | - // Delete entry in boincteam table |
|
215 | - $sql2='DELETE FROM {boincteam} WHERE id=%d'; |
|
216 | - $db_res = db_query($sql2, $id); |
|
214 | + // Delete entry in boincteam table |
|
215 | + $sql2='DELETE FROM {boincteam} WHERE id=%d'; |
|
216 | + $db_res = db_query($sql2, $id); |
|
217 | 217 | |
218 | - // Delete the drupal node (if present) |
|
219 | - if ($drupalid) { |
|
218 | + // Delete the drupal node (if present) |
|
219 | + if ($drupalid) { |
|
220 | 220 | node_delete($drupalid); |
221 | - } |
|
221 | + } |
|
222 | 222 | |
223 | - $context['results'][] = $id . ' : ' . check_plain($boincteam->name); |
|
224 | - $context['message'] = t('Processing team @name', array('@name' => $boincteam->name)); |
|
223 | + $context['results'][] = $id . ' : ' . check_plain($boincteam->name); |
|
224 | + $context['message'] = t('Processing team @name', array('@name' => $boincteam->name)); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | * or failure. |
230 | 230 | */ |
231 | 231 | function boincteam_utility_batch_finished($success, $results, $operations) { |
232 | - if ($success) { |
|
232 | + if ($success) { |
|
233 | 233 | $message = 'Info: Delete SPAM Teams utility- ' . count($results) . ' team(s) deleted.'; |
234 | 234 | drupal_set_message($message, 'info'); |
235 | - } |
|
236 | - else { |
|
235 | + } |
|
236 | + else { |
|
237 | 237 | // An error occurred. |
238 | 238 | // $operations contains the operations that remained unprocessed. |
239 | 239 | $error_operation = reset($operations); |
240 | 240 | $message = 'Error: An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
241 | 241 | drupal_set_message($message, 'error'); |
242 | - } |
|
242 | + } |
|
243 | 243 | } |
244 | 244 | \ No newline at end of file |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | // This variable name has been changed for Drupal 7/8. |
44 | 44 | $maintenance_mode = variable_get('site_offline'); |
45 | 45 | if (!$maintenance_mode) { |
46 | - drupal_set_message(t('WARNING: Site is online (not in maintenance mode)! Deleting teams is only allowed when site is offline. Change this setting in ') . l(t('Site maintenance'), '/admin/settings/site-maintenance'), 'warning'); |
|
46 | + drupal_set_message(t('WARNING: Site is online (not in maintenance mode)! Deleting teams is only allowed when site is offline. Change this setting in ').l(t('Site maintenance'), '/admin/settings/site-maintenance'), 'warning'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | $form['teamdelete'] = array( |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | '#value' => t('Delete Selected Teams'), |
57 | 57 | '#submit' => array('boincteam_utility_delete_team'), |
58 | 58 | '#attributes' => array( |
59 | - 'onclick' => 'return confirm(\'' . t('You are about to delete the selected teams suspected of being SPAM. Do you want to continue?') . '\')', |
|
59 | + 'onclick' => 'return confirm(\''.t('You are about to delete the selected teams suspected of being SPAM. Do you want to continue?').'\')', |
|
60 | 60 | ), |
61 | 61 | ); |
62 | 62 | $form['teamdelete']['results_table'] = array( |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | function boincteam_utility_team_table() { |
70 | 70 | |
71 | - $limit=50; |
|
71 | + $limit = 50; |
|
72 | 72 | $sql = "SELECT team.id AS id, team.name AS name, team.nusers AS nusers FROM {team} WHERE team.nusers<2 AND team.total_credit=0 AND team.seti_id=0 AND team.description REGEXP '<a href'"; |
73 | 73 | |
74 | 74 | // @todo - add bts() or t() |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $tablesort = tablesort_sql($resultheader); |
96 | 96 | db_set_active('boinc_rw'); |
97 | - $db_res = pager_query($sql . $tablesort, $limit); |
|
97 | + $db_res = pager_query($sql.$tablesort, $limit); |
|
98 | 98 | db_set_active('default'); |
99 | 99 | |
100 | 100 | $form = array(); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | while ($result = db_fetch_object($db_res)) { |
105 | 105 | $drupalnid = boincteam_lookup_nid($result->id); |
106 | 106 | if ($drupalnid) { |
107 | - $tlink = l($result->name, '/community/teams/' . $drupalnid); |
|
107 | + $tlink = l($result->name, '/community/teams/'.$drupalnid); |
|
108 | 108 | } |
109 | 109 | else { |
110 | 110 | $tlink = ''; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | 'operations' => $operations, |
150 | 150 | 'init_message' => t('Starting team deletion'), |
151 | 151 | 'finished' => 'boincteam_utility_batch_finished', |
152 | - 'file' => drupal_get_path('module', 'boincteam') . '/boincteam.admin.inc', |
|
152 | + 'file' => drupal_get_path('module', 'boincteam').'/boincteam.admin.inc', |
|
153 | 153 | ); |
154 | 154 | batch_set($batch); |
155 | 155 | //batch_process('/admin/boinc/utility-team-delete'); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | ); |
174 | 174 | $rows = array(); |
175 | 175 | $output = ""; |
176 | - if(!empty($form['checkboxes']['#options'])) { |
|
176 | + if (!empty($form['checkboxes']['#options'])) { |
|
177 | 177 | foreach (element_children($form['id']) as $key) { |
178 | 178 | $rows[] = array( |
179 | 179 | drupal_render($form['checkboxes'][$key]), |
@@ -207,12 +207,12 @@ discard block |
||
207 | 207 | |
208 | 208 | // Delete entry in team table |
209 | 209 | db_set_active('boinc_rw'); |
210 | - $sql1='DELETE FROM {team} WHERE id=%d'; |
|
210 | + $sql1 = 'DELETE FROM {team} WHERE id=%d'; |
|
211 | 211 | $db_res = db_query($sql1, $id); |
212 | 212 | db_set_active('default'); |
213 | 213 | |
214 | 214 | // Delete entry in boincteam table |
215 | - $sql2='DELETE FROM {boincteam} WHERE id=%d'; |
|
215 | + $sql2 = 'DELETE FROM {boincteam} WHERE id=%d'; |
|
216 | 216 | $db_res = db_query($sql2, $id); |
217 | 217 | |
218 | 218 | // Delete the drupal node (if present) |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | node_delete($drupalid); |
221 | 221 | } |
222 | 222 | |
223 | - $context['results'][] = $id . ' : ' . check_plain($boincteam->name); |
|
223 | + $context['results'][] = $id.' : '.check_plain($boincteam->name); |
|
224 | 224 | $context['message'] = t('Processing team @name', array('@name' => $boincteam->name)); |
225 | 225 | } |
226 | 226 | |
@@ -230,14 +230,14 @@ discard block |
||
230 | 230 | */ |
231 | 231 | function boincteam_utility_batch_finished($success, $results, $operations) { |
232 | 232 | if ($success) { |
233 | - $message = 'Info: Delete SPAM Teams utility- ' . count($results) . ' team(s) deleted.'; |
|
233 | + $message = 'Info: Delete SPAM Teams utility- '.count($results).' team(s) deleted.'; |
|
234 | 234 | drupal_set_message($message, 'info'); |
235 | 235 | } |
236 | 236 | else { |
237 | 237 | // An error occurred. |
238 | 238 | // $operations contains the operations that remained unprocessed. |
239 | 239 | $error_operation = reset($operations); |
240 | - $message = 'Error: An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
|
240 | + $message = 'Error: An error occurred while processing '.$error_operation[0].' with arguments :'.print_r($error_operation[0], TRUE); |
|
241 | 241 | drupal_set_message($message, 'error'); |
242 | 242 | } |
243 | 243 | } |
244 | 244 | \ No newline at end of file |
@@ -26,7 +26,7 @@ |
||
26 | 26 | page_head(tra("Change password")); |
27 | 27 | |
28 | 28 | form_start(secure_url_base()."edit_passwd_action.php", "post"); |
29 | -form_input_text(tra("New password"), "passwd", "", "password",'id="passwd"',passwd_visible_checkbox("passwd")); |
|
29 | +form_input_text(tra("New password"), "passwd", "", "password", 'id="passwd"', passwd_visible_checkbox("passwd")); |
|
30 | 30 | form_submit(tra("Change password")); |
31 | 31 | form_end(); |
32 | 32 | page_tail(); |
@@ -27,7 +27,7 @@ |
||
27 | 27 | |
28 | 28 | die("Delete this line first\n"); |
29 | 29 | |
30 | -$id = (int) $argv[1]; |
|
30 | +$id = (int)$argv[1]; |
|
31 | 31 | |
32 | 32 | $user = BoincUser::lookup_id($id); |
33 | 33 | if (!$user) die("no such user\n"); |
@@ -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')) { |
@@ -38,8 +38,7 @@ |
||
38 | 38 | * |
39 | 39 | * @return string |
40 | 40 | */ |
41 | - function random_bytes($bytes) |
|
42 | - { |
|
41 | + function random_bytes($bytes) { |
|
43 | 42 | try { |
44 | 43 | $bytes = RandomCompat_intval($bytes); |
45 | 44 | } catch (TypeError $ex) { |