@@ -11,12 +11,12 @@ discard block |
||
| 11 | 11 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| 12 | 12 | |
| 13 | 13 | if (!function_exists('user_load_by_mail')) { |
| 14 | - /** |
|
| 15 | - * user_load_by_mail will be broken out of user_load |
|
| 16 | - */ |
|
| 17 | - function user_load_by_mail($mail) { |
|
| 14 | + /** |
|
| 15 | + * user_load_by_mail will be broken out of user_load |
|
| 16 | + */ |
|
| 17 | + function user_load_by_mail($mail) { |
|
| 18 | 18 | return user_load(array('mail' => $mail)); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -28,14 +28,14 @@ discard block |
||
| 28 | 28 | * Get an image object from a given file and cck field |
| 29 | 29 | */ |
| 30 | 30 | function get_cck_image_object($image_path, $field_name, $content_type, $ignore_resolution = FALSE) { |
| 31 | - $field = content_fields($field_name, $content_type); |
|
| 32 | - $validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field)); |
|
| 33 | - if ($ignore_resolution) { |
|
| 31 | + $field = content_fields($field_name, $content_type); |
|
| 32 | + $validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field)); |
|
| 33 | + if ($ignore_resolution) { |
|
| 34 | 34 | unset($validators['filefield_validate_image_resolution']); |
| 35 | - } |
|
| 36 | - $target_path = filefield_widget_file_path($field); |
|
| 37 | - // Create the image object |
|
| 38 | - return field_file_save_file($image_path, $validators, $target_path, FILE_EXISTS_REPLACE); |
|
| 35 | + } |
|
| 36 | + $target_path = filefield_widget_file_path($field); |
|
| 37 | + // Create the image object |
|
| 38 | + return field_file_save_file($image_path, $validators, $target_path, FILE_EXISTS_REPLACE); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | |
@@ -47,73 +47,73 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | */ |
| 49 | 49 | function boincuser_check_credit_requirements() { |
| 50 | - global $user; |
|
| 51 | - if (!$user->uid) { |
|
| 50 | + global $user; |
|
| 51 | + if (!$user->uid) { |
|
| 52 | 52 | return FALSE; |
| 53 | - } |
|
| 54 | - $account = user_load($user->uid); |
|
| 55 | - $min_credit_to_post = variable_get('boinc_comment_min_credit', 0); |
|
| 56 | - $community_role = array_search('community member', user_roles(true)); |
|
| 57 | - $unrestricted_role = array_search('verified contributor', user_roles(true)); |
|
| 58 | - |
|
| 59 | - // Set user roles based on current penalty status... |
|
| 60 | - if ($account->boincuser_penalty_expiration > time()) { |
|
| 53 | + } |
|
| 54 | + $account = user_load($user->uid); |
|
| 55 | + $min_credit_to_post = variable_get('boinc_comment_min_credit', 0); |
|
| 56 | + $community_role = array_search('community member', user_roles(true)); |
|
| 57 | + $unrestricted_role = array_search('verified contributor', user_roles(true)); |
|
| 58 | + |
|
| 59 | + // Set user roles based on current penalty status... |
|
| 60 | + if ($account->boincuser_penalty_expiration > time()) { |
|
| 61 | 61 | drupal_set_message(bts( |
| 62 | - 'You are banned from community participation until @date', |
|
| 63 | - array('@date' => format_date($account->boincuser_penalty_expiration)) |
|
| 62 | + 'You are banned from community participation until @date', |
|
| 63 | + array('@date' => format_date($account->boincuser_penalty_expiration)) |
|
| 64 | 64 | ), 'warning', FALSE); |
| 65 | 65 | if (isset($account->roles[$community_role])) { |
| 66 | - // Remove from the community role, if not already |
|
| 67 | - unset($account->roles[$community_role]); |
|
| 66 | + // Remove from the community role, if not already |
|
| 67 | + unset($account->roles[$community_role]); |
|
| 68 | 68 | } |
| 69 | 69 | if (isset($account->roles[$unrestricted_role])) { |
| 70 | - // Likewise, revoke extra privileges |
|
| 71 | - unset($account->roles[$unrestricted_role]); |
|
| 70 | + // Likewise, revoke extra privileges |
|
| 71 | + unset($account->roles[$unrestricted_role]); |
|
| 72 | 72 | } |
| 73 | 73 | user_save($account, array('roles' => $account->roles)); |
| 74 | - } |
|
| 75 | - else { |
|
| 74 | + } |
|
| 75 | + else { |
|
| 76 | 76 | if (!isset($account->roles[$community_role])) { |
| 77 | - // The user should be a 'community member' role. If the user was |
|
| 78 | - // previously banned, this will restore that role. |
|
| 79 | - $account->roles[$community_role] = 'community member'; |
|
| 80 | - user_save($account, array('roles' => $account->roles)); |
|
| 77 | + // The user should be a 'community member' role. If the user was |
|
| 78 | + // previously banned, this will restore that role. |
|
| 79 | + $account->roles[$community_role] = 'community member'; |
|
| 80 | + user_save($account, array('roles' => $account->roles)); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // ... and total credit. |
| 84 | 84 | if ($account->boincuser_total_credit >= $min_credit_to_post) { |
| 85 | - if (!isset($account->roles[$unrestricted_role])) { |
|
| 85 | + if (!isset($account->roles[$unrestricted_role])) { |
|
| 86 | 86 | // This user is now above the credit threshold and is allowed full |
| 87 | 87 | // privileges |
| 88 | 88 | $account->roles[$unrestricted_role] = 'verified contributor'; |
| 89 | 89 | user_save($account, array('roles' => $account->roles)); |
| 90 | - } |
|
| 90 | + } |
|
| 91 | 91 | } |
| 92 | 92 | else { |
| 93 | - drupal_set_message(bts( |
|
| 93 | + drupal_set_message(bts( |
|
| 94 | 94 | 'You must earn @count more credits to be able to post comments on this site and create or modify your user profile.', |
| 95 | 95 | array('@count' => $min_credit_to_post - $account->boincuser_total_credit) |
| 96 | - ), 'warning', FALSE); |
|
| 97 | - if (isset($account->roles[$unrestricted_role])) { |
|
| 96 | + ), 'warning', FALSE); |
|
| 97 | + if (isset($account->roles[$unrestricted_role])) { |
|
| 98 | 98 | // Either the threshold has been raised or credits have been revoked; |
| 99 | 99 | // this user no longer qualifies for full privileges |
| 100 | 100 | unset($account->roles[$unrestricted_role]); |
| 101 | 101 | user_save($account, array('roles' => $account->roles)); |
| 102 | - } |
|
| 102 | + } |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - } |
|
| 105 | + } |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * Get the cid of the first comment the user has not seen on a given node |
| 110 | 110 | */ |
| 111 | 111 | function boincuser_get_first_unread_comment_id($nid, $uid = NULL) { |
| 112 | - if (!$uid) { |
|
| 112 | + if (!$uid) { |
|
| 113 | 113 | global $user; |
| 114 | 114 | $uid = $user->uid; |
| 115 | - } |
|
| 116 | - return db_result(db_query(" |
|
| 115 | + } |
|
| 116 | + return db_result(db_query(" |
|
| 117 | 117 | SELECT c.cid |
| 118 | 118 | FROM {node} n |
| 119 | 119 | INNER JOIN {comments} c ON c.nid = n.nid |
@@ -124,40 +124,40 @@ discard block |
||
| 124 | 124 | ORDER BY c.timestamp ASC |
| 125 | 125 | LIMIT 1", |
| 126 | 126 | $uid, $nid |
| 127 | - )); |
|
| 127 | + )); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * Choose and set the user of the day |
| 132 | 132 | */ |
| 133 | 133 | function boincuser_select_user_of_the_day() { |
| 134 | - // First get a list of users with recent credit |
|
| 135 | - db_set_active('boinc_rw'); |
|
| 136 | - $users_with_credit = db_query(" |
|
| 134 | + // First get a list of users with recent credit |
|
| 135 | + db_set_active('boinc_rw'); |
|
| 136 | + $users_with_credit = db_query(" |
|
| 137 | 137 | SELECT |
| 138 | 138 | id |
| 139 | 139 | FROM {user} u |
| 140 | 140 | JOIN {profile} p ON p.userid = u.id |
| 141 | 141 | WHERE expavg_credit > 1 |
| 142 | 142 | ORDER BY uotd_time ASC, RAND()" |
| 143 | - ); |
|
| 144 | - db_set_active('default'); |
|
| 145 | - $active_users = array(); |
|
| 146 | - while ($user_with_credit = db_fetch_object($users_with_credit)) { |
|
| 143 | + ); |
|
| 144 | + db_set_active('default'); |
|
| 145 | + $active_users = array(); |
|
| 146 | + while ($user_with_credit = db_fetch_object($users_with_credit)) { |
|
| 147 | 147 | $active_users[] = $user_with_credit->id; |
| 148 | - } |
|
| 149 | - $active_users = implode(',', $active_users); |
|
| 150 | - // Limit to users who have never been user of the day, if there are any |
|
| 151 | - $never_been_picked = db_result(db_query(" |
|
| 148 | + } |
|
| 149 | + $active_users = implode(',', $active_users); |
|
| 150 | + // Limit to users who have never been user of the day, if there are any |
|
| 151 | + $never_been_picked = db_result(db_query(" |
|
| 152 | 152 | SELECT COUNT(*) |
| 153 | 153 | FROM {boincuser} bu |
| 154 | 154 | WHERE bu.uotd_time = 0 |
| 155 | 155 | " . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '') |
| 156 | - )); |
|
| 157 | - $new_uotd_uid = 0; |
|
| 158 | - while (!$new_uotd_uid) { |
|
| 156 | + )); |
|
| 157 | + $new_uotd_uid = 0; |
|
| 158 | + while (!$new_uotd_uid) { |
|
| 159 | 159 | // Select a user of the day randomly from the pool |
| 160 | - $new_uotd_uid = db_result(db_query(" |
|
| 160 | + $new_uotd_uid = db_result(db_query(" |
|
| 161 | 161 | SELECT |
| 162 | 162 | n.uid |
| 163 | 163 | FROM {node} n |
@@ -171,31 +171,31 @@ discard block |
||
| 171 | 171 | LIMIT 1" |
| 172 | 172 | )); |
| 173 | 173 | if (!$new_uotd_uid) { |
| 174 | - // Can't find a user with a profile; remove constraints on the pool |
|
| 175 | - if ($never_been_picked) { |
|
| 174 | + // Can't find a user with a profile; remove constraints on the pool |
|
| 175 | + if ($never_been_picked) { |
|
| 176 | 176 | // Allow users who have been previously selected |
| 177 | 177 | $never_been_picked = FALSE; |
| 178 | - } |
|
| 179 | - elseif ($active_users) { |
|
| 178 | + } |
|
| 179 | + elseif ($active_users) { |
|
| 180 | 180 | // Allow users who are not even active (getting desperate) |
| 181 | 181 | $active_users = FALSE; |
| 182 | - } |
|
| 183 | - else { |
|
| 182 | + } |
|
| 183 | + else { |
|
| 184 | 184 | // Process failed... |
| 185 | 185 | return FALSE; |
| 186 | - } |
|
| 186 | + } |
|
| 187 | 187 | } |
| 188 | - } |
|
| 189 | - $uotd = user_load($new_uotd_uid); |
|
| 190 | - if ($uotd->uid) { |
|
| 188 | + } |
|
| 189 | + $uotd = user_load($new_uotd_uid); |
|
| 190 | + if ($uotd->uid) { |
|
| 191 | 191 | db_query(" |
| 192 | 192 | UPDATE {boincuser} |
| 193 | 193 | SET uotd_time = '%d' |
| 194 | 194 | WHERE uid = '%d'", |
| 195 | - time(), $uotd->uid |
|
| 195 | + time(), $uotd->uid |
|
| 196 | 196 | ); |
| 197 | - } |
|
| 198 | - return $uotd; |
|
| 197 | + } |
|
| 198 | + return $uotd; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | |
@@ -213,71 +213,71 @@ discard block |
||
| 213 | 213 | * new and prev email. |
| 214 | 214 | */ |
| 215 | 215 | function _boincuser_send_emailchange($account, $new_email=NULL, $prev_email=NULL, $adminuser=FALSE) { |
| 216 | - require_boinc('token'); |
|
| 217 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
| 216 | + require_boinc('token'); |
|
| 217 | + module_load_include('inc', 'rules', 'modules/system.rules'); |
|
| 218 | 218 | |
| 219 | - global $base_url; |
|
| 220 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
| 219 | + global $base_url; |
|
| 220 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
| 221 | 221 | |
| 222 | - if (is_null($new_email)) { |
|
| 222 | + if (is_null($new_email)) { |
|
| 223 | 223 | $new_email = $account->mail; |
| 224 | - } |
|
| 225 | - if (is_null($prev_email)) { |
|
| 224 | + } |
|
| 225 | + if (is_null($prev_email)) { |
|
| 226 | 226 | $prev_email = $account->boincuser_previous_email_addr; |
| 227 | - } |
|
| 228 | - |
|
| 229 | - // @todo - set constant in drupal, or use BOINC contsants |
|
| 230 | - $duration = TOKEN_DURATION_ONE_WEEK; |
|
| 231 | - $changedate = date('F j, Y \a\t G:i T', time()); |
|
| 232 | - $newdate = date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration); |
|
| 233 | - $token = create_token($account->boincuser_id, TOKEN_TYPE_CHANGE_EMAIL, $duration); |
|
| 234 | - if ($adminuser) { |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + // @todo - set constant in drupal, or use BOINC contsants |
|
| 230 | + $duration = TOKEN_DURATION_ONE_WEEK; |
|
| 231 | + $changedate = date('F j, Y \a\t G:i T', time()); |
|
| 232 | + $newdate = date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration); |
|
| 233 | + $token = create_token($account->boincuser_id, TOKEN_TYPE_CHANGE_EMAIL, $duration); |
|
| 234 | + if ($adminuser) { |
|
| 235 | 235 | $graf1 = "Your email address was changed from {$prev_email} to {$new_email} " |
| 236 | - . "on {$changedate}. If you need to reverse this change, please look for " |
|
| 237 | - . "an email send to the email address: {$prev_email}.\n"; |
|
| 238 | - } |
|
| 239 | - else { |
|
| 236 | + . "on {$changedate}. If you need to reverse this change, please look for " |
|
| 237 | + . "an email send to the email address: {$prev_email}.\n"; |
|
| 238 | + } |
|
| 239 | + else { |
|
| 240 | 240 | $graf1 = "Your email address was changed from {$prev_email} to {$new_email} " |
| 241 | - . "on {$changedate}. You will not be able to change your email address " |
|
| 242 | - . "until {$newdate}. If you need to reverse this change, please look for " |
|
| 243 | - . "an email send to the email address: {$prev_email}.\n"; |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - // Send email #1 to current address |
|
| 247 | - $mysubject = "Notification of email change at {$site_name}"; |
|
| 248 | - $mymessage = '' |
|
| 249 | - . "{$account->boincuser_name},\n" |
|
| 250 | - . "\n" |
|
| 251 | - . $graf1 |
|
| 252 | - . "\n" |
|
| 253 | - . "Thanks, \n" |
|
| 254 | - . "{$site_name} support team\n"; |
|
| 255 | - |
|
| 256 | - $settings = array( |
|
| 241 | + . "on {$changedate}. You will not be able to change your email address " |
|
| 242 | + . "until {$newdate}. If you need to reverse this change, please look for " |
|
| 243 | + . "an email send to the email address: {$prev_email}.\n"; |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + // Send email #1 to current address |
|
| 247 | + $mysubject = "Notification of email change at {$site_name}"; |
|
| 248 | + $mymessage = '' |
|
| 249 | + . "{$account->boincuser_name},\n" |
|
| 250 | + . "\n" |
|
| 251 | + . $graf1 |
|
| 252 | + . "\n" |
|
| 253 | + . "Thanks, \n" |
|
| 254 | + . "{$site_name} support team\n"; |
|
| 255 | + |
|
| 256 | + $settings = array( |
|
| 257 | 257 | 'from' => '', |
| 258 | 258 | 'to' => $new_email, |
| 259 | 259 | 'subject' => $mysubject, |
| 260 | 260 | 'message' => $mymessage, |
| 261 | - ); |
|
| 262 | - rules_action_mail_to_user($account, $settings); |
|
| 263 | - |
|
| 264 | - // Send email #2 to previous address. |
|
| 265 | - $mymessage = '' |
|
| 266 | - . "Your email address has been changed. If you did not intend to take this action, then please click this link to reverse this change, or copy-and-paste the link into your browser location bar. You will need to change your password as well.\n" |
|
| 267 | - . "\n" |
|
| 268 | - . "{$base_url}/user/{$account->uid}/recoveremail/{$token}\n" |
|
| 269 | - . "\n" |
|
| 270 | - . "Thanks, \n" |
|
| 271 | - . "{$site_name} support team\n"; |
|
| 272 | - |
|
| 273 | - $settings = array( |
|
| 261 | + ); |
|
| 262 | + rules_action_mail_to_user($account, $settings); |
|
| 263 | + |
|
| 264 | + // Send email #2 to previous address. |
|
| 265 | + $mymessage = '' |
|
| 266 | + . "Your email address has been changed. If you did not intend to take this action, then please click this link to reverse this change, or copy-and-paste the link into your browser location bar. You will need to change your password as well.\n" |
|
| 267 | + . "\n" |
|
| 268 | + . "{$base_url}/user/{$account->uid}/recoveremail/{$token}\n" |
|
| 269 | + . "\n" |
|
| 270 | + . "Thanks, \n" |
|
| 271 | + . "{$site_name} support team\n"; |
|
| 272 | + |
|
| 273 | + $settings = array( |
|
| 274 | 274 | 'from' => '', |
| 275 | 275 | 'to' => $prev_email, |
| 276 | 276 | 'subject' => $mysubject, |
| 277 | 277 | 'message' => $mymessage, |
| 278 | - ); |
|
| 278 | + ); |
|
| 279 | 279 | |
| 280 | - rules_action_mail($settings); |
|
| 280 | + rules_action_mail($settings); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
@@ -287,32 +287,32 @@ discard block |
||
| 287 | 287 | * |
| 288 | 288 | */ |
| 289 | 289 | function create_proper_drupalname($requested_name) { |
| 290 | - if (!$requested_name) { |
|
| 290 | + if (!$requested_name) { |
|
| 291 | 291 | // If the name is empty, set it |
| 292 | 292 | $requested_name = 'anonymous'; |
| 293 | - } |
|
| 294 | - $same_name_tally = 1; |
|
| 295 | - |
|
| 296 | - // Remove extra spaces |
|
| 297 | - $name2 = preg_replace("/ {2,}/", " ", trim($requested_name)); |
|
| 298 | - // Remove any non-valid characters |
|
| 299 | - $cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $name2); |
|
| 300 | - // Truncate name |
|
| 301 | - $name_length = strlen($cleaned_name); |
|
| 302 | - if ($name_length > 56) { |
|
| 293 | + } |
|
| 294 | + $same_name_tally = 1; |
|
| 295 | + |
|
| 296 | + // Remove extra spaces |
|
| 297 | + $name2 = preg_replace("/ {2,}/", " ", trim($requested_name)); |
|
| 298 | + // Remove any non-valid characters |
|
| 299 | + $cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $name2); |
|
| 300 | + // Truncate name |
|
| 301 | + $name_length = strlen($cleaned_name); |
|
| 302 | + if ($name_length > 56) { |
|
| 303 | 303 | // Name is limited to 60 characters, but we want to leave space to add a |
| 304 | 304 | // tally if needed (for users with duplicate names); Limit to 56 chars and |
| 305 | 305 | // replace the middle of the string with "..." if too long |
| 306 | 306 | $cleaned_name = substr_replace($cleaned_name, '...', 28, ($name_length-56)+3); |
| 307 | - } |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - // Determine if there are duplicate names, if so append a number to end. |
|
| 310 | - $unique_name = $cleaned_name; |
|
| 311 | - while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) { |
|
| 309 | + // Determine if there are duplicate names, if so append a number to end. |
|
| 310 | + $unique_name = $cleaned_name; |
|
| 311 | + while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) { |
|
| 312 | 312 | $same_name_tally++; |
| 313 | 313 | $unique_name = "{$cleaned_name}_{$same_name_tally}"; |
| 314 | - } |
|
| 315 | - return $unique_name; |
|
| 314 | + } |
|
| 315 | + return $unique_name; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | |
@@ -326,9 +326,9 @@ discard block |
||
| 326 | 326 | * |
| 327 | 327 | */ |
| 328 | 328 | function boincuser_check_termsofuse($user) { |
| 329 | - require_boinc('consent'); |
|
| 330 | - $boinc_user = boincuser_load($user->uid, TRUE); |
|
| 331 | - return check_user_consent($boinc_user, CONSENT_TYPE_ENROLL); |
|
| 329 | + require_boinc('consent'); |
|
| 330 | + $boinc_user = boincuser_load($user->uid, TRUE); |
|
| 331 | + return check_user_consent($boinc_user, CONSENT_TYPE_ENROLL); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
@@ -339,33 +339,33 @@ discard block |
||
| 339 | 339 | * |
| 340 | 340 | */ |
| 341 | 341 | function boincuser_consentto_termsofuse($user) { |
| 342 | - require_boinc('consent'); |
|
| 343 | - $boinc_user = boincuser_load($user->uid, TRUE); |
|
| 342 | + require_boinc('consent'); |
|
| 343 | + $boinc_user = boincuser_load($user->uid, TRUE); |
|
| 344 | 344 | |
| 345 | - list($checkct, $ctid) = check_consent_type(CONSENT_TYPE_ENROLL); |
|
| 346 | - if ($checkct) { |
|
| 345 | + list($checkct, $ctid) = check_consent_type(CONSENT_TYPE_ENROLL); |
|
| 346 | + if ($checkct) { |
|
| 347 | 347 | $rc1 = consent_to_a_policy($boinc_user, $ctid, 1, 0, 'Webform', time()); |
| 348 | 348 | if (!$rc1) { |
| 349 | - drupal_set_message( |
|
| 349 | + drupal_set_message( |
|
| 350 | 350 | bts("ERROR: Database error when attempting to INSERT into table consent with ID=@id. The @project administrators have been notified.", |
| 351 | 351 | array( |
| 352 | - '@id' => $boinc_user->id, |
|
| 353 | - '@project' => variable_get('site_name', 'Drupal-BOINC'), NULL, 'boinc:add-new-user' |
|
| 352 | + '@id' => $boinc_user->id, |
|
| 353 | + '@project' => variable_get('site_name', 'Drupal-BOINC'), NULL, 'boinc:add-new-user' |
|
| 354 | 354 | ), |
| 355 | 355 | 'NULL', 'boinc:consent-termsofuse'), |
| 356 | - 'error'); |
|
| 357 | - rules_invoke_event('boincuser_general_consent_error', variable_get('boinc_admin_mailing_list_subject_tag', '')); |
|
| 356 | + 'error'); |
|
| 357 | + rules_invoke_event('boincuser_general_consent_error', variable_get('boinc_admin_mailing_list_subject_tag', '')); |
|
| 358 | 358 | } |
| 359 | 359 | return $rc1; |
| 360 | - } |
|
| 361 | - else { |
|
| 360 | + } |
|
| 361 | + else { |
|
| 362 | 362 | drupal_set_message( |
| 363 | - bts('ERROR: Consent type for enrollment not found. The @project administrators have been nofitifed.', |
|
| 363 | + bts('ERROR: Consent type for enrollment not found. The @project administrators have been nofitifed.', |
|
| 364 | 364 | array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:consent-termsofuse'), |
| 365 | 365 | 'error'); |
| 366 | 366 | rules_invoke_event('boincuser_general_consent_type_error', CONSENT_TYPE_ENROLL, variable_get('boinc_admin_mailing_list_subject_tag', '')); |
| 367 | - } |
|
| 368 | - return FALSE; |
|
| 367 | + } |
|
| 368 | + return FALSE; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -374,16 +374,16 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | function _boincuser_ignore_paths($path, $paths_to_ignore) { |
| 376 | 376 | |
| 377 | - foreach ($paths_to_ignore as $pi) { |
|
| 377 | + foreach ($paths_to_ignore as $pi) { |
|
| 378 | 378 | // @todo Currently this function uses {} as PHP regexp |
| 379 | 379 | // delimiters. Curly brace is not really allowed un URLs, but a |
| 380 | 380 | // more robust function would first check for these curly braces |
| 381 | 381 | // in the path_to_ignore patterms, just in case. |
| 382 | 382 | if (preg_match('{' . $pi . '}', $path)) { |
| 383 | - return TRUE; |
|
| 383 | + return TRUE; |
|
| 384 | 384 | } |
| 385 | - } |
|
| 386 | - return FALSE; |
|
| 385 | + } |
|
| 386 | + return FALSE; |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
@@ -391,20 +391,20 @@ discard block |
||
| 391 | 391 | * Drupal's recover email path. |
| 392 | 392 | */ |
| 393 | 393 | function _boincuser_redirect_recover_email() { |
| 394 | - $params = array( |
|
| 394 | + $params = array( |
|
| 395 | 395 | 'boincid' => isset($_GET['id']) ? $_GET['id'] : '', |
| 396 | 396 | 'token' => isset($_GET['token']) ? $_GET['token'] : '' |
| 397 | - ); |
|
| 397 | + ); |
|
| 398 | 398 | |
| 399 | - // If boincid or token is not present, then go to the home page. |
|
| 400 | - if (empty($params['boincid']) or empty($params['token'])) { |
|
| 399 | + // If boincid or token is not present, then go to the home page. |
|
| 400 | + if (empty($params['boincid']) or empty($params['token'])) { |
|
| 401 | 401 | $redirect = ''; |
| 402 | - } |
|
| 403 | - else { |
|
| 402 | + } |
|
| 403 | + else { |
|
| 404 | 404 | $uid = boincuser_lookup_uid($params['boincid']); |
| 405 | 405 | $redirect = "/user/${uid}/recoveremail/${params['token']}"; |
| 406 | - } |
|
| 407 | - drupal_goto($redirect); |
|
| 406 | + } |
|
| 407 | + drupal_goto($redirect); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -415,17 +415,17 @@ discard block |
||
| 415 | 415 | * Require BOINC library |
| 416 | 416 | */ |
| 417 | 417 | function require_boinc($libraries) { |
| 418 | - if ($include_dir = boinc_get_path('html_inc')) { |
|
| 418 | + if ($include_dir = boinc_get_path('html_inc')) { |
|
| 419 | 419 | $working_dir = getcwd(); |
| 420 | 420 | chdir($include_dir); |
| 421 | 421 | if (!is_array($libraries)) { |
| 422 | - $libraries = array($libraries); |
|
| 422 | + $libraries = array($libraries); |
|
| 423 | 423 | } |
| 424 | 424 | foreach ($libraries as $library) { |
| 425 | - require_once("{$library}.inc"); |
|
| 425 | + require_once("{$library}.inc"); |
|
| 426 | 426 | } |
| 427 | 427 | chdir($working_dir); |
| 428 | - } |
|
| 428 | + } |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | /** |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | * The path from the BOINC html root must be included (e.g. user/file.php) |
| 434 | 434 | */ |
| 435 | 435 | function include_boinc($file) { |
| 436 | - if ($include_dir = boinc_get_path()) { |
|
| 436 | + if ($include_dir = boinc_get_path()) { |
|
| 437 | 437 | $include_dir .= '/html'; |
| 438 | 438 | $workingDir = getcwd(); |
| 439 | 439 | $path = dirname($file); |
@@ -441,84 +441,84 @@ discard block |
||
| 441 | 441 | chdir("{$include_dir}/{$path}"); |
| 442 | 442 | include($file); |
| 443 | 443 | chdir($workingDir); |
| 444 | - } |
|
| 444 | + } |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | /** |
| 448 | 448 | * Get the BOINC include path |
| 449 | 449 | */ |
| 450 | 450 | function boinc_get_path($type = 'root') { |
| 451 | - $dir = "boinc_{$type}_dir"; |
|
| 452 | - if ($include_dir = variable_get("boinc_{$type}_dir", '')) { |
|
| 451 | + $dir = "boinc_{$type}_dir"; |
|
| 452 | + if ($include_dir = variable_get("boinc_{$type}_dir", '')) { |
|
| 453 | 453 | return $include_dir; |
| 454 | - } |
|
| 455 | - else { |
|
| 454 | + } |
|
| 455 | + else { |
|
| 456 | 456 | // Don't show errors on blacklisted pages |
| 457 | 457 | $page_blacklist = array( |
| 458 | - 'admin/boinc/environment' |
|
| 458 | + 'admin/boinc/environment' |
|
| 459 | 459 | ); |
| 460 | 460 | if (!in_array($_GET['q'], $page_blacklist)) { |
| 461 | - watchdog('boincuser', 'The BOINC environment is not configured. Please |
|
| 461 | + watchdog('boincuser', 'The BOINC environment is not configured. Please |
|
| 462 | 462 | !configure_it', array('!configure_it' => l(t('configure it now'), |
| 463 | 463 | 'admin/boinc/environment')), WATCHDOG_WARNING); |
| 464 | - if (user_access('administer site configuration')) { |
|
| 464 | + if (user_access('administer site configuration')) { |
|
| 465 | 465 | drupal_set_message(t('The BOINC environment is not configured. Please |
| 466 | 466 | !configure_it', array('!configure_it' => l(t('configure it now'), |
| 467 | 467 | 'admin/boinc/environment'))), 'warning', FALSE); |
| 468 | - } |
|
| 469 | - else { |
|
| 468 | + } |
|
| 469 | + else { |
|
| 470 | 470 | drupal_set_message(t('There is a problem with the site. Please contact |
| 471 | 471 | the system administrator.'), 'error', FALSE); |
| 472 | - } |
|
| 473 | - // Redirect home to display the error message and avoid fatal errors |
|
| 474 | - // (unless on a blacklisted page) |
|
| 475 | - $redirect_blacklist = array( |
|
| 472 | + } |
|
| 473 | + // Redirect home to display the error message and avoid fatal errors |
|
| 474 | + // (unless on a blacklisted page) |
|
| 475 | + $redirect_blacklist = array( |
|
| 476 | 476 | 'admin/settings/performance', |
| 477 | 477 | 'admin/boinc/environment', |
| 478 | 478 | 'home', |
| 479 | 479 | '' |
| 480 | - ); |
|
| 481 | - if (!in_array($_GET['q'], $redirect_blacklist)) { |
|
| 480 | + ); |
|
| 481 | + if (!in_array($_GET['q'], $redirect_blacklist)) { |
|
| 482 | 482 | drupal_goto(''); |
| 483 | - } |
|
| 483 | + } |
|
| 484 | 484 | } |
| 485 | 485 | else { |
| 486 | - // Clear the messages on the environment config page |
|
| 487 | - drupal_get_messages(); |
|
| 486 | + // Clear the messages on the environment config page |
|
| 487 | + drupal_get_messages(); |
|
| 488 | 488 | } |
| 489 | - } |
|
| 490 | - return FALSE; |
|
| 489 | + } |
|
| 490 | + return FALSE; |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | /** |
| 494 | 494 | * Get the configured scheduler tags |
| 495 | 495 | */ |
| 496 | 496 | function boinc_get_scheduler_tags() { |
| 497 | - // Don't generate messages for blacklisted pages |
|
| 498 | - $page_blacklist = array( |
|
| 497 | + // Don't generate messages for blacklisted pages |
|
| 498 | + $page_blacklist = array( |
|
| 499 | 499 | 'admin/boinc/environment', |
| 500 | 500 | 'admin/boinc/scheduler' |
| 501 | - ); |
|
| 502 | - if ($url_config = variable_get('boinc_scheduler_urls', '')) { |
|
| 501 | + ); |
|
| 502 | + if ($url_config = variable_get('boinc_scheduler_urls', '')) { |
|
| 503 | 503 | return explode("\r\n", $url_config); |
| 504 | - } |
|
| 505 | - elseif (!in_array($_GET['q'], $page_blacklist)) { |
|
| 504 | + } |
|
| 505 | + elseif (!in_array($_GET['q'], $page_blacklist)) { |
|
| 506 | 506 | watchdog('boincuser', 'The BOINC scheduling server settings are not yet |
| 507 | 507 | configured. Please !verify for the settings to become effective.', |
| 508 | - array('!verify' => l(t('verify the default values') . ' <strong>' . |
|
| 508 | + array('!verify' => l(t('verify the default values') . ' <strong>' . |
|
| 509 | 509 | t('and') . '</strong> ' . t('save the configuration'), |
| 510 | 510 | 'admin/boinc/scheduler', array('html' => TRUE)) |
| 511 | - ), WATCHDOG_WARNING); |
|
| 511 | + ), WATCHDOG_WARNING); |
|
| 512 | 512 | if (user_access('administer site configuration')) { |
| 513 | - drupal_set_message(t('The BOINC scheduling server settings are not yet |
|
| 513 | + drupal_set_message(t('The BOINC scheduling server settings are not yet |
|
| 514 | 514 | configured. Please !verify for the settings to become effective', |
| 515 | 515 | array('!verify' => l(t('verify the default values') . ' <strong>' . |
| 516 | - t('and') . '</strong> ' . t('save the configuration'), |
|
| 517 | - 'admin/boinc/scheduler', array('html' => TRUE)) |
|
| 516 | + t('and') . '</strong> ' . t('save the configuration'), |
|
| 517 | + 'admin/boinc/scheduler', array('html' => TRUE)) |
|
| 518 | 518 | )), 'warning', FALSE); |
| 519 | 519 | } |
| 520 | - } |
|
| 521 | - return array(); |
|
| 520 | + } |
|
| 521 | + return array(); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -530,41 +530,41 @@ discard block |
||
| 530 | 530 | * Determine if a BOINC ID matches the logged in user |
| 531 | 531 | */ |
| 532 | 532 | function is_current_boinc_user($boinc_id) { |
| 533 | - global $user; |
|
| 534 | - if (!$user->uid) { |
|
| 533 | + global $user; |
|
| 534 | + if (!$user->uid) { |
|
| 535 | 535 | return FALSE; |
| 536 | - } |
|
| 537 | - // boincuser_id is not stored in the global user, so load a new instance |
|
| 538 | - $drupuser = user_load($user->uid); |
|
| 539 | - return ($boinc_id == $drupuser->boincuser_id); |
|
| 536 | + } |
|
| 537 | + // boincuser_id is not stored in the global user, so load a new instance |
|
| 538 | + $drupuser = user_load($user->uid); |
|
| 539 | + return ($boinc_id == $drupuser->boincuser_id); |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | /** |
| 543 | 543 | * Convert a BOINC ID to a Drupal ID |
| 544 | 544 | */ |
| 545 | 545 | function boincuser_lookup_uid($boinc_id) { |
| 546 | - $drupal_id = db_result(db_query("SELECT uid FROM {boincuser} WHERE boinc_id='%d'", $boinc_id)); |
|
| 547 | - return $drupal_id; |
|
| 546 | + $drupal_id = db_result(db_query("SELECT uid FROM {boincuser} WHERE boinc_id='%d'", $boinc_id)); |
|
| 547 | + return $drupal_id; |
|
| 548 | 548 | } |
| 549 | 549 | function get_drupal_id($boinc_id) { |
| 550 | - return boincuser_lookup_uid($boinc_id); |
|
| 550 | + return boincuser_lookup_uid($boinc_id); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | /** |
| 554 | 554 | * Get a BOINC user object |
| 555 | 555 | */ |
| 556 | 556 | function boincuser_load($user_id = NULL, $is_drupal_id = FALSE) { |
| 557 | - if (!$user_id) { |
|
| 557 | + if (!$user_id) { |
|
| 558 | 558 | global $user; |
| 559 | 559 | $user_id = $user->uid; |
| 560 | 560 | $is_drupal_id = TRUE; |
| 561 | - } |
|
| 562 | - if ($is_drupal_id) { |
|
| 561 | + } |
|
| 562 | + if ($is_drupal_id) { |
|
| 563 | 563 | $account = user_load($user_id); |
| 564 | 564 | $user_id = $account->boincuser_id; |
| 565 | - } |
|
| 566 | - require_boinc('boinc_db'); |
|
| 567 | - return BoincUser::lookup_id($user_id); |
|
| 565 | + } |
|
| 566 | + require_boinc('boinc_db'); |
|
| 567 | + return BoincUser::lookup_id($user_id); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | /** |
@@ -574,10 +574,10 @@ discard block |
||
| 574 | 574 | * page, delete button. |
| 575 | 575 | */ |
| 576 | 576 | function _boincuser_node_profile_delete_submit($form, &$form_state) { |
| 577 | - $node = $form['#node']; |
|
| 578 | - $deleteurl = 'node/'. $node->nid .'/delete'; |
|
| 579 | - $afterq = 'destination=account'; |
|
| 580 | - drupal_goto($deleteurl, $afterq); |
|
| 577 | + $node = $form['#node']; |
|
| 578 | + $deleteurl = 'node/'. $node->nid .'/delete'; |
|
| 579 | + $afterq = 'destination=account'; |
|
| 580 | + drupal_goto($deleteurl, $afterq); |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -588,8 +588,8 @@ discard block |
||
| 588 | 588 | * Wrapper for boinc_version() function |
| 589 | 589 | */ |
| 590 | 590 | function get_boinc_version($x) { |
| 591 | - require_boinc('host'); |
|
| 592 | - return function_exists('boinc_version') ? boinc_version(parse_serialnum($x)) : 'err!'; |
|
| 591 | + require_boinc('host'); |
|
| 592 | + return function_exists('boinc_version') ? boinc_version(parse_serialnum($x)) : 'err!'; |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | |
@@ -598,14 +598,14 @@ discard block |
||
| 598 | 598 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| 599 | 599 | |
| 600 | 600 | /** |
| 601 | - * Generate the friend block header |
|
| 602 | - */ |
|
| 601 | + * Generate the friend block header |
|
| 602 | + */ |
|
| 603 | 603 | function boincuser_views_friends_block_header($context = null) { |
| 604 | - // Get the friend count for the user being viewed |
|
| 605 | - $view = views_get_current_view(); |
|
| 606 | - $account_id = $view->args[0]; |
|
| 607 | - $friend_count = flag_friend_get_friend_count($account_id); |
|
| 608 | - return '<h2 class="pane-title">' . bts('Friends (@count)', |
|
| 604 | + // Get the friend count for the user being viewed |
|
| 605 | + $view = views_get_current_view(); |
|
| 606 | + $account_id = $view->args[0]; |
|
| 607 | + $friend_count = flag_friend_get_friend_count($account_id); |
|
| 608 | + return '<h2 class="pane-title">' . bts('Friends (@count)', |
|
| 609 | 609 | array('@count' => $friend_count)) . '</h2>'; |
| 610 | 610 | } |
| 611 | 611 | |
@@ -614,13 +614,13 @@ discard block |
||
| 614 | 614 | * database. |
| 615 | 615 | */ |
| 616 | 616 | function _boincuser_user_name_autocomplete($string) { |
| 617 | - $matches = array(); |
|
| 618 | - db_set_active('boinc_ro'); |
|
| 619 | - $result = db_query_range("SELECT id,name FROM {user} WHERE name LIKE '%s%'", $string, 0, 10); |
|
| 620 | - db_set_active('default'); |
|
| 621 | - while ($user = db_fetch_object($result)) { |
|
| 622 | - $matches[$user->name . '_' . $user->id] = htmlentities($user->name) . " (" . $user->id . ')'; |
|
| 623 | - } |
|
| 624 | - |
|
| 625 | - drupal_json((object)$matches); |
|
| 617 | + $matches = array(); |
|
| 618 | + db_set_active('boinc_ro'); |
|
| 619 | + $result = db_query_range("SELECT id,name FROM {user} WHERE name LIKE '%s%'", $string, 0, 10); |
|
| 620 | + db_set_active('default'); |
|
| 621 | + while ($user = db_fetch_object($result)) { |
|
| 622 | + $matches[$user->name . '_' . $user->id] = htmlentities($user->name) . " (" . $user->id . ')'; |
|
| 623 | + } |
|
| 624 | + |
|
| 625 | + drupal_json((object)$matches); |
|
| 626 | 626 | } |
@@ -28,138 +28,138 @@ |
||
| 28 | 28 | check_tokens($user->authenticator); |
| 29 | 29 | |
| 30 | 30 | function account_ownership_action($user) { |
| 31 | - // POST request - the user has submitted the form. |
|
| 32 | - page_head(tra("Proof of account ownership results"), null, null, null, boinc_recaptcha_get_head_extra()); |
|
| 33 | - |
|
| 34 | - if (recaptcha_private_key()) { |
|
| 35 | - // Recaptcha is enabled on the BOINC server |
|
| 36 | - if (!boinc_recaptcha_isValidated(recaptcha_private_key())) { |
|
| 37 | - // The user failed to solve the recaptcha prompt - redirect them to an error message! |
|
| 38 | - error_page( |
|
| 39 | - tra("Your reCAPTCHA response was not correct. Please try again.") |
|
| 40 | - ); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - // Input is passed in from the openssl_sign_form |
|
| 45 | - $user_data = htmlentities(post_str("user_data", true), ENT_QUOTES, "UTF-8"); // Convert special characters to html equivelant |
|
| 46 | - |
|
| 47 | - if ((strlen($user_data) > 0) && (strlen($user_data) <= 4096)) { |
|
| 48 | - require_once("../inc/account_ownership.inc"); |
|
| 49 | - // Check that the private key file exists where specified. If not, redirect to error page. |
|
| 50 | - if (!file_exists($account_ownership_private_key_file_path)) { |
|
| 51 | - error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - // Check that the public key file exists where specified. If not, redirect to error page. |
|
| 55 | - if (!file_exists($account_ownership_public_key_file_path)) { |
|
| 56 | - error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - $privkey = fopen($account_ownership_private_key_file_path, "r"); // Opening private key file |
|
| 60 | - if (!isset($privkey) || empty($privkey)) { |
|
| 31 | + // POST request - the user has submitted the form. |
|
| 32 | + page_head(tra("Proof of account ownership results"), null, null, null, boinc_recaptcha_get_head_extra()); |
|
| 33 | + |
|
| 34 | + if (recaptcha_private_key()) { |
|
| 35 | + // Recaptcha is enabled on the BOINC server |
|
| 36 | + if (!boinc_recaptcha_isValidated(recaptcha_private_key())) { |
|
| 37 | + // The user failed to solve the recaptcha prompt - redirect them to an error message! |
|
| 38 | + error_page( |
|
| 39 | + tra("Your reCAPTCHA response was not correct. Please try again.") |
|
| 40 | + ); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + // Input is passed in from the openssl_sign_form |
|
| 45 | + $user_data = htmlentities(post_str("user_data", true), ENT_QUOTES, "UTF-8"); // Convert special characters to html equivelant |
|
| 46 | + |
|
| 47 | + if ((strlen($user_data) > 0) && (strlen($user_data) <= 4096)) { |
|
| 48 | + require_once("../inc/account_ownership.inc"); |
|
| 49 | + // Check that the private key file exists where specified. If not, redirect to error page. |
|
| 50 | + if (!file_exists($account_ownership_private_key_file_path)) { |
|
| 51 | + error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + // Check that the public key file exists where specified. If not, redirect to error page. |
|
| 55 | + if (!file_exists($account_ownership_public_key_file_path)) { |
|
| 56 | + error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + $privkey = fopen($account_ownership_private_key_file_path, "r"); // Opening private key file |
|
| 60 | + if (!isset($privkey) || empty($privkey)) { |
|
| 61 | 61 | error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
| 62 | - } |
|
| 63 | - $privkey_contents = fread($privkey, 8192); // Reading contents of private key into var |
|
| 64 | - fclose($privkey); // Closing private key file |
|
| 62 | + } |
|
| 63 | + $privkey_contents = fread($privkey, 8192); // Reading contents of private key into var |
|
| 64 | + fclose($privkey); // Closing private key file |
|
| 65 | 65 | |
| 66 | - $userid = $user->id; // Retrieving the user's UserId |
|
| 67 | - $message_data = "$userid $user_data"; // Create the message which will be signed. |
|
| 66 | + $userid = $user->id; // Retrieving the user's UserId |
|
| 67 | + $message_data = "$userid $user_data"; // Create the message which will be signed. |
|
| 68 | 68 | |
| 69 | - $private_key_pem = openssl_pkey_get_private($privkey_contents); // Loading the private key into memory |
|
| 70 | - openssl_sign($message_data, $signature, $private_key_pem, OPENSSL_ALGO_SHA512); // Compute signature using SHA512 |
|
| 71 | - openssl_free_key($private_key_pem); // Free the private key from memory for additional security |
|
| 69 | + $private_key_pem = openssl_pkey_get_private($privkey_contents); // Loading the private key into memory |
|
| 70 | + openssl_sign($message_data, $signature, $private_key_pem, OPENSSL_ALGO_SHA512); // Compute signature using SHA512 |
|
| 71 | + openssl_free_key($private_key_pem); // Free the private key from memory for additional security |
|
| 72 | 72 | |
| 73 | - $pubkey = fopen($account_ownership_public_key_file_path, "r"); // Open public key file |
|
| 74 | - if ((!isset($pubkey)) || empty($pubkey)) { |
|
| 73 | + $pubkey = fopen($account_ownership_public_key_file_path, "r"); // Open public key file |
|
| 74 | + if ((!isset($pubkey)) || empty($pubkey)) { |
|
| 75 | 75 | error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
| 76 | - } |
|
| 77 | - $pubkey_contents = fread($pubkey, 8192); // Read contents to var |
|
| 78 | - fclose($pubkey); // Close pub key file |
|
| 79 | - |
|
| 80 | - $base64_sig = base64_encode($signature); // Base64 encode the generated signature to enable safe output to text file. |
|
| 81 | - $decoded_sig = base64_decode($base64_sig); // Decode base64 sig for use in sig_verification |
|
| 82 | - $pubkeyid = openssl_pkey_get_public($pubkey_contents); // fetch public key into memory |
|
| 83 | - $sig_verification = openssl_verify($message_data, $decoded_sig, $pubkeyid, OPENSSL_ALGO_SHA512); // Verify that the generated signature against the original data, using the public key. |
|
| 84 | - openssl_free_key($pubkeyid); // Free the public key from memory |
|
| 85 | - |
|
| 86 | - // Check if signature was successfully validated |
|
| 87 | - if ($sig_verification == 1) { |
|
| 88 | - $url_tokens = url_tokens($user->authenticator); |
|
| 89 | - // The generated signature has been successfully verified using the public key. |
|
| 90 | - $master_url = master_url(); |
|
| 91 | - echo "<p>Do not share this information with anyone other than the external system which has requested this proof of account ownership.</p>"; |
|
| 92 | - echo "<textarea rows='13' cols='50' id='result_textbox'><account_ownership_verification>\n<master_url>$master_url</master_url>\n<msg>$message_data</msg>\n<signature>$base64_sig</signature>\n</account_ownership_verification></textarea>"; |
|
| 93 | - echo "<br/><br/><button class='btn btn-success' onclick='copy_result_textbox()'>Copy text</button>"; |
|
| 94 | - echo "<a href='account_ownership.php?$url_tokens'><button class='btn btn-default'>Go back</button></a>"; |
|
| 95 | - echo '<script type="text/javascript">'; |
|
| 96 | - echo 'function copy_result_textbox() { |
|
| 76 | + } |
|
| 77 | + $pubkey_contents = fread($pubkey, 8192); // Read contents to var |
|
| 78 | + fclose($pubkey); // Close pub key file |
|
| 79 | + |
|
| 80 | + $base64_sig = base64_encode($signature); // Base64 encode the generated signature to enable safe output to text file. |
|
| 81 | + $decoded_sig = base64_decode($base64_sig); // Decode base64 sig for use in sig_verification |
|
| 82 | + $pubkeyid = openssl_pkey_get_public($pubkey_contents); // fetch public key into memory |
|
| 83 | + $sig_verification = openssl_verify($message_data, $decoded_sig, $pubkeyid, OPENSSL_ALGO_SHA512); // Verify that the generated signature against the original data, using the public key. |
|
| 84 | + openssl_free_key($pubkeyid); // Free the public key from memory |
|
| 85 | + |
|
| 86 | + // Check if signature was successfully validated |
|
| 87 | + if ($sig_verification == 1) { |
|
| 88 | + $url_tokens = url_tokens($user->authenticator); |
|
| 89 | + // The generated signature has been successfully verified using the public key. |
|
| 90 | + $master_url = master_url(); |
|
| 91 | + echo "<p>Do not share this information with anyone other than the external system which has requested this proof of account ownership.</p>"; |
|
| 92 | + echo "<textarea rows='13' cols='50' id='result_textbox'><account_ownership_verification>\n<master_url>$master_url</master_url>\n<msg>$message_data</msg>\n<signature>$base64_sig</signature>\n</account_ownership_verification></textarea>"; |
|
| 93 | + echo "<br/><br/><button class='btn btn-success' onclick='copy_result_textbox()'>Copy text</button>"; |
|
| 94 | + echo "<a href='account_ownership.php?$url_tokens'><button class='btn btn-default'>Go back</button></a>"; |
|
| 95 | + echo '<script type="text/javascript">'; |
|
| 96 | + echo 'function copy_result_textbox() { |
|
| 97 | 97 | var target_textbox = document.getElementById("result_textbox"); |
| 98 | 98 | target_textbox.select(); |
| 99 | 99 | document.execCommand("copy"); |
| 100 | 100 | alert("Copied to clipboard"); |
| 101 | 101 | }'; |
| 102 | - echo '</script>'; |
|
| 103 | - page_tail(); |
|
| 104 | - |
|
| 105 | - } elseif ($sig_verification == 0) { |
|
| 106 | - // The generated signature has not been verified. The private/public keys do not match. |
|
| 107 | - error_page(tra("Signature verification failed. Contact the project administrator to resolve the issue.")); |
|
| 108 | - } else { |
|
| 109 | - // Something has gone wrong & an error has occurred. |
|
| 110 | - error_page(tra("An error occurred during the signature verification. Contact the project administrator to resolve the issue.")); |
|
| 111 | - } |
|
| 112 | - } else { |
|
| 113 | - // User data input invalid |
|
| 114 | - error_page(tra("Invalid input. User input must have a length > 0 and < 4096. <form><input type='button' value='Go back!'' onclick='history.back()'></form>")); |
|
| 115 | - } |
|
| 102 | + echo '</script>'; |
|
| 103 | + page_tail(); |
|
| 104 | + |
|
| 105 | + } elseif ($sig_verification == 0) { |
|
| 106 | + // The generated signature has not been verified. The private/public keys do not match. |
|
| 107 | + error_page(tra("Signature verification failed. Contact the project administrator to resolve the issue.")); |
|
| 108 | + } else { |
|
| 109 | + // Something has gone wrong & an error has occurred. |
|
| 110 | + error_page(tra("An error occurred during the signature verification. Contact the project administrator to resolve the issue.")); |
|
| 111 | + } |
|
| 112 | + } else { |
|
| 113 | + // User data input invalid |
|
| 114 | + error_page(tra("Invalid input. User input must have a length > 0 and < 4096. <form><input type='button' value='Go back!'' onclick='history.back()'></form>")); |
|
| 115 | + } |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | function account_ownership_form($user) { |
| 119 | - // GET request - the user has navigated to the page. |
|
| 120 | - page_head(tra("Generate proof of account ownership"), null, null, null, boinc_recaptcha_get_head_extra()); |
|
| 121 | - |
|
| 122 | - if ($user) { // Verify the user is logged in |
|
| 123 | - require_once("../inc/account_ownership.inc"); |
|
| 124 | - |
|
| 125 | - if (!file_exists($account_ownership_private_key_file_path)) { |
|
| 126 | - // Check that the private key file exists where specified. If not, redirect to error page. |
|
| 127 | - error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - if (!file_exists($account_ownership_public_key_file_path)) { |
|
| 131 | - // Check that the public key file exists where specified. If not, redirect to error page. |
|
| 132 | - error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - echo "<p>This tool is designed to create a proof of account ownership for external systems.</p>"; |
|
| 136 | - |
|
| 137 | - if (recaptcha_public_key()) { |
|
| 138 | - // Recaptcha configured |
|
| 139 | - echo "<p>Enter a message with length less than 4096 characters into the input textbox below, solve the captcha then click the 'Generate' button.</p>"; |
|
| 140 | - } else { |
|
| 141 | - // Recaptcha not configured |
|
| 142 | - echo "<p>Enter a message with length less than 4096 characters into the input textbox below then click the 'Generate' button.</p>"; |
|
| 143 | - } |
|
| 144 | - echo "<p>A textbox will then appear which contains your proof of account ownership."; |
|
| 145 | - echo "<form method=post action=account_ownership.php>"; |
|
| 146 | - |
|
| 147 | - echo form_tokens($user->authenticator); |
|
| 148 | - echo "<textarea rows='4' cols='50' name=user_data type=text size=20 placeholder='Enter text'></textarea><br/><br/>"; |
|
| 149 | - |
|
| 150 | - if (recaptcha_public_key()) { |
|
| 151 | - // Trigger recaptcha! |
|
| 152 | - form_general("", boinc_recaptcha_get_html(recaptcha_public_key())); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - echo "<input class=\"btn btn-success\" type=submit value='".tra("Generate")."'>"; |
|
| 156 | - echo "</form><br/><hr/>"; |
|
| 157 | - } else { |
|
| 158 | - // The user is not logged in! |
|
| 159 | - echo "<p>You need to be logged in to use this functionality.</p>"; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - page_tail(); |
|
| 119 | + // GET request - the user has navigated to the page. |
|
| 120 | + page_head(tra("Generate proof of account ownership"), null, null, null, boinc_recaptcha_get_head_extra()); |
|
| 121 | + |
|
| 122 | + if ($user) { // Verify the user is logged in |
|
| 123 | + require_once("../inc/account_ownership.inc"); |
|
| 124 | + |
|
| 125 | + if (!file_exists($account_ownership_private_key_file_path)) { |
|
| 126 | + // Check that the private key file exists where specified. If not, redirect to error page. |
|
| 127 | + error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + if (!file_exists($account_ownership_public_key_file_path)) { |
|
| 131 | + // Check that the public key file exists where specified. If not, redirect to error page. |
|
| 132 | + error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue.")); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + echo "<p>This tool is designed to create a proof of account ownership for external systems.</p>"; |
|
| 136 | + |
|
| 137 | + if (recaptcha_public_key()) { |
|
| 138 | + // Recaptcha configured |
|
| 139 | + echo "<p>Enter a message with length less than 4096 characters into the input textbox below, solve the captcha then click the 'Generate' button.</p>"; |
|
| 140 | + } else { |
|
| 141 | + // Recaptcha not configured |
|
| 142 | + echo "<p>Enter a message with length less than 4096 characters into the input textbox below then click the 'Generate' button.</p>"; |
|
| 143 | + } |
|
| 144 | + echo "<p>A textbox will then appear which contains your proof of account ownership."; |
|
| 145 | + echo "<form method=post action=account_ownership.php>"; |
|
| 146 | + |
|
| 147 | + echo form_tokens($user->authenticator); |
|
| 148 | + echo "<textarea rows='4' cols='50' name=user_data type=text size=20 placeholder='Enter text'></textarea><br/><br/>"; |
|
| 149 | + |
|
| 150 | + if (recaptcha_public_key()) { |
|
| 151 | + // Trigger recaptcha! |
|
| 152 | + form_general("", boinc_recaptcha_get_html(recaptcha_public_key())); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + echo "<input class=\"btn btn-success\" type=submit value='".tra("Generate")."'>"; |
|
| 156 | + echo "</form><br/><hr/>"; |
|
| 157 | + } else { |
|
| 158 | + // The user is not logged in! |
|
| 159 | + echo "<p>You need to be logged in to use this functionality.</p>"; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + page_tail(); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $link = secure_url_base() . "forum_thread.php?id=" . $thread->id; |
| 132 | 132 | $body = "A " . PROJECT . " user has posted to the thread |
| 133 | 133 | \"" . $thread->title . "\".\n" |
| 134 | - ."To view the updated thread, visit:\n$link |
|
| 134 | + ."To view the updated thread, visit:\n$link |
|
| 135 | 135 | |
| 136 | 136 | -------------------------- |
| 137 | 137 | To change email preferences, visit: |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $link = secure_url_base() . "forum_forum.php?id=" . $forum->id; |
| 150 | 150 | $body = "A " . PROJECT . " user has added a thread to the forum |
| 151 | 151 | \"" . $thread->title . "\".\n" |
| 152 | - ."To view the updated forum, visit:\n$link |
|
| 152 | + ."To view the updated forum, visit:\n$link |
|
| 153 | 153 | |
| 154 | 154 | -------------------------- |
| 155 | 155 | To change email preferences, visit: |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | //////////////////// a user clicks the red "x" to report a post /////////// |
| 163 | 163 | // |
| 164 | 164 | function send_report_post_email($user, $forum, $thread, $post, $message) { |
| 165 | - $master_url = master_url(); |
|
| 165 | + $master_url = master_url(); |
|
| 166 | 166 | |
| 167 | 167 | $body = ""; |
| 168 | 168 | $owner = BoincUser::lookup_id($post->user); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | //////////////////// a banishment vote has been started /////////// |
| 219 | 219 | // |
| 220 | 220 | function send_banish_vote_email($user, $duration, $reason, $end_time) { |
| 221 | - $master_url = master_url(); |
|
| 221 | + $master_url = master_url(); |
|
| 222 | 222 | $now=time(); |
| 223 | 223 | $subject = PROJECT." banishment vote underway"; |
| 224 | 224 | $vote_url = $master_url."forum_banishment_vote.php"; |
@@ -240,11 +240,11 @@ discard block |
||
| 240 | 240 | pm_send_msg($user, $user, $subject, $body, false); |
| 241 | 241 | |
| 242 | 242 | $body .= "\n\n<a href=".$vote_url."?action=yes&userid=" |
| 243 | - .$user->id |
|
| 244 | - .">[vote to banish author]</a>\n\n" |
|
| 245 | - ."<a href=".$vote_url."?action=no&userid=" |
|
| 246 | - .$user->id |
|
| 247 | - .">[vote not to banish author]</a>"; |
|
| 243 | + .$user->id |
|
| 244 | + .">[vote to banish author]</a>\n\n" |
|
| 245 | + ."<a href=".$vote_url."?action=no&userid=" |
|
| 246 | + .$user->id |
|
| 247 | + .">[vote not to banish author]</a>"; |
|
| 248 | 248 | |
| 249 | 249 | $forum = new BoincForum; |
| 250 | 250 | $forum->parent_type = 0; |
@@ -168,7 +168,7 @@ |
||
| 168 | 168 | $user->prefs = $prefs; |
| 169 | 169 | } |
| 170 | 170 | function privilege($specialbit) { |
| 171 | - return (substr($this->special_user, $specialbit, 1) == '1'); |
|
| 171 | + return (substr($this->special_user, $specialbit, 1) == '1'); |
|
| 172 | 172 | } |
| 173 | 173 | function update($clause) { |
| 174 | 174 | $db = BoincDb::get(); |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | // along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | |
| 19 | 19 | // show statistics by client "brand" |
| 20 | - DEPRECATED |
|
| 20 | + DEPRECATED |
|
| 21 | 21 | |
| 22 | 22 | require_once("../inc/util.inc"); |
| 23 | 23 | |