Add adress and phone number attributes
Change-Id: I7e69468ac6e5a05f42120a42bf02b92f18773ca7
diff --git a/User.php b/User.php
index ea144b7..5fb7307 100644
--- a/User.php
+++ b/User.php
@@ -3,50 +3,126 @@
class User
{
- public $username;
- public $name;
- public $first_name;
- public $last_name;
- public $email;
- public $organization;
- public $user_hash;
- public $password;
- function __construct()
- {
- $this->username = "";
- $this->name = "";
- $this->first_name = "";
- $this->last_name = "";
- $this->email = "";
- $this->organization = "";
- $this->user_hash = "";
- $this->password = "";
+ public $username;
+ public $first_name;
+ public $last_name;
+ public $organization;
+ public $user_hash;
+ public $password;
+ public $street;
+ public $zip;
+ public $city;
+ public $country;
+ public $email;
+ public $phone;
+ public bool $eula_signed;
+ public bool $privacy_policy_signed;
+
+ function __construct()
+ {
+ $this->username = "";
+ $this->first_name = "";
+ $this->last_name = "";
+ $this->email = "";
+ $this->organization = "";
+ $this->user_hash = "";
+ $this->password = "";
+ $this->city = "";
+ $this->country = "";
+ $this->zip = "";
+ $this->street = "";
+ $this->phone = "";
+ $this->eula_signed = false;
+ $this->privacy_policy_signed = false;
+ }
+
+ function __construct1(object $data)
+ {
+ foreach ($data as $key => $value) {
+ if (array_key_exists($key, (array) $this))
+ $this->{$key} = $value;
}
+ if (isset($data->password)) $this->set_password($data->password);
+ }
- function __construct6(string $username, string $first_name, string $last_name, string $email, string $password, string $organization)
- {
- include 'config.php';
- $this->username = $username;
- $this->name = $first_name;
- $this->first_name = $first_name;
- $this->last_name = $last_name;
- $this->email = $email;
- $this->organization = $organization;
- $this->set_password($password);
-
+ function init_from_object(object $data)
+ {
+ foreach ($data as $key => $value) {
+ if (array_key_exists($key, (array) $this))
+ $this->{$key} = $value;
}
+ if (isset($data->password)) $this->set_password($data->password);
+ }
- function set_password(string $password)
- {
- include 'config.php';
- if ($ENCRYPT_PASSWORDS) {
- $this->user_hash = "{crypt}" . crypt($password, '$6$' . generateSalt(10) . '$');
- # $this->user_hash = "{SHA}" . base64_encode(sha1($password, true));
- } else {
- $this->user_hash = "{CLEAR}" . $password;
+ function init_from_array(array $data)
+ {
+ foreach ($data as $key => $value) {
+ if (array_key_exists($key, (array) $this)) {
+ if (is_bool(gettype($this->{$key})) && is_string($value))
+ $this->{$key} = !empty($value);
+ else
+ $this->{$key} = $value;
+ }
+ }
+ if (!empty($data["password"])) $this->set_password($data["password"]);
+ }
+
+ function __construct6(string $username, string $first_name, string $last_name, string $email, string $password, string $organization)
+ {
+ include 'config.php';
+ $this->username = $username;
+ $this->first_name = $first_name;
+ $this->last_name = $last_name;
+ $this->email = $email;
+ $this->organization = $organization;
+ $this->set_password($password);
+ }
+
+ function set_password(string $password)
+ {
+ include 'config.php';
+ if ($ENCRYPT_PASSWORDS) {
+ $this->user_hash = "{crypt}" . crypt($password, '$6$' . generateSalt(10) . '$');
+ # $this->user_hash = "{SHA}" . base64_encode(sha1($password, true));
+ } else {
+ $this->user_hash = "{CLEAR}" . $password;
+ }
+ $this->password = $this->user_hash;
+ }
+
+ function to_string()
+ {
+ $tmp_user = $this;
+ $tmp_user->password = "***";
+ $tmp_user->user_hash = "***";
+ return json_encode($tmp_user);
+ }
+
+ function backup_in_session()
+ {
+ global $_SESSION;
+ foreach ($this as $key => $value) {
+ $_SESSION[$key] = $value;
+ }
+ }
+
+ function to_table() {
+ $table = "<table style='border: 1px solid #e1e4e8; border-collapse: collapse; width: 100%;'>";
+ foreach ($this as $key => $value) {
+ if ($key != "password" && $key != "user_hash" && !empty($value)) {
+ if (is_bool($value)) {
+ if ($value) $value = "yes";
+ else $value = "no";
}
- $this->password = $this->user_hash;
+ $value = str_replace("\r\n", "<br>", $value);
+ $key = str_replace("_", " ", ucfirst($key));
+ $table .= " <tr>
+ <td style='border: 1px solid #e1e4e8; padding: 6px 13px;'><strong>$key</strong></td>
+ <td style='border: 1px solid #e1e4e8; padding: 6px 13px;'>$value</td>
+ </tr>\n";
+ }
}
-}
-
-?>
\ No newline at end of file
+ $table .= "</table>";
+ return $table;
+ }
+}
\ No newline at end of file
diff --git a/index.php b/index.php
index b019079..d2ae3a1 100755
--- a/index.php
+++ b/index.php
@@ -131,7 +131,7 @@
$error = "";
$error .= validate_username($user->username);
- $error .= validate_name($user->name, $FIRST_NAME_VALIDATION_ERROR);
+ $error .= validate_name($user->first_name, $FIRST_NAME_VALIDATION_ERROR);
$error .= validate_name($user->last_name, $LAST_NAME_VALIDATION_ERROR);
$error .= validate_email($user->email);
$error .= validate_password($password);
@@ -145,14 +145,6 @@
return $error;
}
-function backup_user_in_session($user)
-{
- $_SESSION['username'] = $user->username;
- $_SESSION['first_name'] = $user->first_name;
- $_SESSION['last_name'] = $user->last_name;
- $_SESSION['email'] = $user->email;
- $_SESSION['organization'] = $user->organization;
-}
function approve_request(User $user)
{
@@ -177,10 +169,10 @@
send_confirmation_email($user->email, $smtp, $url, $user);
$_SESSION['resend'] = generateRandomString(12);
$_SESSION['token'] = $token;
- backup_user_in_session($user);
+ $user->backup_in_session();
$TEMPLATE = template_path();
include $TEMPLATE . "confirm_your_email.htm";
- $log->info("Registration process started for " . user_to_string($user));
+ $log->info("Registration process started for " . $user->to_string());
}
function recover_form($error = null)
@@ -210,7 +202,10 @@
if (isset($_POST['type'])) {
switch ($_POST['type']) {
case "register":
- $user = new User($_POST["username"], $_POST["name"], $_POST["last_name"], $_POST["email"], $_POST["password"], $_POST["organization"]);
+ $log->info("Registration request from " . array_to_string($_POST));
+ $user = new User();
+ $user->init_from_array($_POST);
+ $log->info("Registration request from " . $user->to_string());
if (redis_inc_ipdata(getClientIP(), "register", true) > $HOURLY_REGISTRATIONS) {
include $TEMPLATE . "registration_limit.htm";
} else {
@@ -313,12 +308,12 @@
}
}
redis_inc_ipdata(getClientIP(), "register");
- $log->info("User registered: " . user_to_string($user));
+ $log->info("User registered: " . $user->to_string());
echo $STRINGS->email_confirmation;
if (isset($POST_REGISTER_HOOK)) $POST_REGISTER_HOOK($user);
include $TEMPLATE . "mail_confirmed.htm";
} else {
- $log->error("User registration failed for: " . user_to_string($user));
+ $log->error("User registration failed for: " . $user->to_string());
echo $STRINGS->email_confirmation;
include $TEMPLATE . "registration_error.htm";
}
diff --git a/ldap.php b/ldap.php
index 8f43c23..3c63d12 100755
--- a/ldap.php
+++ b/ldap.php
@@ -72,6 +72,7 @@
$info["postalcode"] = $user->zip;
$info["l"] = $user->city;
$info["co"] = $user->country;
+ $info["telephoneNumber"] = $user->phone;
$info["objectclass"][0] = "top";
$info["objectclass"][1] = "person";
diff --git a/redis.php b/redis.php
index 323a74b..45c00b0 100755
--- a/redis.php
+++ b/redis.php
@@ -17,11 +17,13 @@
function redis_get_user($key) {
$redis = connect();
- $data = json_decode($redis->get($key));
- if ($data && gettype($data) == "object") {
+ $data = json_decode($redis->get($key), true);
+ if ($data && gettype($data) == "array") {
$user = new User();
- foreach ($data as $key => $value) $user->{$key} = $value;
- if (isset($data->password)) $user->set_password($data->password);
+ $user->init_from_array($data);
+
+ #foreach ($data as $key => $value) $user->{$key} = $value;
+ #if (isset($data->password)) $user->set_password($data->password);
#$user = new User($data->username, $data->first_name, $data->last_name, $data->email, $data->password, $data->organization);
return $user;
} else {
diff --git a/templates/email.php b/templates/email.php
index ccb20d0..58eb17f 100644
--- a/templates/email.php
+++ b/templates/email.php
@@ -2,40 +2,7 @@
$REGISTRATION_INFORMATION = "
<h3>Registration information</h3>
<p>
-<table style='border: 1px solid #e1e4e8; border-collapse: collapse; width: 100%;'>
-<tr>
-<td style='border: 1px solid #e1e4e8; padding: 6px 13px;'>
-<strong>Username</strong>
-</td>
-<td style='border: 1px solid #e1e4e8; padding: 6px 13px;'>
-{{username}}
-</td>
-</tr>
-<tr>
-<td style='border: 1px solid #e1e4e8; padding: 6px 13px;'>
-<strong>Name</strong>
-</td>
-<td style='border: 1px solid #e1e4e8; padding: 6px 13px;'>
-{{full_name}}
-</td>
-</tr>
-<tr>
-<td style='border: 1px solid #e1e4e8; padding: 6px 13px;'>
-<strong>Organization</strong>
-</td>
-<td style='border: 1px solid #e1e4e8; padding: 6px 13px;'>
-{{organization}}
-</td>
-</tr>
-<tr>
-<td style='border: 1px solid #e1e4e8; padding: 6px 13px;'>
-<strong>Email</strong>
-</td>
-<td style='border: 1px solid #e1e4e8; padding: 6px 13px;'>
-{{email}}
-</td>
-</tr>
-</table>
+{{usertable}}
</p>
";
diff --git a/templates/register.htm b/templates/register.htm
index 5292bbd..cd715a2 100644
--- a/templates/register.htm
+++ b/templates/register.htm
@@ -2,7 +2,7 @@
<?php echo $SERVICE_ACRONYM;?>
</h1>
-<form class="row g-3 needs-validation" novalidate action="" method="POST">
+<form class="row g-3 needs-validation" novalidate data-toggle="validator" action="" method="POST">
<!-- Username input -->
<div class="col-md-4">
<label class="form-label font-weight-bold" for="form3Example3">Username</label>
@@ -20,10 +20,10 @@
<div class="form-outline">
<label class="form-label font-weight-bold" for="form3Example1">First name</label>
<input pattern="[^\s]{<?php echo $VAL_USER->min_first_name.','.$VAL_USER->max_first_name;?>}" required
- title="At least 2 not whitespace characters" name="name" type="text" id="form3Example1"
- class="form-control <?php if(isset($error) && $error && !isset($_POST['name'])){echo 'border-danger';}?>"
+ title="At least 2 not whitespace characters" name="first_name" type="text" id="form3Example1"
+ class="form-control <?php if(isset($error) && $error && !isset($_POST['first_name'])){echo 'border-danger';}?>"
placeholder="John"
- value="<?php echo isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '' ?>" />
+ value="<?php echo isset($_POST['first_name']) ? htmlspecialchars($_POST['first_name']) : '' ?>" />
<div class="invalid-feedback">
Please provide a first name with at least 2 characters.
</div>
@@ -43,30 +43,351 @@
</div>
</div>
- <!-- Email input -->
- <div class="form-outline md-6">
- <label class="form-label font-weight-bold" for="form3Example3">Email address</label>
- <input required name="email" type="email" id="form3Example3"
- class="form-control <?php if(isset($error) && $error && !isset($_POST['email'])){echo 'border-danger';}?>"
- placeholder="myemail@example.com"
- value="<?php echo isset($_POST['email']) ? htmlspecialchars($_POST['email']) : '' ?>" />
- <div class="invalid-feedback">
- Please provide a valid email address.
- </div>
- </div>
-
<div class="form-outline md-6">
<label class="form-label font-weight-bold" for="organization">Institution / Organization</label>
<input required name="organization" type="text" id="organization"
class="form-control <?php if(isset($error) && $error && !isset($_POST['organization'])){echo 'border-danger';}?>"
placeholder="Example University"
pattern=".{3,64}"
+ type="text"
value="<?php echo isset($_POST['organization']) ? htmlspecialchars($_POST['organization']) : '' ?>" />
<div class="invalid-feedback">
Please indicate the institution or organization you are affiliated with.
</div>
</div>
+ <!--
+ <div class="form-outline col-md-6">
+ <label for="address-line-1" class="form-label form-label font-weight-bold">Address line 1</label>
+ <input name="address-line-1" type="text" class="form-control" id="address-line-1"/>
+ </div>
+ Address line 1-->
+
+ <!-- Street -->
+ <div class="form-outline col-md-12">
+ <label for="street" class="form-label form-label font-weight-bold">Street</label>
+ <input name="street" type="text" class="form-control" id="street"
+ placeholder="1234 Main St"
+ value="<?php echo isset($_POST['street']) ? htmlspecialchars($_POST['street']) : '' ?>"
+ required/>
+ <div class="invalid-feedback">
+ Please provide a valid street.
+ </div>
+ </div>
+
+ <!-- Zip code -->
+ <div class="form-outline col-md-3">
+ <label for="zip-code" class="form-label form-label font-weight-bold">Zip</label>
+ <input name="zip" type="text" class="form-control" id="zip-code"
+ value="<?php echo isset($_POST['zip']) ? htmlspecialchars($_POST['zip']) : '' ?>"
+ required/>
+ <div class="invalid-feedback">
+ Please provide a valid zip or postal code.
+ </div>
+ </div>
+
+ <!-- City -->
+ <div class="form-outline col-md-5">
+ <label for="city" class="form-label form-label font-weight-bold">City</label>
+ <input name="city" type="text" class="form-control" id="city"
+ value="<?php echo isset($_POST['city']) ? htmlspecialchars($_POST['city']) : '' ?>"
+ required/>
+ <div class="invalid-feedback">
+ Please provide a valid city.
+ </div>
+ </div>
+
+ <!-- Country -->
+ <div class="form-outline col-md-6">
+ <label for="country" class="form-label form-label font-weight-bold">Country</label>
+ <input class="form-control" list="countries" name="country" id="country"
+ value="<?php echo isset($_POST['country']) ? htmlspecialchars($_POST['country']) : '' ?>"
+ required placeholder="Type to search your country...">
+ <datalist id="countries">
+ <option value="Afghanistan">
+ <option value="Åland Islands">
+ <option value="Albania">
+ <option value="Algeria">
+ <option value="American Samoa">
+ <option value="Andorra">
+ <option value="Angola">
+ <option value="Anguilla">
+ <option value="Antarctica">
+ <option value="Antigua and Barbuda">
+ <option value="Argentina">
+ <option value="Armenia">
+ <option value="Aruba">
+ <option value="Australia">
+ <option value="Austria">
+ <option value="Azerbaijan">
+ <option value="Bahamas">
+ <option value="Bahrain">
+ <option value="Bangladesh">
+ <option value="Barbados">
+ <option value="Belarus">
+ <option value="Belgium">
+ <option value="Belize">
+ <option value="Benin">
+ <option value="Bermuda">
+ <option value="Bhutan">
+ <option value="Bolivia, Plurinational State of">
+ <option value="Bonaire, Sint Eustatius and Saba">
+ <option value="Bosnia and Herzegovina">
+ <option value="Botswana">
+ <option value="Bouvet Island">
+ <option value="Brazil">
+ <option value="British Indian Ocean Territory">
+ <option value="Brunei Darussalam">
+ <option value="Bulgaria">
+ <option value="Burkina Faso">
+ <option value="Burundi">
+ <option value="Cambodia">
+ <option value="Cameroon">
+ <option value="Canada">
+ <option value="Cape Verde">
+ <option value="Cayman Islands">
+ <option value="Central African Republic">
+ <option value="Chad">
+ <option value="Chile">
+ <option value="China">
+ <option value="Christmas Island">
+ <option value="Cocos (Keeling) Islands">
+ <option value="Colombia">
+ <option value="Comoros">
+ <option value="Congo">
+ <option value="Congo, the Democratic Republic of the">
+ <option value="Cook Islands">
+ <option value="Costa Rica">
+ <option value="Côte d'Ivoire">
+ <option value="Croatia">
+ <option value="Cuba">
+ <option value="Curaçao">
+ <option value="Cyprus">
+ <option value="Czech Republic">
+ <option value="Denmark">
+ <option value="Djibouti">
+ <option value="Dominica">
+ <option value="Dominican Republic">
+ <option value="Ecuador">
+ <option value="Egypt">
+ <option value="El Salvador">
+ <option value="Equatorial Guinea">
+ <option value="Eritrea">
+ <option value="Estonia">
+ <option value="Ethiopia">
+ <option value="Falkland Islands (Malvinas)">
+ <option value="Faroe Islands">
+ <option value="Fiji">
+ <option value="Finland">
+ <option value="France">
+ <option value="French Guiana">
+ <option value="French Polynesia">
+ <option value="French Southern Territories">
+ <option value="Gabon">
+ <option value="Gambia">
+ <option value="Georgia">
+ <option value="Germany">
+ <option value="Ghana">
+ <option value="Gibraltar">
+ <option value="Greece">
+ <option value="Greenland">
+ <option value="Grenada">
+ <option value="Guadeloupe">
+ <option value="Guam">
+ <option value="Guatemala">
+ <option value="Guernsey">
+ <option value="Guinea">
+ <option value="Guinea-Bissau">
+ <option value="Guyana">
+ <option value="Haiti">
+ <option value="Heard Island and McDonald Islands">
+ <option value="Holy See (Vatican City State)">
+ <option value="Honduras">
+ <option value="Hong Kong">
+ <option value="Hungary">
+ <option value="Iceland">
+ <option value="India">
+ <option value="Indonesia">
+ <option value="Iran, Islamic Republic of">
+ <option value="Iraq">
+ <option value="Ireland">
+ <option value="Isle of Man">
+ <option value="Israel">
+ <option value="Italy">
+ <option value="Jamaica">
+ <option value="Japan">
+ <option value="Jersey">
+ <option value="Jordan">
+ <option value="Kazakhstan">
+ <option value="Kenya">
+ <option value="Kiribati">
+ <option value="Korea, Democratic People's Republic of">
+ <option value="Korea, Republic of">
+ <option value="Kuwait">
+ <option value="Kyrgyzstan">
+ <option value="Lao People's Democratic Republic">
+ <option value="Latvia">
+ <option value="Lebanon">
+ <option value="Lesotho">
+ <option value="Liberia">
+ <option value="Libya">
+ <option value="Liechtenstein">
+ <option value="Lithuania">
+ <option value="Luxembourg">
+ <option value="Macao">
+ <option value="Macedonia, the former Yugoslav Republic of">
+ <option value="Madagascar">
+ <option value="Malawi">
+ <option value="Malaysia">
+ <option value="Maldives">
+ <option value="Mali">
+ <option value="Malta">
+ <option value="Marshall Islands">
+ <option value="Martinique">
+ <option value="Mauritania">
+ <option value="Mauritius">
+ <option value="Mayotte">
+ <option value="Mexico">
+ <option value="Micronesia, Federated States of">
+ <option value="Moldova, Republic of">
+ <option value="Monaco">
+ <option value="Mongolia">
+ <option value="Montenegro">
+ <option value="Montserrat">
+ <option value="Morocco">
+ <option value="Mozambique">
+ <option value="Myanmar">
+ <option value="Namibia">
+ <option value="Nauru">
+ <option value="Nepal">
+ <option value="Netherlands">
+ <option value="New Caledonia">
+ <option value="New Zealand">
+ <option value="Nicaragua">
+ <option value="Niger">
+ <option value="Nigeria">
+ <option value="Niue">
+ <option value="Norfolk Island">
+ <option value="Northern Mariana Islands">
+ <option value="Norway">
+ <option value="Oman">
+ <option value="Pakistan">
+ <option value="Palau">
+ <option value="Palestinian Territory, Occupied">
+ <option value="Panama">
+ <option value="Papua New Guinea">
+ <option value="Paraguay">
+ <option value="Peru">
+ <option value="Philippines">
+ <option value="Pitcairn">
+ <option value="Poland">
+ <option value="Portugal">
+ <option value="Puerto Rico">
+ <option value="Qatar">
+ <option value="Réunion">
+ <option value="Romania">
+ <option value="Russian Federation">
+ <option value="Rwanda">
+ <option value="Saint Barthélemy">
+ <option value="Saint Helena, Ascension and Tristan da Cunha">
+ <option value="Saint Kitts and Nevis">
+ <option value="Saint Lucia">
+ <option value="Saint Martin (French part)">
+ <option value="Saint Pierre and Miquelon">
+ <option value="Saint Vincent and the Grenadines">
+ <option value="Samoa">
+ <option value="San Marino">
+ <option value="Sao Tome and Principe">
+ <option value="Saudi Arabia">
+ <option value="Senegal">
+ <option value="Serbia">
+ <option value="Seychelles">
+ <option value="Sierra Leone">
+ <option value="Singapore">
+ <option value="Sint Maarten (Dutch part)">
+ <option value="Slovakia">
+ <option value="Slovenia">
+ <option value="Solomon Islands">
+ <option value="Somalia">
+ <option value="South Africa">
+ <option value="South Georgia and the South Sandwich Islands">
+ <option value="South Sudan">
+ <option value="Spain">
+ <option value="Sri Lanka">
+ <option value="Sudan">
+ <option value="Suriname">
+ <option value="Svalbard and Jan Mayen">
+ <option value="Swaziland">
+ <option value="Sweden">
+ <option value="Switzerland">
+ <option value="Syrian Arab Republic">
+ <option value="Taiwan, Province of China">
+ <option value="Tajikistan">
+ <option value="Tanzania, United Republic of">
+ <option value="Thailand">
+ <option value="Timor-Leste">
+ <option value="Togo">
+ <option value="Tokelau">
+ <option value="Tonga">
+ <option value="Trinidad and Tobago">
+ <option value="Tunisia">
+ <option value="Turkey">
+ <option value="Turkmenistan">
+ <option value="Turks and Caicos Islands">
+ <option value="Tuvalu">
+ <option value="Uganda">
+ <option value="Ukraine">
+ <option value="United Arab Emirates">
+ <option value="United Kingdom">
+ <option value="United States">
+ <option value="United States Minor Outlying Islands">
+ <option value="Uruguay">
+ <option value="Uzbekistan">
+ <option value="Vanuatu">
+ <option value="Venezuela, Bolivarian Republic of">
+ <option value="Viet Nam">
+ <option value="Virgin Islands, British">
+ <option value="Virgin Islands, U.S.">
+ <option value="Wallis and Futuna">
+ <option value="Western Sahara">
+ <option value="Yemen">
+ <option value="Zambia">
+ <option value="Zimbabwe">
+ </datalist>
+ <div class="invalid-feedback">
+ Please provide a valid country.
+ </div>
+ </div>
+
+ <!-- Email input -->
+ <div class="form-outline md-6">
+ <label class="form-label font-weight-bold" for="email">Email address</label>
+ <input required name="email" type="email" id="email"
+ class="form-control <?php if(isset($error) && $error && !isset($_POST['email'])){echo 'border-danger';}?>"
+ type="email"
+ pattern="^[^\s@]+@[^\s@]+\.[^\s@]+$"
+ placeholder="myemail@example.org"
+ value="<?php echo isset($_POST['email']) ? htmlspecialchars($_POST['email']) : '' ?>" />
+ <div class="invalid-feedback">
+ Please provide a valid email address.
+ </div>
+ </div>
+
+ <!-- Phone number -->
+ <div class="form-outline md-6">
+ <label class="form-label font-weight-bold" for="phone">Phone number</label>
+ <input required name="phone" type="tel" id="phone"
+ class="form-control <?php if(isset($error) && $error && !isset($_POST['phone'])){echo 'border-danger';}?>"
+ pattern="\+\d[\s\d-]+$"
+ placeholder="+1 234 567 890"
+ value="<?php echo isset($_POST['phone']) ? htmlspecialchars($_POST['phone']) : '' ?>"
+ required/>
+ <i class='bx bxs-phone'></i>
+ <div class="invalid-feedback">
+ Please provide a valid phone number.
+ </div>
+ </div>
+
<!-- Password input -->
<div id="password-div" class="col-md-8">
<label class="form-label font-weight-bold" for="pw1">Password</label>
@@ -113,9 +434,9 @@
<div class="form-outline mb-3">
<label class="form-label font-weight-bold" for="eula">End User License Agreement</label>
<div class="form-group form-check">
- <input type="checkbox" class="form-check-input" name="eula" id="eula" required
+ <input type="checkbox" class="form-check-input" name="eula_signed" id="eula" required
title="You need to agree to the EULA in order to proceed"
- <?php echo isset($_POST['eula']) ? 'checked' : '' ?>
+ <?php echo isset($_POST['eula_signed']) ? 'checked' : '' ?>
value="eula">
<label class="form-check-label" for="eula">I have read and agree to to the
<?php echo $SERVICE_NAME; ?> <a
@@ -131,9 +452,9 @@
<div class="form-outline mb-3">
<label class="form-label font-weight-bold" for="privacy_policy">Privacy Policy</label>
<div class="form-group form-check">
- <input type="checkbox" class="form-check-input" name="privacy_policy" id="privacy_policy" required
+ <input type="checkbox" class="form-check-input" name="privacy_policy_signed" id="privacy_policy" required
title="You need to agree to the privacy policy in order to proceed"
- <?php echo isset($_POST['privacy_policy']) ? 'checked' : '' ?>
+ <?php echo isset($_POST['privacy_policy_signed']) ? 'checked' : '' ?>
value="privacy_policy">
<label class="form-check-label" for="privacy_policy">I have read and agree
to to the
diff --git a/utils.php b/utils.php
index 41996fb..2c2d29b 100644
--- a/utils.php
+++ b/utils.php
@@ -60,18 +60,23 @@
function replace_all_user_variables(string $string, User $user, string $url)
{
+ foreach ($user as $key => $value) {
+ $to_replace = "{{" . $key . "}}";
+ $string = str_replace($to_replace, $value, $string);
+ }
+
$string = str_replace("{{url}}", $url, $string);
$string = str_replace("{{full_name}}", $user->first_name . " " . $user->last_name, $string);
$string = str_replace("{{fullname}}", $user->first_name . " " . $user->last_name, $string);
- $string = str_replace("{{first_name}}", $user->first_name, $string);
- $string = str_replace("{{last_name}}", $user->last_name, $string);
- $string = str_replace("{{email}}", $user->email, $string);
- $string = str_replace("{{organization}}", $user->organization, $string);
- $string = str_replace("{{username}}", $user->username, $string);
+ $string = str_replace("{{usertable}}", $user->to_table(), $string);
return $string;
}
-function user_to_string(User $user)
+function array_to_string(array $array)
{
- return $user->first_name . " " . $user->last_name . " <" . $user->email . "> " . $user->organization . " " . $user->username;
-}
\ No newline at end of file
+ $string = "";
+ foreach ($array as $key => $value) {
+ $string .= $key . ": " . $value . "\n";
+ }
+ return $string;
+}