2015-01-09 18:54:05 +00:00
|
|
|
<?php
|
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
2018-02-28 00:56:59 +00:00
|
|
|
// Copyright (C) 2018 University of California
|
2015-01-09 18:54:05 +00:00
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2017-10-31 04:38:07 +00:00
|
|
|
// functions related to account creation and login:
|
|
|
|
// - forms for create / login
|
|
|
|
// - function to make login token
|
|
|
|
|
2018-06-04 16:22:38 +00:00
|
|
|
include_once("../inc/consent.inc");
|
|
|
|
|
2018-03-01 00:27:00 +00:00
|
|
|
// If have recent token, return it.
|
|
|
|
// Else make login token, store in user record, return token
|
2017-10-31 04:38:07 +00:00
|
|
|
//
|
|
|
|
function make_login_token($user) {
|
|
|
|
$now = time();
|
2018-03-01 00:27:00 +00:00
|
|
|
if ($now - $user->login_token_time < 86400) {
|
2018-07-14 02:35:20 +00:00
|
|
|
$user->update("login_token_time=$now");
|
2018-03-01 00:27:00 +00:00
|
|
|
return $user->login_token;
|
|
|
|
}
|
|
|
|
$token = substr(random_string(), 0, 8);
|
2017-11-03 20:07:51 +00:00
|
|
|
$user->update("login_token='$token', login_token_time=$now");
|
2017-10-31 04:38:07 +00:00
|
|
|
return $token;
|
|
|
|
}
|
2015-01-14 17:19:11 +00:00
|
|
|
|
2018-01-08 08:35:53 +00:00
|
|
|
// return HTML string for a checkbox for toggling password visibility
|
|
|
|
//
|
|
|
|
function passwd_visible_checkbox($name) {
|
|
|
|
return sprintf('
|
|
|
|
<script>
|
|
|
|
function toggle_passwd() {
|
2018-03-07 00:27:22 +00:00
|
|
|
var c = document.getElementById("passwd_visible");
|
2018-01-08 08:35:53 +00:00
|
|
|
var x = document.getElementById("%s");
|
2018-03-07 00:27:22 +00:00
|
|
|
if (c.checked) {
|
2018-01-08 08:35:53 +00:00
|
|
|
x.type = "text";
|
|
|
|
} else {
|
|
|
|
x.type = "password";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2020-08-19 06:57:42 +00:00
|
|
|
<input type="checkbox" id="passwd_visible" onclick="toggle_passwd()"> <label for="passwd_visible"><small>%s</small></label>
|
|
|
|
', $name,
|
|
|
|
tra("Show password")
|
2018-01-08 08:35:53 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-01-09 18:54:05 +00:00
|
|
|
function create_account_form($teamid, $next_url) {
|
2017-02-02 06:13:21 +00:00
|
|
|
global $recaptcha_public_key;
|
2017-06-20 07:38:11 +00:00
|
|
|
form_input_hidden('next_url', $next_url);
|
2015-01-09 18:54:05 +00:00
|
|
|
|
|
|
|
if ($teamid) {
|
2017-06-20 07:38:11 +00:00
|
|
|
form_input_hidden('teamid', $teamid);
|
2015-01-09 18:54:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Using invitation codes to restrict access?
|
|
|
|
//
|
|
|
|
if (defined('INVITE_CODES')) {
|
2017-06-20 07:38:11 +00:00
|
|
|
form_input_text(
|
2017-09-26 05:08:40 +00:00
|
|
|
sprintf('<span title="%s">%s</span>',
|
|
|
|
tra("An invitation code is required to create an account."),
|
|
|
|
tra("Invitation code")
|
|
|
|
),
|
|
|
|
"invite_code"
|
2017-06-20 07:38:11 +00:00
|
|
|
);
|
2015-01-09 18:54:05 +00:00
|
|
|
}
|
|
|
|
|
2017-06-20 07:38:11 +00:00
|
|
|
form_input_text(
|
2017-09-26 05:08:40 +00:00
|
|
|
sprintf('<span title="%s">%s</span>',
|
|
|
|
tra("Identifies you on our web site. Use your real name or a nickname."),
|
|
|
|
tra("Screen name")
|
|
|
|
),
|
2017-06-20 07:38:11 +00:00
|
|
|
"new_name"
|
2015-01-09 18:54:05 +00:00
|
|
|
);
|
2017-06-20 07:38:11 +00:00
|
|
|
form_input_text(
|
2017-09-26 05:08:40 +00:00
|
|
|
sprintf('<span title="%s">%s</span>',
|
|
|
|
tra("Must be a valid address of the form 'name@domain'."),
|
|
|
|
tra("Email address")
|
|
|
|
),
|
2017-06-20 07:38:11 +00:00
|
|
|
"new_email_addr"
|
2015-01-09 18:54:05 +00:00
|
|
|
);
|
|
|
|
$min_passwd_length = parse_element(get_config(), "<min_passwd_length>");
|
|
|
|
if (!$min_passwd_length) {
|
|
|
|
$min_passwd_length = 6;
|
|
|
|
}
|
|
|
|
|
2017-06-20 07:38:11 +00:00
|
|
|
form_input_text(
|
2017-09-26 05:08:40 +00:00
|
|
|
sprintf('<span title="%s">%s</span>',
|
|
|
|
tra("Must be at least %1 characters", $min_passwd_length),
|
|
|
|
tra("Password")
|
|
|
|
),
|
2018-03-07 18:27:23 +00:00
|
|
|
"passwd", "", "password",'id="passwd"',passwd_visible_checkbox("passwd")
|
2015-01-09 18:54:05 +00:00
|
|
|
);
|
2018-12-15 04:20:24 +00:00
|
|
|
if (USER_COUNTRY) {
|
2018-12-11 00:58:56 +00:00
|
|
|
form_select(
|
|
|
|
sprintf('<span title="%s">%s</span>',
|
|
|
|
tra("Select the country you want to represent, if any."),
|
|
|
|
tra("Country")
|
|
|
|
),
|
|
|
|
"country",
|
|
|
|
country_select_options()
|
|
|
|
);
|
|
|
|
}
|
2017-06-05 21:26:42 +00:00
|
|
|
if (POSTAL_CODE) {
|
2017-06-20 07:38:11 +00:00
|
|
|
form_input_text(
|
2016-11-29 08:34:26 +00:00
|
|
|
tra("Postal or ZIP Code")."<br><small>".tra("Optional")."</small>",
|
2017-06-20 07:38:11 +00:00
|
|
|
"postal_code"
|
2015-01-14 17:19:11 +00:00
|
|
|
);
|
|
|
|
}
|
2018-05-04 23:42:05 +00:00
|
|
|
|
2018-06-01 19:41:21 +00:00
|
|
|
// Add terms of use to Web form. User must agree by checking the checkbox.
|
2018-09-17 15:39:24 +00:00
|
|
|
list($checkct, $ctid) = check_consent_type(CONSENT_TYPE_ENROLL);
|
2018-06-15 19:54:35 +00:00
|
|
|
if ($checkct and check_termsofuse()) {
|
2018-06-11 15:42:31 +00:00
|
|
|
$terms_of_use = trim(file_get_contents(TERMSOFUSE_FILE));
|
2018-05-04 23:42:05 +00:00
|
|
|
if ($terms_of_use) {
|
2018-09-17 14:50:00 +00:00
|
|
|
panel(tra('Terms of Use'), function() use($terms_of_use) {
|
2018-05-04 23:42:05 +00:00
|
|
|
echo nl2br($terms_of_use);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$myitems = array(
|
2018-06-01 19:41:21 +00:00
|
|
|
array("agree_to_terms_of_use", "", false),
|
2018-05-04 23:42:05 +00:00
|
|
|
);
|
|
|
|
form_checkboxes(tra("Do you agree to the terms of use above?"), $myitems, 'tabindex="0"');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-09 18:54:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function login_form($next_url) {
|
2017-11-21 23:32:42 +00:00
|
|
|
form_start(secure_url_base()."/login_action.php", "post");
|
|
|
|
form_input_hidden("next_url", $next_url);
|
2015-01-09 18:54:05 +00:00
|
|
|
if (LDAP_HOST) {
|
|
|
|
$x = "Email address or LDAP user name:";
|
|
|
|
} else {
|
|
|
|
$x = tra("Email address:");
|
|
|
|
}
|
2018-03-09 19:51:41 +00:00
|
|
|
form_input_text($x, "email_addr", '', 'text', $attrs='autofocus tabindex="1"');
|
2017-11-21 23:32:42 +00:00
|
|
|
form_input_text(
|
|
|
|
tra("Password:").'<br><small><a href="get_passwd.php">' . tra("forgot password?") . "</a></small>",
|
|
|
|
"passwd",
|
|
|
|
"",
|
2018-02-28 00:56:59 +00:00
|
|
|
"password",
|
2018-03-09 19:51:41 +00:00
|
|
|
'id="passwd" tabindex="2"',
|
2018-02-28 00:56:59 +00:00
|
|
|
passwd_visible_checkbox("passwd")
|
2015-01-09 18:54:05 +00:00
|
|
|
);
|
2018-01-06 09:07:27 +00:00
|
|
|
form_checkboxes(tra("Stay logged in"),
|
2018-03-09 19:51:41 +00:00
|
|
|
array(array("stay_logged_in", "", true)),
|
|
|
|
'tabindex="3"'
|
2018-01-06 09:07:27 +00:00
|
|
|
);
|
2020-08-19 06:57:42 +00:00
|
|
|
form_submit(tra("Log in"), 'tabindex="4"');
|
2017-11-21 23:32:42 +00:00
|
|
|
form_end();
|
2015-01-09 18:54:05 +00:00
|
|
|
}
|
|
|
|
|
2018-06-04 16:22:38 +00:00
|
|
|
function user_agreetermsofuse_form($next_url) {
|
|
|
|
form_start(secure_url_base()."/user_agreetermsofuse_action.php", "post");
|
2018-05-08 19:36:05 +00:00
|
|
|
form_input_hidden("next_url", $next_url);
|
|
|
|
|
2018-06-11 15:42:31 +00:00
|
|
|
$terms_of_use = trim(file_get_contents(TERMSOFUSE_FILE));
|
2018-05-08 19:36:05 +00:00
|
|
|
if ($terms_of_use) {
|
2018-09-17 14:50:00 +00:00
|
|
|
panel(tra('Terms of Use'), function() use($terms_of_use) {
|
2018-05-08 19:36:05 +00:00
|
|
|
echo nl2br($terms_of_use);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$myitems = array(
|
2018-06-01 19:41:21 +00:00
|
|
|
array("agree_to_terms_of_use", "", false),
|
2018-05-08 19:36:05 +00:00
|
|
|
);
|
|
|
|
form_checkboxes(tra("Do you agree to the terms of use above?"), $myitems, 'tabindex="0"');
|
|
|
|
}
|
|
|
|
else {
|
2018-06-01 19:41:21 +00:00
|
|
|
// error - no terms of use for user to agree to!
|
2018-05-08 19:36:05 +00:00
|
|
|
}
|
|
|
|
|
2018-06-11 14:38:35 +00:00
|
|
|
form_submit(tra("I agree"));
|
2018-05-08 19:36:05 +00:00
|
|
|
form_end();
|
|
|
|
}
|
|
|
|
|
2015-01-09 18:54:05 +00:00
|
|
|
?>
|