@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | // If $selection is provided, and if it matches one of the entries in the file, |
| 33 | 33 | // it will be selected by default. |
| 34 | 34 | // |
| 35 | -function show_combo_box($name, $filename, $selection=null) { |
|
| 35 | +function show_combo_box($name, $filename, $selection = null) { |
|
| 36 | 36 | echo "<select name=\"$name\" class=\"form-control\">\n"; |
| 37 | 37 | |
| 38 | 38 | $file = fopen($filename, "r"); |
@@ -63,14 +63,14 @@ discard block |
||
| 63 | 63 | <tr><td colspan=2> |
| 64 | 64 | <table border=0 cellpadding=5 |
| 65 | 65 | <tr> |
| 66 | -<td valign=top><a href=\"" . IMAGE_URL . $profile->userid . '.jpg' . "\"><img src=\"" . IMAGE_URL . $profile->userid . '_sm.jpg' . "\"></a> |
|
| 66 | +<td valign=top><a href=\"" . IMAGE_URL.$profile->userid.'.jpg'."\"><img src=\"".IMAGE_URL.$profile->userid.'_sm.jpg'."\"></a> |
|
| 67 | 67 | </td> |
| 68 | -<td valign=top>" .tra("%1 Your profile picture is shown to the left.", $warning) ." |
|
| 68 | +<td valign=top>" .tra("%1 Your profile picture is shown to the left.", $warning)." |
|
| 69 | 69 | <p>". |
| 70 | -tra("To replace it, click the \"Browse\" button and select a JPEG or PNG file (%1 or less).", "50KB") ."<br /> |
|
| 70 | +tra("To replace it, click the \"Browse\" button and select a JPEG or PNG file (%1 or less).", "50KB")."<br /> |
|
| 71 | 71 | <input name=picture type=file><br> |
| 72 | 72 | <p>". |
| 73 | -tra("To remove it from your profile, check this box:") . " |
|
| 73 | +tra("To remove it from your profile, check this box:")." |
|
| 74 | 74 | <input type=checkbox name=delete_pic> |
| 75 | 75 | <p> |
| 76 | 76 | </td></tr>"; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | end_table(); |
| 79 | 79 | echo "</td></tr>"; |
| 80 | 80 | } else { |
| 81 | - rowify(tra("If you would like include a picture with your profile, click the \"Browse\" button and select a JPEG or PNG file. Please select images of %1 or less.", "50KB") . " |
|
| 81 | + rowify(tra("If you would like include a picture with your profile, click the \"Browse\" button and select a JPEG or PNG file. Please select images of %1 or less.", "50KB")." |
|
| 82 | 82 | <p> |
| 83 | 83 | <input name=picture type=file> |
| 84 | 84 | "); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | row1(tra("Language")); |
| 94 | 94 | echo "<tr><td> |
| 95 | 95 | <p>" . |
| 96 | - tra("Select the language in which your profile is written:") . " |
|
| 96 | + tra("Select the language in which your profile is written:")." |
|
| 97 | 97 | <p> |
| 98 | 98 | "; |
| 99 | 99 | if (isset($profile->language)) { |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | if (recaptcha_public_key()) { |
| 110 | 110 | table_row(boinc_recaptcha_get_html(recaptcha_public_key())); |
| 111 | 111 | } |
| 112 | - table_row("<p><input class=\"btn btn-success\" type=\"submit\" value=\"".tra("Create/edit profile") ."\" name=\"submit\">"); |
|
| 112 | + table_row("<p><input class=\"btn btn-success\" type=\"submit\" value=\"".tra("Create/edit profile")."\" name=\"submit\">"); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // Returns an array containing: |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | // Determine if the filetype uploaded is supported. |
| 125 | 125 | // TODO: Change these to constants. |
| 126 | - switch($size[2]) { |
|
| 126 | + switch ($size[2]) { |
|
| 127 | 127 | case '2': // JPEG |
| 128 | 128 | $image = imageCreateFromJPEG($fileName); |
| 129 | 129 | break; |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | function show_description() { |
| 162 | 162 | echo " |
| 163 | - <p>" .tra("Your %1 profile %2 lets you share your opinions and background with the %3 community.", "<b>", "</b>", PROJECT) . " |
|
| 163 | + <p>" .tra("Your %1 profile %2 lets you share your opinions and background with the %3 community.", "<b>", "</b>", PROJECT)." |
|
| 164 | 164 | <p> |
| 165 | 165 | "; |
| 166 | 166 | } |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | row1(show_profile_heading1()); |
| 179 | 179 | rowify(show_profile_question1().bbcode_info()); |
| 180 | 180 | show_textarea("response1", $response1); |
| 181 | - row1( show_profile_heading2()); |
|
| 182 | - rowify( show_profile_question2().bbcode_info()); |
|
| 181 | + row1(show_profile_heading2()); |
|
| 182 | + rowify(show_profile_question2().bbcode_info()); |
|
| 183 | 183 | show_textarea("response2", $response2); |
| 184 | 184 | show_language_selection($profile); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | function show_textarea($name, $text) { |
| 188 | - rowify("<textarea name=\"$name\" class=\"form-control\" rows=\"10\">" . $text . "</textarea>"); |
|
| 188 | + rowify("<textarea name=\"$name\" class=\"form-control\" rows=\"10\">".$text."</textarea>"); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | // $profile is null if user doesn't already have a profile. |
@@ -229,8 +229,8 @@ discard block |
||
| 229 | 229 | $delete_pic = "off"; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - if (strlen($response1)==0 && |
|
| 233 | - strlen($response2)==0 && |
|
| 232 | + if (strlen($response1) == 0 && |
|
| 233 | + strlen($response2) == 0 && |
|
| 234 | 234 | $delete_pic != "on" && |
| 235 | 235 | !is_uploaded_file($_FILES['picture']['tmp_name']) |
| 236 | 236 | ) { |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $profile->verification = 0; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - $profile ? $has_picture = $profile->has_picture: $has_picture = false; |
|
| 247 | + $profile ? $has_picture = $profile->has_picture : $has_picture = false; |
|
| 248 | 248 | |
| 249 | 249 | if (is_uploaded_file($_FILES['picture']['tmp_name'])) { |
| 250 | 250 | $has_picture = true; |
@@ -259,13 +259,13 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | // Write the original image file to disk. |
| 261 | 261 | // TODO: define a constant for image quality. |
| 262 | - ImageJPEG($images[0], IMAGE_PATH . $user->id . '.jpg'); |
|
| 263 | - ImageJPEG($images[1], IMAGE_PATH . $user->id . '_sm.jpg'); |
|
| 262 | + ImageJPEG($images[0], IMAGE_PATH.$user->id.'.jpg'); |
|
| 263 | + ImageJPEG($images[1], IMAGE_PATH.$user->id.'_sm.jpg'); |
|
| 264 | 264 | } |
| 265 | 265 | $response1 = sanitize_html($response1); |
| 266 | 266 | $response2 = sanitize_html($response2); |
| 267 | 267 | |
| 268 | - $has_picture = $has_picture?1:0; |
|
| 268 | + $has_picture = $has_picture ? 1 : 0; |
|
| 269 | 269 | if ($profile) { |
| 270 | 270 | $query = " response1 = '".BoincDb::escape_string($response1)."'," |
| 271 | 271 | ." response2 = '".BoincDb::escape_string($response2)."'," |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | page_tail(); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | -function show_profile_form($profile, $warning=null) { |
|
| 310 | +function show_profile_form($profile, $warning = null) { |
|
| 311 | 311 | if ($profile) { |
| 312 | 312 | page_head(tra("Edit your profile"), null, null, null, boinc_recaptcha_get_head_extra()); |
| 313 | 313 | } else { |
@@ -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') { |
@@ -141,12 +141,12 @@ discard block |
||
| 141 | 141 | // prefix for links; needed for pages not in top dir |
| 142 | 142 | $user, |
| 143 | 143 | // logged-in user, if any |
| 144 | - $fixed=false, |
|
| 144 | + $fixed = false, |
|
| 145 | 145 | // if true, navbar is fixed at top of page. |
| 146 | 146 | // NOTE: if you do this, you must set a global var $fixed_navbar |
| 147 | 147 | // to true at compile time |
| 148 | 148 | // (it needs to be set when page_head() is called). |
| 149 | - $inverse=false |
|
| 149 | + $inverse = false |
|
| 150 | 150 | // white on black? |
| 151 | 151 | ) { |
| 152 | 152 | $master_url = master_url(); |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | // output a panel. |
| 247 | 247 | // $content_func is a function that generates the panel contents |
| 248 | 248 | // |
| 249 | -function panel($title, $content_func, $class="panel-primary", $body_class="") { |
|
| 249 | +function panel($title, $content_func, $class = "panel-primary", $body_class = "") { |
|
| 250 | 250 | echo sprintf('<div class="panel %s"> |
| 251 | 251 | ', $class |
| 252 | 252 | ); |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | // $left_width is the width of left column in 1/12 units. |
| 274 | 274 | // $arg is passed to the functions. |
| 275 | 275 | // |
| 276 | -function grid($top_func, $left_func, $right_func, $left_width=6, $arg=null) { |
|
| 276 | +function grid($top_func, $left_func, $right_func, $left_width = 6, $arg = null) { |
|
| 277 | 277 | echo ' |
| 278 | 278 | <div class="container-fluid"> |
| 279 | 279 | '; |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | </div> |
| 289 | 289 | '; |
| 290 | 290 | } |
| 291 | - $right_width = 12-$left_width; |
|
| 291 | + $right_width = 12 - $left_width; |
|
| 292 | 292 | echo ' |
| 293 | 293 | <div class="row"> |
| 294 | 294 | <div class="col-sm-'.$left_width.'"> |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | // use extra = "name=x" |
| 313 | 313 | // call forum_focus(x, foo) after defining the field |
| 314 | 314 | // |
| 315 | -function form_start($action, $method='get', $extra='') { |
|
| 315 | +function form_start($action, $method = 'get', $extra = '') { |
|
| 316 | 316 | echo sprintf( |
| 317 | 317 | '<div class="container-fluid"> |
| 318 | 318 | <form class="form-horizontal" method="%s" action="%s" %s>' |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | // just the input field |
| 345 | 345 | // |
| 346 | 346 | function form_input_text_field( |
| 347 | - $name, $value='', $type='text', $attrs='', $extra='' |
|
| 347 | + $name, $value = '', $type = 'text', $attrs = '', $extra = '' |
|
| 348 | 348 | ) { |
| 349 | 349 | return sprintf( |
| 350 | 350 | '<input %s type="%s" class="form-control" name="%s" value="%s">%s', |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | // the whole row |
| 356 | 356 | // |
| 357 | 357 | function form_input_text( |
| 358 | - $label, $name, $value='', $type='text', $attrs='', $extra='' |
|
| 358 | + $label, $name, $value = '', $type = 'text', $attrs = '', $extra = '' |
|
| 359 | 359 | ) { |
| 360 | 360 | echo sprintf(' |
| 361 | 361 | <div class="form-group"> |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | ); |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | -function form_input_textarea($label, $name, $value='', $nrows=4) { |
|
| 386 | +function form_input_textarea($label, $name, $value = '', $nrows = 4) { |
|
| 387 | 387 | echo sprintf(' |
| 388 | 388 | <div class="form-group"> |
| 389 | 389 | <label align=right class="%s" for="%s">%s</label> |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | // $items is either a string of <option> elements, |
| 401 | 401 | // or an array of [value, name] pairs |
| 402 | 402 | // |
| 403 | -function form_select($label, $name, $items, $selected=null) { |
|
| 403 | +function form_select($label, $name, $items, $selected = null) { |
|
| 404 | 404 | echo sprintf(' |
| 405 | 405 | <div class="form-group"> |
| 406 | 406 | <label align=right class="%s" for="%s">%s</label> |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | foreach ($items as $i) { |
| 414 | 414 | echo sprintf( |
| 415 | 415 | '<option %s value=%s>%s</option>', |
| 416 | - ($i[0]==$selected)?'selected':'', |
|
| 416 | + ($i[0] == $selected) ? 'selected' : '', |
|
| 417 | 417 | $i[0], $i[1] |
| 418 | 418 | ); |
| 419 | 419 | } |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | // same, for multiple select. |
| 427 | 427 | // $selected, if non-null, is a list of selected values |
| 428 | 428 | // |
| 429 | -function form_select_multiple($label, $name, $items, $selected=null, $size=0) { |
|
| 429 | +function form_select_multiple($label, $name, $items, $selected = null, $size = 0) { |
|
| 430 | 430 | echo sprintf(' |
| 431 | 431 | <div class="form-group"> |
| 432 | 432 | <label align=right class="%s" for="%s">%s</label> |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | foreach ($items as $i) { |
| 439 | 439 | echo sprintf( |
| 440 | 440 | '<option %s value=%s>%s</option>', |
| 441 | - ($selected && in_array($i[0], $selected))?'selected':'', |
|
| 441 | + ($selected && in_array($i[0], $selected)) ? 'selected' : '', |
|
| 442 | 442 | $i[0], $i[1] |
| 443 | 443 | ); |
| 444 | 444 | } |
@@ -447,12 +447,12 @@ discard block |
||
| 447 | 447 | |
| 448 | 448 | // return a list of strings for checkbox items |
| 449 | 449 | // |
| 450 | -function checkbox_item_strings($items, $attrs='') { |
|
| 450 | +function checkbox_item_strings($items, $attrs = '') { |
|
| 451 | 451 | $x = []; |
| 452 | 452 | foreach ($items as $i) { |
| 453 | 453 | $x[] = sprintf('<input %s type="checkbox" name="%s" %s> %s |
| 454 | 454 | ', |
| 455 | - $attrs, $i[0], $i[2]?"checked":"", $i[1] |
|
| 455 | + $attrs, $i[0], $i[2] ? "checked" : "", $i[1] |
|
| 456 | 456 | ); |
| 457 | 457 | } |
| 458 | 458 | return $x; |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | |
| 461 | 461 | // $items is list of (name, label, checked) |
| 462 | 462 | // |
| 463 | -function form_checkboxes($label, $items, $attrs='') { |
|
| 463 | +function form_checkboxes($label, $items, $attrs = '') { |
|
| 464 | 464 | echo sprintf(' |
| 465 | 465 | <div class="form-group"> |
| 466 | 466 | <label align=right class="%s">%s</label> |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | // |
| 480 | 480 | function form_radio_buttons( |
| 481 | 481 | $label, $name, $items, $selected, |
| 482 | - $assign_ids=false // assign IDs to buttons based on names |
|
| 482 | + $assign_ids = false // assign IDs to buttons based on names |
|
| 483 | 483 | ) { |
| 484 | 484 | echo sprintf(' |
| 485 | 485 | <div class="form-group"> |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | FORM_LEFT_CLASS, $label, FORM_RIGHT_CLASS |
| 490 | 490 | ); |
| 491 | 491 | foreach ($items as $i) { |
| 492 | - $checked = ($selected == $i[0])?"checked":""; |
|
| 492 | + $checked = ($selected == $i[0]) ? "checked" : ""; |
|
| 493 | 493 | if ($assign_ids) { |
| 494 | 494 | $id = sprintf('id="%s_%s"', $name, $i[0]); |
| 495 | 495 | } else { |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | '; |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | -function form_submit($text, $attrs='') { |
|
| 530 | +function form_submit($text, $attrs = '') { |
|
| 531 | 531 | form_general( |
| 532 | 532 | "", |
| 533 | 533 | sprintf( |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | ); |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | -function form_checkbox($label, $name, $checked=false) { |
|
| 540 | +function form_checkbox($label, $name, $checked = false) { |
|
| 541 | 541 | echo sprintf(' |
| 542 | 542 | <div class="form-group"> |
| 543 | 543 | <label align=right class="%s">%s</label> |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | <input type="checkbox" name="%s" %s> |
| 550 | 550 | </div> |
| 551 | 551 | </div> |
| 552 | - ', $name, $checked?"checked":"" |
|
| 552 | + ', $name, $checked ? "checked" : "" |
|
| 553 | 553 | ); |
| 554 | 554 | } |
| 555 | 555 | |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | // $selected is the list of selected values. |
| 578 | 578 | // $extra is e.g. id=foo |
| 579 | 579 | // |
| 580 | -function form_select2_multi($label, $name, $items, $selected=null, $extra='') { |
|
| 580 | +function form_select2_multi($label, $name, $items, $selected = null, $extra = '') { |
|
| 581 | 581 | echo sprintf(' |
| 582 | 582 | <div class="form-group"> |
| 583 | 583 | <label align=right class="%s" for="%s">%s</label> |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | foreach ($items as $i) { |
| 590 | 590 | echo sprintf( |
| 591 | 591 | '<option %s value=%s>%s</option>', |
| 592 | - ($selected && in_array($i[0], $selected))?'selected':'', |
|
| 592 | + ($selected && in_array($i[0], $selected)) ? 'selected' : '', |
|
| 593 | 593 | $i[0], $i[1] |
| 594 | 594 | ); |
| 595 | 595 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | require_once("../inc/bootstrap.inc"); |
| 31 | 31 | |
| 32 | 32 | function master_url() { |
| 33 | - return parse_config(get_config() , "<master_url>"); |
|
| 33 | + return parse_config(get_config(), "<master_url>"); |
|
| 34 | 34 | } |
| 35 | 35 | function recaptcha_public_key() { |
| 36 | 36 | return parse_config(get_config(), "<recaptcha_public_key>"); |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | // Set parameters to defaults if not defined in config.xml |
| 43 | 43 | |
| 44 | 44 | $x = parse_config(get_config(), "<user_country>"); |
| 45 | -define('USER_COUNTRY', ($x===null)?1:(int)$x); |
|
| 45 | +define('USER_COUNTRY', ($x === null) ? 1 : (int)$x); |
|
| 46 | 46 | |
| 47 | 47 | $x = parse_config(get_config(), "<user_url>"); |
| 48 | -define('USER_URL', ($x===null)?1:(int)$x); |
|
| 48 | +define('USER_URL', ($x === null) ? 1 : (int)$x); |
|
| 49 | 49 | |
| 50 | 50 | // Set parameters to defaults if not defined in project.inc |
| 51 | 51 | |
@@ -155,10 +155,10 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | function url_base() { |
| 158 | - return is_https()?secure_url_base():URL_BASE; |
|
| 158 | + return is_https() ?secure_url_base() : URL_BASE; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | -function send_cookie($name, $value, $permanent, $ops=false) { |
|
| 161 | +function send_cookie($name, $value, $permanent, $ops = false) { |
|
| 162 | 162 | // the following allows independent login for projects on the same server |
| 163 | 163 | // |
| 164 | 164 | $url = parse_url(master_url()); |
@@ -167,28 +167,28 @@ discard block |
||
| 167 | 167 | $path = substr($path, 0, -1); |
| 168 | 168 | $path .= "_ops/"; |
| 169 | 169 | } |
| 170 | - $expire = $permanent?time()+3600*24*365:0; |
|
| 170 | + $expire = $permanent ?time() + 3600*24*365 : 0; |
|
| 171 | 171 | setcookie($name, $value, $expire, $path, |
| 172 | 172 | '', |
| 173 | - is_https(), // if this page is secure, make cookie secure |
|
| 173 | + is_https(), // if this page is secure, make cookie secure |
|
| 174 | 174 | true // httponly; no JS access |
| 175 | 175 | ); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | -function clear_cookie($name, $ops=false) { |
|
| 178 | +function clear_cookie($name, $ops = false) { |
|
| 179 | 179 | $url = parse_url(master_url()); |
| 180 | 180 | $path = $url['path']; |
| 181 | 181 | if ($ops) { |
| 182 | 182 | $path = substr($path, 0, -1); |
| 183 | 183 | $path .= "_ops/"; |
| 184 | 184 | } |
| 185 | - setcookie($name, '', time()-3600, $path); |
|
| 185 | + setcookie($name, '', time() - 3600, $path); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | $g_logged_in_user = null; |
| 189 | 189 | $got_logged_in_user = false; |
| 190 | 190 | |
| 191 | -function get_logged_in_user($must_be_logged_in=true) { |
|
| 191 | +function get_logged_in_user($must_be_logged_in = true) { |
|
| 192 | 192 | global $g_logged_in_user, $got_logged_in_user; |
| 193 | 193 | if ($got_logged_in_user) { |
| 194 | 194 | // this could have been called earlier with $must_be_logged_in false |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | $next_url = $_SERVER['REQUEST_URI']; |
| 215 | 215 | $n = strrpos($next_url, "/"); |
| 216 | 216 | if ($n) { |
| 217 | - $next_url = substr($next_url, $n+1); |
|
| 217 | + $next_url = substr($next_url, $n + 1); |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | $next_url = urlencode($next_url); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | return $g_logged_in_user; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | -function show_login_info($prefix="") { |
|
| 228 | +function show_login_info($prefix = "") { |
|
| 229 | 229 | $user = get_logged_in_user(false); |
| 230 | 230 | if ($user) { |
| 231 | 231 | $url_tokens = url_tokens($user->authenticator); |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | -$cache_control_extra=""; |
|
| 238 | +$cache_control_extra = ""; |
|
| 239 | 239 | $is_login_page = false; |
| 240 | 240 | |
| 241 | 241 | // Call this to start pages. |
@@ -247,11 +247,11 @@ discard block |
||
| 247 | 247 | // with an existing web framework can more easily do so. |
| 248 | 248 | // To do so, define page_head() in html/project/project.inc |
| 249 | 249 | // |
| 250 | -if (!function_exists("page_head")){ |
|
| 250 | +if (!function_exists("page_head")) { |
|
| 251 | 251 | function page_head( |
| 252 | 252 | $title, |
| 253 | 253 | // page title. Put in <title>, used as title for browser tab. |
| 254 | - $body_attrs=null, |
|
| 254 | + $body_attrs = null, |
|
| 255 | 255 | // <body XXXX> |
| 256 | 256 | // e.g. Javascript to put focus in an input field |
| 257 | 257 | // (onload="document.form.foo.focus()") |
@@ -260,10 +260,10 @@ discard block |
||
| 260 | 260 | // if set, include schedulers.txt. |
| 261 | 261 | // also pass to project_banner() in case you want a different |
| 262 | 262 | // header for your main page. |
| 263 | - $url_prefix="", |
|
| 263 | + $url_prefix = "", |
|
| 264 | 264 | // prepend this to links. |
| 265 | 265 | // Use for web pages not in the top directory |
| 266 | - $head_extra=null |
|
| 266 | + $head_extra = null |
|
| 267 | 267 | // extra stuff to put in <head>. E.g.: |
| 268 | 268 | // reCAPTCHA code (create_profile.php) |
| 269 | 269 | // bbcode javascript (forums) |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | header("Content-type: text/html; charset=utf-8"); |
| 286 | 286 | header("Expires: Mon, 26 Jul 1997 05:00:00 UTC"); |
| 287 | 287 | // Date in the past |
| 288 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " UTC"); |
|
| 288 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." UTC"); |
|
| 289 | 289 | // always modified |
| 290 | 290 | header("Cache-Control: $cache_control_extra no-cache, must-revalidate, post-check=0, pre-check=0"); |
| 291 | 291 | // for HTTP/1.1 |
@@ -308,11 +308,11 @@ discard block |
||
| 308 | 308 | if ($head_extra) { |
| 309 | 309 | echo "\n$head_extra\n"; |
| 310 | 310 | } |
| 311 | - if ($is_main && (!defined('NO_COMPUTING')||!NO_COMPUTING)) { |
|
| 311 | + if ($is_main && (!defined('NO_COMPUTING') || !NO_COMPUTING)) { |
|
| 312 | 312 | readfile("schedulers.txt"); |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $t = $title?$title:PROJECT; |
|
| 315 | + $t = $title ? $title : PROJECT; |
|
| 316 | 316 | echo "<title>$t</title>\n"; |
| 317 | 317 | echo ' |
| 318 | 318 | <meta charset="utf-8"> |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | echo '<div class="container-fluid"> |
| 369 | 369 | '; |
| 370 | 370 | |
| 371 | - switch($title) { //kludge |
|
| 371 | + switch ($title) { //kludge |
|
| 372 | 372 | case tra("Log in"): |
| 373 | 373 | case tra("Create an account"): |
| 374 | 374 | case tra("Server status page"): |
@@ -383,13 +383,13 @@ discard block |
||
| 383 | 383 | |
| 384 | 384 | // See the comments for page_head() |
| 385 | 385 | // |
| 386 | -if (!function_exists("page_tail")){ |
|
| 386 | +if (!function_exists("page_tail")) { |
|
| 387 | 387 | function page_tail( |
| 388 | - $show_date=false, |
|
| 388 | + $show_date = false, |
|
| 389 | 389 | // true for pages that are generated periodically rather than on the fly |
| 390 | - $url_prefix="", |
|
| 390 | + $url_prefix = "", |
|
| 391 | 391 | // use for pages not at top level |
| 392 | - $is_main=false |
|
| 392 | + $is_main = false |
|
| 393 | 393 | // passed to project_footer; |
| 394 | 394 | ) { |
| 395 | 395 | echo "<br>\n"; |
@@ -423,24 +423,24 @@ discard block |
||
| 423 | 423 | // convert time interval in seconds to a string of the form |
| 424 | 424 | // 'D days h hours m min s sec'. |
| 425 | 425 | |
| 426 | -function time_diff($x, $res=3) { |
|
| 426 | +function time_diff($x, $res = 3) { |
|
| 427 | 427 | $x = (int)$x; |
| 428 | 428 | $days = (int)($x/86400); |
| 429 | - $hours = (int)(($x-$days*86400)/3600); |
|
| 430 | - $minutes = (int)(($x-$days*86400-$hours*3600)/60); |
|
| 431 | - $seconds = $x % 60; |
|
| 429 | + $hours = (int)(($x - $days*86400)/3600); |
|
| 430 | + $minutes = (int)(($x - $days*86400 - $hours*3600)/60); |
|
| 431 | + $seconds = $x%60; |
|
| 432 | 432 | |
| 433 | 433 | $s = ""; |
| 434 | 434 | if ($days) { |
| 435 | 435 | $s .= "$days ".tra("days")." "; |
| 436 | 436 | } |
| 437 | - if ($res>0 && ($hours || strlen($s))) { |
|
| 437 | + if ($res > 0 && ($hours || strlen($s))) { |
|
| 438 | 438 | $s .= "$hours ".tra("hours")." "; |
| 439 | 439 | } |
| 440 | - if ($res>1 && ($minutes || strlen($s))) { |
|
| 440 | + if ($res > 1 && ($minutes || strlen($s))) { |
|
| 441 | 441 | $s .= "$minutes ".tra("min")." "; |
| 442 | 442 | } |
| 443 | - if ($res>2) { |
|
| 443 | + if ($res > 2) { |
|
| 444 | 444 | $s .= "$seconds ".tra("sec")." "; |
| 445 | 445 | } |
| 446 | 446 | return $s; |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | function time_str($x) { |
| 456 | 456 | if ($x == 0) return "---"; |
| 457 | - return gmdate('j M Y, G:i:s', (int)$x) . " UTC"; |
|
| 457 | + return gmdate('j M Y, G:i:s', (int)$x)." UTC"; |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | function local_time_str($x) { |
@@ -466,14 +466,14 @@ discard block |
||
| 466 | 466 | return time_str($x); |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | -function start_table_str($class="", $style="") { |
|
| 470 | - $s = $style?'style="'.$style.'"':''; |
|
| 469 | +function start_table_str($class = "", $style = "") { |
|
| 470 | + $s = $style ? 'style="'.$style.'"' : ''; |
|
| 471 | 471 | return '<div class="table"> |
| 472 | 472 | <table '.$s.' width="100%" class="table table-condensed '.$class.'" > |
| 473 | 473 | '; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | -function start_table($class="", $style="") { |
|
| 476 | +function start_table($class = "", $style = "") { |
|
| 477 | 477 | echo start_table_str($class, $style); |
| 478 | 478 | } |
| 479 | 479 | |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | echo "</tr>\n"; |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | -function row1($x, $ncols=2, $class="heading") { |
|
| 521 | +function row1($x, $ncols = 2, $class = "heading") { |
|
| 522 | 522 | if ($class == "heading") { |
| 523 | 523 | echo "<tr><th class=\"bg-primary\" colspan=\"$ncols\">$x</th></tr>\n"; |
| 524 | 524 | } else { |
@@ -532,10 +532,10 @@ discard block |
||
| 532 | 532 | |
| 533 | 533 | // a table row with 2 columns, with the left on right-aligned |
| 534 | 534 | |
| 535 | -function row2($x, $y, $show_error=false, $lwidth='40%') { |
|
| 536 | - if ($x==="") $x="<br>"; |
|
| 537 | - if ($y==="") $y="<br>"; |
|
| 538 | - $attrs = $show_error?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
| 535 | +function row2($x, $y, $show_error = false, $lwidth = '40%') { |
|
| 536 | + if ($x === "") $x = "<br>"; |
|
| 537 | + if ($y === "") $y = "<br>"; |
|
| 538 | + $attrs = $show_error ?VALUE_ATTRS_ERR:VALUE_ATTRS; |
|
| 539 | 539 | echo "<tr> |
| 540 | 540 | <td width=\"$lwidth\" ".NAME_ATTRS.">$x</td> |
| 541 | 541 | <td $attrs >$y</td> |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | // output the first part of row2(); |
| 547 | 547 | // then write the content, followed by </td></tr> |
| 548 | 548 | |
| 549 | -function row2_init($x, $lwidth='40%') { |
|
| 549 | +function row2_init($x, $lwidth = '40%') { |
|
| 550 | 550 | echo sprintf('<tr> |
| 551 | 551 | <td width="%s" %s>%s</td> |
| 552 | 552 | <td %s>', |
@@ -562,31 +562,31 @@ discard block |
||
| 562 | 562 | echo "<tr><td>$string</td></tr>"; |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | -function row_array($x, $attrs=null) { |
|
| 565 | +function row_array($x, $attrs = null) { |
|
| 566 | 566 | echo "<tr>\n"; |
| 567 | 567 | $i = 0; |
| 568 | 568 | foreach ($x as $h) { |
| 569 | - $a = $attrs?$attrs[$i]:""; |
|
| 569 | + $a = $attrs ? $attrs[$i] : ""; |
|
| 570 | 570 | echo "<td $a>$h</td>\n"; |
| 571 | 571 | $i++; |
| 572 | 572 | } |
| 573 | 573 | echo "</tr>\n"; |
| 574 | 574 | } |
| 575 | 575 | |
| 576 | -define ('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
| 576 | +define('ALIGN_RIGHT', 'style="text-align:right;"'); |
|
| 577 | 577 | |
| 578 | -function row_heading_array($x, $attrs=null, $class='bg-primary') { |
|
| 578 | +function row_heading_array($x, $attrs = null, $class = 'bg-primary') { |
|
| 579 | 579 | echo "<tr>"; |
| 580 | 580 | $i = 0; |
| 581 | 581 | foreach ($x as $h) { |
| 582 | - $a = $attrs?$attrs[$i]:""; |
|
| 582 | + $a = $attrs ? $attrs[$i] : ""; |
|
| 583 | 583 | echo "<th $a class=\"$class\">$h</th>"; |
| 584 | 584 | $i++; |
| 585 | 585 | } |
| 586 | 586 | echo "</tr>\n"; |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | -function row_heading($x, $class='bg-primary') { |
|
| 589 | +function row_heading($x, $class = 'bg-primary') { |
|
| 590 | 590 | echo sprintf('<tr><th class="%s" colspan=99>%s</th></tr> |
| 591 | 591 | ', $class, $x |
| 592 | 592 | ); |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | // If $ellipsis is true, then an ellipsis is added to any sentence which |
| 647 | 647 | // is cut short. |
| 648 | 648 | |
| 649 | -function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { |
|
| 649 | +function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis = false) { |
|
| 650 | 650 | $words = explode($delimiter, $sentence); |
| 651 | 651 | $total_chars = 0; |
| 652 | 652 | $trunc = false; |
@@ -729,8 +729,8 @@ discard block |
||
| 729 | 729 | |
| 730 | 730 | // returns null if the arg is optional and missing |
| 731 | 731 | // |
| 732 | -function get_int($name, $optional=false) { |
|
| 733 | - $x=null; |
|
| 732 | +function get_int($name, $optional = false) { |
|
| 733 | + $x = null; |
|
| 734 | 734 | if (isset($_GET[$name])) $x = $_GET[$name]; |
| 735 | 735 | if (!is_numeric($x)) { |
| 736 | 736 | if ($optional) { |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | |
| 750 | 750 | // returns null if the arg is optional and missing |
| 751 | 751 | // |
| 752 | -function post_num($name, $optional=false) { |
|
| 752 | +function post_num($name, $optional = false) { |
|
| 753 | 753 | $x = null; |
| 754 | 754 | if (isset($_POST[$name])) $x = $_POST[$name]; |
| 755 | 755 | if (!is_numeric($x)) { |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | |
| 765 | 765 | // returns null if the arg is optional and missing |
| 766 | 766 | // |
| 767 | -function post_int($name, $optional=false) { |
|
| 767 | +function post_int($name, $optional = false) { |
|
| 768 | 768 | $x = post_num($name, $optional); |
| 769 | 769 | if (is_null($x)) return null; |
| 770 | 770 | $y = (int)$x; |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | -function get_str($name, $optional=false) { |
|
| 785 | +function get_str($name, $optional = false) { |
|
| 786 | 786 | if (isset($_GET[$name])) { |
| 787 | 787 | $x = $_GET[$name]; |
| 788 | 788 | } else { |
@@ -794,7 +794,7 @@ discard block |
||
| 794 | 794 | return undo_magic_quotes($x); |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | -function post_str($name, $optional=false) { |
|
| 797 | +function post_str($name, $optional = false) { |
|
| 798 | 798 | if (isset($_POST[$name])) { |
| 799 | 799 | $x = $_POST[$name]; |
| 800 | 800 | } else { |
@@ -806,7 +806,7 @@ discard block |
||
| 806 | 806 | return undo_magic_quotes($x); |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | -function post_arr($name, $optional=false) { |
|
| 809 | +function post_arr($name, $optional = false) { |
|
| 810 | 810 | if (isset($_POST[$name]) && is_array($_POST[$name])) { |
| 811 | 811 | $x = $_POST[$name]; |
| 812 | 812 | } else { |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | // the mb_* functions are not included by default |
| 823 | 823 | // return (mb_detect_encoding($passwd) -= 'ASCII'); |
| 824 | 824 | |
| 825 | - for ($i=0; $i<strlen($str); $i++) { |
|
| 825 | + for ($i = 0; $i < strlen($str); $i++) { |
|
| 826 | 826 | $c = ord(substr($str, $i)); |
| 827 | 827 | if ($c < 32 || $c > 127) return false; |
| 828 | 828 | } |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | $number = str_replace(',', '.', $number); // replace the german decimal separator |
| 847 | 847 | // if no value was entered and this is ok |
| 848 | 848 | // |
| 849 | - if ($number=='' && !$low) return true; |
|
| 849 | + if ($number == '' && !$low) return true; |
|
| 850 | 850 | |
| 851 | 851 | // the supplied value contains alphabetic characters |
| 852 | 852 | // |
@@ -863,7 +863,7 @@ discard block |
||
| 863 | 863 | |
| 864 | 864 | // Generate a "select" element from an array of values |
| 865 | 865 | // |
| 866 | -function select_from_array($name, $array, $selection=null, $width=240) { |
|
| 866 | +function select_from_array($name, $array, $selection = null, $width = 240) { |
|
| 867 | 867 | $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"'; |
| 868 | 868 | |
| 869 | 869 | foreach ($array as $key => $value) { |
@@ -888,12 +888,12 @@ discard block |
||
| 888 | 888 | return $str; |
| 889 | 889 | } |
| 890 | 890 | |
| 891 | -function strip_bbcode($string){ |
|
| 892 | - return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/","",$string); |
|
| 891 | +function strip_bbcode($string) { |
|
| 892 | + return preg_replace("/((\[.+\])+?)(.+?)((\[\/.+\])+?)/", "", $string); |
|
| 893 | 893 | } |
| 894 | 894 | |
| 895 | 895 | function current_url() { |
| 896 | - $url = is_https()?'https':'http'; |
|
| 896 | + $url = is_https() ? 'https' : 'http'; |
|
| 897 | 897 | $url .= "://"; |
| 898 | 898 | $url .= $_SERVER['SERVER_NAME']; |
| 899 | 899 | $url .= ":".$_SERVER['SERVER_PORT']; |
@@ -911,7 +911,7 @@ discard block |
||
| 911 | 911 | // the colors for bootstrap's btn-success are almost illegible; |
| 912 | 912 | // the green is too light. Use a darker green. |
| 913 | 913 | // |
| 914 | -function button_style($color='green', $font_size=null) { |
|
| 914 | +function button_style($color = 'green', $font_size = null) { |
|
| 915 | 915 | $fs = ''; |
| 916 | 916 | if ($font_size) { |
| 917 | 917 | $fs = sprintf('; font-size:%dpx', $font_size); |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | // class: class of the button, e.g. btn |
| 931 | 931 | // extra: Additional text in href tag |
| 932 | 932 | // |
| 933 | -function button_text($url, $text, $desc=null, $class=null, $extra='') { |
|
| 933 | +function button_text($url, $text, $desc = null, $class = null, $extra = '') { |
|
| 934 | 934 | if (!$desc) { |
| 935 | 935 | $desc = $text; |
| 936 | 936 | } |
@@ -945,23 +945,23 @@ discard block |
||
| 945 | 945 | ); |
| 946 | 946 | } |
| 947 | 947 | |
| 948 | -function button_text_small($url, $text, $desc=null) { |
|
| 948 | +function button_text_small($url, $text, $desc = null) { |
|
| 949 | 949 | return button_text($url, $text, $desc, "btn btn-xs", button_style()); |
| 950 | 950 | } |
| 951 | 951 | |
| 952 | -function show_button($url, $text, $desc=null, $class=null, $extra=null) { |
|
| 952 | +function show_button($url, $text, $desc = null, $class = null, $extra = null) { |
|
| 953 | 953 | echo button_text($url, $text, $desc, $class, $extra); |
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 | // for places with a bunch of buttons, like forum posts |
| 957 | 957 | // |
| 958 | -function show_button_small($url, $text, $desc=null) { |
|
| 958 | +function show_button_small($url, $text, $desc = null) { |
|
| 959 | 959 | echo button_text_small($url, $text, $desc); |
| 960 | 960 | } |
| 961 | 961 | |
| 962 | 962 | // used for showing icons |
| 963 | 963 | // |
| 964 | -function show_image($src, $title, $alt, $height=null) { |
|
| 964 | +function show_image($src, $title, $alt, $height = null) { |
|
| 965 | 965 | $h = ""; |
| 966 | 966 | if ($height) { |
| 967 | 967 | $h = "height=\"$height\""; |
@@ -998,7 +998,7 @@ discard block |
||
| 998 | 998 | // tries instead to connect to <replica_db_host> if tag exists. |
| 999 | 999 | // DEPRECATED - use boinc_db.inc |
| 1000 | 1000 | // |
| 1001 | -function db_init($try_replica=false) { |
|
| 1001 | +function db_init($try_replica = false) { |
|
| 1002 | 1002 | check_web_stopped(); |
| 1003 | 1003 | $retval = db_init_aux($try_replica); |
| 1004 | 1004 | if ($retval == 1) { |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | // Check this to avoid XSS vulnerability |
| 1075 | 1075 | // |
| 1076 | 1076 | function sanitize_sort_by($x) { |
| 1077 | - switch($x) { |
|
| 1077 | + switch ($x) { |
|
| 1078 | 1078 | case 'expavg_credit': |
| 1079 | 1079 | case 'total_credit': |
| 1080 | 1080 | return; |
@@ -1092,7 +1092,7 @@ discard block |
||
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | function do_download($path) { |
| 1095 | - $name=basename($path); |
|
| 1095 | + $name = basename($path); |
|
| 1096 | 1096 | header('Content-Description: File Transfer'); |
| 1097 | 1097 | header('Content-Type: application/octet-stream'); |
| 1098 | 1098 | header('Content-Disposition: attachment; filename='.$name); |
@@ -1100,7 +1100,7 @@ discard block |
||
| 1100 | 1100 | header('Expires: 0'); |
| 1101 | 1101 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
| 1102 | 1102 | header('Pragma: public'); |
| 1103 | - header('Content-Length: ' . filesize($path)); |
|
| 1103 | + header('Content-Length: '.filesize($path)); |
|
| 1104 | 1104 | flush(); |
| 1105 | 1105 | readfile($path); |
| 1106 | 1106 | } |
@@ -1149,10 +1149,10 @@ discard block |
||
| 1149 | 1149 | // Otherwise return 0. |
| 1150 | 1150 | // Format of user agent string is "BOINC client (windows_x86_64 7.3.17)" |
| 1151 | 1151 | // |
| 1152 | -function boinc_client_version(){ |
|
| 1152 | +function boinc_client_version() { |
|
| 1153 | 1153 | if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) return 0; |
| 1154 | 1154 | $x = $_SERVER['HTTP_USER_AGENT']; |
| 1155 | - $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
| 1155 | + $e = "/BOINC client [^ ]* (\d+).(\d+).(\d+)\)/"; |
|
| 1156 | 1156 | if (preg_match($e, $x, $matches)) { |
| 1157 | 1157 | return $matches[1]*10000 + $matches[2]*100 + $matches[3]; |
| 1158 | 1158 | } |
@@ -1181,7 +1181,7 @@ discard block |
||
| 1181 | 1181 | $rem_name = $name."_remaining"; |
| 1182 | 1182 | return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\" |
| 1183 | 1183 | onkeyup=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\">".$text."</textarea> |
| 1184 | - <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen-strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
| 1184 | + <br><input name=\"$rem_name\" type=\"text\" id=\"$rem_name\" value=\"".($maxlen - strlen($text))."\" size=\"3\" maxlength=\"3\" readonly> ".tra("characters remaining") |
|
| 1185 | 1185 | ; |
| 1186 | 1186 | } |
| 1187 | 1187 | |
@@ -1211,7 +1211,7 @@ discard block |
||
| 1211 | 1211 | // use the following around text with long lines, |
| 1212 | 1212 | // to limit the width and make it more readable. |
| 1213 | 1213 | // |
| 1214 | -function text_start($width=640) { |
|
| 1214 | +function text_start($width = 640) { |
|
| 1215 | 1215 | echo sprintf("<div style=\"max-width: %dpx;\">\n", $width); |
| 1216 | 1216 | } |
| 1217 | 1217 | function text_end() { |
@@ -1237,7 +1237,7 @@ discard block |
||
| 1237 | 1237 | } |
| 1238 | 1238 | |
| 1239 | 1239 | function cert_filename() { |
| 1240 | - return defined("CERT_FILENAME")?CERT_FILENAME:"cert1.php"; |
|
| 1240 | + return defined("CERT_FILENAME") ?CERT_FILENAME:"cert1.php"; |
|
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | 1243 | // if user hasn't validated their email addr, tell them to |
@@ -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; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | // - project forums: everyone in POST_REPORT_EMAILS |
| 25 | 25 | // - team message board: team founder and admins |
| 26 | 26 | // |
| 27 | -function mail_report_list($forum, $subject, $body, $must_send=false) { |
|
| 27 | +function mail_report_list($forum, $subject, $body, $must_send = false) { |
|
| 28 | 28 | $success = true; |
| 29 | 29 | switch ($forum->parent_type) { |
| 30 | 30 | case 0: |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | function send_moderation_email($forum, $post, $thread, $explanation, $action) { |
| 66 | 66 | $master_url = master_url(); |
| 67 | 67 | |
| 68 | - $moderator=get_logged_in_user(); |
|
| 68 | + $moderator = get_logged_in_user(); |
|
| 69 | 69 | $body = ""; |
| 70 | 70 | $user = BoincUser::lookup_id($post->user); |
| 71 | 71 | |
@@ -126,11 +126,11 @@ discard block |
||
| 126 | 126 | // There's a new post in the thread, which the user is subscribed to. |
| 127 | 127 | // send them an email notifying them. |
| 128 | 128 | // |
| 129 | -function send_thread_notification_email($thread, $user){ |
|
| 130 | - $title = PROJECT . ": there is a new post in '". $thread->title ."'"; |
|
| 131 | - $link = secure_url_base() . "forum_thread.php?id=" . $thread->id; |
|
| 132 | - $body = "A " . PROJECT . " user has posted to the thread |
|
| 133 | -\"" . $thread->title . "\".\n" |
|
| 129 | +function send_thread_notification_email($thread, $user) { |
|
| 130 | + $title = PROJECT.": there is a new post in '".$thread->title."'"; |
|
| 131 | + $link = secure_url_base()."forum_thread.php?id=".$thread->id; |
|
| 132 | + $body = "A ".PROJECT." user has posted to the thread |
|
| 133 | +\"" . $thread->title."\".\n" |
|
| 134 | 134 | ."To view the updated thread, visit:\n$link |
| 135 | 135 | |
| 136 | 136 | -------------------------- |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | // There's a new thread in the forum, which the user is subscribed to. |
| 145 | 145 | // send them an email notifying them. |
| 146 | 146 | // |
| 147 | -function send_forum_notification_email($forum, $user){ |
|
| 148 | - $title = PROJECT . ": there is a new thread in '". $forum->title ."'"; |
|
| 149 | - $link = secure_url_base() . "forum_forum.php?id=" . $forum->id; |
|
| 150 | - $body = "A " . PROJECT . " user has added a thread to the forum |
|
| 151 | -\"" . $thread->title . "\".\n" |
|
| 147 | +function send_forum_notification_email($forum, $user) { |
|
| 148 | + $title = PROJECT.": there is a new thread in '".$forum->title."'"; |
|
| 149 | + $link = secure_url_base()."forum_forum.php?id=".$forum->id; |
|
| 150 | + $body = "A ".PROJECT." user has added a thread to the forum |
|
| 151 | +\"" . $thread->title."\".\n" |
|
| 152 | 152 | ."To view the updated forum, visit:\n$link |
| 153 | 153 | |
| 154 | 154 | -------------------------- |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | //////////////////// a user clicks the red "x" to report a post /////////// |
| 163 | 163 | // |
| 164 | -function send_report_post_email($user, $forum, $thread, $post, $message) { |
|
| 164 | +function send_report_post_email($user, $forum, $thread, $post, $message) { |
|
| 165 | 165 | $master_url = master_url(); |
| 166 | 166 | |
| 167 | 167 | $body = ""; |
@@ -219,16 +219,16 @@ discard block |
||
| 219 | 219 | // |
| 220 | 220 | function send_banish_vote_email($user, $duration, $reason, $end_time) { |
| 221 | 221 | $master_url = master_url(); |
| 222 | - $now=time(); |
|
| 222 | + $now = time(); |
|
| 223 | 223 | $subject = PROJECT." banishment vote underway"; |
| 224 | 224 | $vote_url = $master_url."forum_banishment_vote.php"; |
| 225 | 225 | $body = " |
| 226 | 226 | A vote has been started to banish you |
| 227 | 227 | from the ".PROJECT." message boards until ".date('M j, |
| 228 | -Y G:i', $duration+$now).", |
|
| 228 | +Y G:i', $duration + $now).", |
|
| 229 | 229 | because your postings have not followed our guidelines. |
| 230 | 230 | |
| 231 | -This vote will last until ".date('M j, Y G:i',$end_time)." or until a majority |
|
| 231 | +This vote will last until ".date('M j, Y G:i', $end_time)." or until a majority |
|
| 232 | 232 | decision has been reached. If the vote does not result in banishment, you will be |
| 233 | 233 | able to resume posting at that time. |
| 234 | 234 | "; |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | mkdir("../cache", 0770); |
| 33 | 33 | chmod("../cache", 0770); |
| 34 | 34 | } |
| 35 | - for ($i=0;$i<256;$i++) { |
|
| 36 | - $j=sprintf("%02x",$i); |
|
| 35 | + for ($i = 0; $i < 256; $i++) { |
|
| 36 | + $j = sprintf("%02x", $i); |
|
| 37 | 37 | if (!@filemtime("../cache/$j")) { |
| 38 | 38 | mkdir("../cache/$j", 0770); |
| 39 | 39 | chmod("../cache/$j", 0770); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -function get_path($params, $phpfile=null) { |
|
| 44 | +function get_path($params, $phpfile = null) { |
|
| 45 | 45 | if (!@filemtime("../cache/00")) make_cache_dirs(); |
| 46 | 46 | if ($phpfile) { |
| 47 | 47 | $z = $phpfile; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | // add a layer of subdirectories for reducing file lookup time |
| 54 | - $sz = substr(md5($z."_".urlencode($params)),1,2); |
|
| 54 | + $sz = substr(md5($z."_".urlencode($params)), 1, 2); |
|
| 55 | 55 | $path = "../cache/".$sz."/".$z; |
| 56 | 56 | if ($params) { |
| 57 | 57 | $path = $path."_".urlencode($params); |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | function disk_usage($dir) { |
| 63 | - $usage=0; |
|
| 64 | - if ($handle=@opendir($dir)) { |
|
| 65 | - while ($file=readdir($handle)) { |
|
| 63 | + $usage = 0; |
|
| 64 | + if ($handle = @opendir($dir)) { |
|
| 65 | + while ($file = readdir($handle)) { |
|
| 66 | 66 | if (($file != ".") && ($file != "..")) { |
| 67 | 67 | if (@is_dir($dir."/".$file)) { |
| 68 | - $usage+=disk_usage($dir."/".$file); |
|
| 68 | + $usage += disk_usage($dir."/".$file); |
|
| 69 | 69 | } else { |
| 70 | - $usage+=@filesize($dir."/".$file); |
|
| 70 | + $usage += @filesize($dir."/".$file); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | if (!chdir($dir)) { |
| 82 | 82 | return; |
| 83 | 83 | } |
| 84 | - if ($handle=@opendir(".")) { |
|
| 85 | - while ($file=readdir($handle)) { |
|
| 84 | + if ($handle = @opendir(".")) { |
|
| 85 | + while ($file = readdir($handle)) { |
|
| 86 | 86 | if ($file == ".") continue; |
| 87 | 87 | if ($file == "..") continue; |
| 88 | 88 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | if (@is_dir($file)) { |
| 94 | 94 | clean_cache($max_age, $file); |
| 95 | 95 | } else { |
| 96 | - if ((time()-@filemtime($file))>$max_age) { |
|
| 96 | + if ((time() - @filemtime($file)) > $max_age) { |
|
| 97 | 97 | //echo "unlinking ".getcwd()."/$file\n"; |
| 98 | 98 | @unlink($file); |
| 99 | 99 | } |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | // check cache size every once in a while, purge if too big |
| 109 | 109 | // |
| 110 | -function cache_check_diskspace(){ |
|
| 111 | - if ((rand() % CACHE_SIZE_CHECK_FREQ)) return; |
|
| 110 | +function cache_check_diskspace() { |
|
| 111 | + if ((rand()%CACHE_SIZE_CHECK_FREQ)) return; |
|
| 112 | 112 | if (disk_usage("../cache") < MAX_CACHE_USAGE) return; |
| 113 | 113 | $x = max(TEAM_PAGE_TTL, USER_PAGE_TTL, USER_HOST_TTL, |
| 114 | 114 | USER_PROFILE_TTL, TOP_PAGES_TTL, INDEX_PAGE_TTL |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | clean_cache($x, "../cache"); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | -function cache_need_to_regenerate($path, $max_age){ |
|
| 119 | +function cache_need_to_regenerate($path, $max_age) { |
|
| 120 | 120 | $regenerate = false; |
| 121 | 121 | $request = apache_request_headers(); |
| 122 | 122 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | // and touch the cached copy so other processes |
| 129 | 129 | // don't regenerate at the same time |
| 130 | 130 | // |
| 131 | - if ($lastmodified<time()-$max_age) { |
|
| 131 | + if ($lastmodified < time() - $max_age) { |
|
| 132 | 132 | $regenerate = true; |
| 133 | 133 | @touch($path); |
| 134 | 134 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // Returns cached data or false if nothing was found |
| 142 | -function get_cached_data($max_age, $params=""){ |
|
| 142 | +function get_cached_data($max_age, $params = "") { |
|
| 143 | 143 | global $no_cache; |
| 144 | 144 | |
| 145 | 145 | if ($no_cache) return false; |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | } else { |
| 157 | 157 | cache_check_diskspace(); |
| 158 | - $regenerate=cache_need_to_regenerate($path, $max_age); |
|
| 158 | + $regenerate = cache_need_to_regenerate($path, $max_age); |
|
| 159 | 159 | if (!$regenerate) { |
| 160 | 160 | return file_get_contents($path); |
| 161 | 161 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // DEPRECATED |
| 168 | -function start_cache($max_age, $params=""){ |
|
| 168 | +function start_cache($max_age, $params = "") { |
|
| 169 | 169 | global $no_cache, $caching, $memcache; |
| 170 | 170 | |
| 171 | 171 | if ($no_cache) return; |
@@ -188,15 +188,15 @@ discard block |
||
| 188 | 188 | $regenerate = cache_need_to_regenerate($path, $max_age); |
| 189 | 189 | } |
| 190 | 190 | //Is the stored version too old, do we need to regenerate it? |
| 191 | - if ($regenerate){ |
|
| 191 | + if ($regenerate) { |
|
| 192 | 192 | // If cached version is too old (or non-existent) |
| 193 | 193 | // generate the page and write to cache |
| 194 | 194 | // |
| 195 | 195 | ob_start(); |
| 196 | 196 | ob_implicit_flush(0); |
| 197 | - Header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
| 198 | - Header("Expires: " . gmdate("D, d M Y H:i:s",time()+$max_age) . " GMT"); |
|
| 199 | - Header("Cache-Control: public, max-age=" . $max_age); |
|
| 197 | + Header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
| 198 | + Header("Expires: ".gmdate("D, d M Y H:i:s", time() + $max_age)." GMT"); |
|
| 199 | + Header("Cache-Control: public, max-age=".$max_age); |
|
| 200 | 200 | |
| 201 | 201 | // allow the calling page to see cache period |
| 202 | 202 | // |
@@ -208,9 +208,9 @@ discard block |
||
| 208 | 208 | if (strstr($params, "format=xml")) { |
| 209 | 209 | header('Content-type: text/xml'); |
| 210 | 210 | } |
| 211 | - Header("Last-Modified: " . gmdate("D, d M Y H:i:s",$lastmodified) . " GMT"); |
|
| 212 | - Header("Expires: " . gmdate("D, d M Y H:i:s",$lastmodified+$max_age) . " GMT"); |
|
| 213 | - Header("Cache-Control: public, max-age=" . $max_age ); |
|
| 211 | + Header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastmodified)." GMT"); |
|
| 212 | + Header("Expires: ".gmdate("D, d M Y H:i:s", $lastmodified + $max_age)." GMT"); |
|
| 213 | + Header("Cache-Control: public, max-age=".$max_age); |
|
| 214 | 214 | if ($cache && $cache->content) { |
| 215 | 215 | echo $cache->content; |
| 216 | 216 | exit; |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | // write output buffer both to client and to cache |
| 230 | 230 | // DEPRECATED |
| 231 | -function end_cache($max_age,$params=""){ |
|
| 231 | +function end_cache($max_age, $params = "") { |
|
| 232 | 232 | global $no_cache; |
| 233 | 233 | if ($no_cache) return; |
| 234 | 234 | |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | -function set_cached_data($max_age, $data, $params=""){ |
|
| 256 | +function set_cached_data($max_age, $data, $params = "") { |
|
| 257 | 257 | // for the benefit of hackers |
| 258 | 258 | if (strstr($params, "..")) { |
| 259 | 259 | return "bad params"; |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | } |
| 296 | 296 | $server_arr = array(); |
| 297 | 297 | $servers = explode('|', MEMCACHE_SERVERS); |
| 298 | - foreach($servers as &$server) { |
|
| 298 | + foreach ($servers as &$server) { |
|
| 299 | 299 | list($ip, $port, $weight) = explode(':', $server); |
| 300 | 300 | if (!$port) { $port = 11211; } |
| 301 | 301 | $server_arr[] = array($ip, $port, $weight); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | // check cache size every once in a while, purge if too big |
| 109 | 109 | // |
| 110 | -function cache_check_diskspace(){ |
|
| 110 | +function cache_check_diskspace() { |
|
| 111 | 111 | if ((rand() % CACHE_SIZE_CHECK_FREQ)) return; |
| 112 | 112 | if (disk_usage("../cache") < MAX_CACHE_USAGE) return; |
| 113 | 113 | $x = max(TEAM_PAGE_TTL, USER_PAGE_TTL, USER_HOST_TTL, |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | clean_cache($x, "../cache"); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | -function cache_need_to_regenerate($path, $max_age){ |
|
| 119 | +function cache_need_to_regenerate($path, $max_age) { |
|
| 120 | 120 | $regenerate = false; |
| 121 | 121 | $request = apache_request_headers(); |
| 122 | 122 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // Returns cached data or false if nothing was found |
| 142 | -function get_cached_data($max_age, $params=""){ |
|
| 142 | +function get_cached_data($max_age, $params="") { |
|
| 143 | 143 | global $no_cache; |
| 144 | 144 | |
| 145 | 145 | if ($no_cache) return false; |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // DEPRECATED |
| 168 | -function start_cache($max_age, $params=""){ |
|
| 168 | +function start_cache($max_age, $params="") { |
|
| 169 | 169 | global $no_cache, $caching, $memcache; |
| 170 | 170 | |
| 171 | 171 | if ($no_cache) return; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $regenerate = cache_need_to_regenerate($path, $max_age); |
| 189 | 189 | } |
| 190 | 190 | //Is the stored version too old, do we need to regenerate it? |
| 191 | - if ($regenerate){ |
|
| 191 | + if ($regenerate) { |
|
| 192 | 192 | // If cached version is too old (or non-existent) |
| 193 | 193 | // generate the page and write to cache |
| 194 | 194 | // |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | // write output buffer both to client and to cache |
| 230 | 230 | // DEPRECATED |
| 231 | -function end_cache($max_age,$params=""){ |
|
| 231 | +function end_cache($max_age,$params="") { |
|
| 232 | 232 | global $no_cache; |
| 233 | 233 | if ($no_cache) return; |
| 234 | 234 | |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | -function set_cached_data($max_age, $data, $params=""){ |
|
| 256 | +function set_cached_data($max_age, $data, $params="") { |
|
| 257 | 257 | // for the benefit of hackers |
| 258 | 258 | if (strstr($params, "..")) { |
| 259 | 259 | return "bad params"; |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | if ($owner) { |
| 552 | 552 | row2('submitter', $owner->name); |
| 553 | 553 | } |
| 554 | - row2("application", $app?$app->name:'---'); |
|
| 554 | + row2("application", $app ? $app->name : '---'); |
|
| 555 | 555 | row2("state", batch_state_string($batch->state)); |
| 556 | 556 | //row2("# jobs", $batch->njobs); |
| 557 | 557 | //row2("# error jobs", $batch->nerror_jobs); |
@@ -610,9 +610,9 @@ discard block |
||
| 610 | 610 | "status" |
| 611 | 611 | ]; |
| 612 | 612 | row_heading_array($x); |
| 613 | - foreach($wus as $wu) { |
|
| 613 | + foreach ($wus as $wu) { |
|
| 614 | 614 | $y = ''; |
| 615 | - switch($wu->status) { |
|
| 615 | + switch ($wu->status) { |
|
| 616 | 616 | case WU_SUCCESS: |
| 617 | 617 | $resultid = $wu->canonical_resultid; |
| 618 | 618 | $y = sprintf('<font color="%s">completed</font>', COLOR_SUCCESS); |
@@ -688,7 +688,7 @@ discard block |
||
| 688 | 688 | $results = BoincResult::enum("workunitid=$wuid"); |
| 689 | 689 | $upload_dir = parse_config(get_config(), "<upload_dir>"); |
| 690 | 690 | $fanout = parse_config(get_config(), "<uldl_dir_fanout>"); |
| 691 | - foreach($results as $result) { |
|
| 691 | + foreach ($results as $result) { |
|
| 692 | 692 | $x = [ |
| 693 | 693 | "<a href=result.php?resultid=$result->id>$result->id</a>", |
| 694 | 694 | state_string($result) |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | if ($result->server_state == RESULT_SERVER_STATE_OVER) { |
| 698 | 698 | $phys_names = get_outfile_phys_names($result); |
| 699 | 699 | $log_names = get_outfile_log_names($result); |
| 700 | - for ($i=0; $i<count($phys_names); $i++) { |
|
| 700 | + for ($i = 0; $i < count($phys_names); $i++) { |
|
| 701 | 701 | if ($is_assim_move) { |
| 702 | 702 | // file is in |
| 703 | 703 | // project/results/<batchid>/<wu_name>__file_<log_name> |