Passed
Push — dpa_web25 ( 2d2e78 )
by David
09:55
created
html/user/account_ownership.php 1 patch
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -28,138 +28,138 @@
 block discarded – undo
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') {
Please login to merge, or discard this patch.
html/inc/forum_email.inc 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.