Merge branch 'hotspotbilling:Development' into Development

This commit is contained in:
Focuslinkstech 2024-10-27 15:07:00 +01:00 committed by GitHub
commit dc42a09685
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 113 additions and 88 deletions

View File

@ -77,7 +77,7 @@ class Package
r2(U . 'home', 'e', Lang::T('Plan Not found')); r2(U . 'home', 'e', Lang::T('Plan Not found'));
} }
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
r2(U . 'dashboard', 'e', Lang::T('Plan Not found')); r2(U . 'dashboard', 'e', Lang::T('You do not have permission to access this page'));
} }
} }

View File

@ -22,12 +22,14 @@ switch ($do) {
$password = _post('password'); $password = _post('password');
$cpassword = _post('cpassword'); $cpassword = _post('cpassword');
$address = _post('address'); $address = _post('address');
// Separate phone number input if OTP is required
if (!empty($config['sms_url']) && $_c['sms_otp_registration'] == 'yes') { if (!empty($config['sms_url']) && $_c['sms_otp_registration'] == 'yes') {
$phonenumber = Lang::phoneFormat($username); $phone_number = alphanumeric(_post('phone_number'), "+_.@-");
$username = $phonenumber; } else {
} else if (strlen($username) < 21) { $phone_number = $username; // When OTP is not required, treat username as phone number
$phonenumber = $username;
} }
$msg = ''; $msg = '';
if (Validator::Length($username, 35, 2) == false) { if (Validator::Length($username, 35, 2) == false) {
$msg .= 'Username should be between 3 to 55 characters' . '<br>'; $msg .= 'Username should be between 3 to 55 characters' . '<br>';
@ -45,10 +47,11 @@ switch ($do) {
$msg .= Lang::T('Passwords does not match') . '<br>'; $msg .= Lang::T('Passwords does not match') . '<br>';
} }
// OTP verification if OTP is enabled
if (!empty($config['sms_url']) && $_c['sms_otp_registration'] == 'yes') { if (!empty($config['sms_url']) && $_c['sms_otp_registration'] == 'yes') {
$otpPath .= sha1($username . $db_pass) . ".txt"; $otpPath .= sha1($phone_number . $db_pass) . ".txt";
run_hook('validate_otp'); #HOOK run_hook('validate_otp'); #HOOK
//expired 10 minutes // Expire after 10 minutes
if (file_exists($otpPath) && time() - filemtime($otpPath) > 1200) { if (file_exists($otpPath) && time() - filemtime($otpPath) > 1200) {
unlink($otpPath); unlink($otpPath);
r2(U . 'register', 's', 'Verification code expired'); r2(U . 'register', 's', 'Verification code expired');
@ -59,7 +62,7 @@ switch ($do) {
$ui->assign('fullname', $fullname); $ui->assign('fullname', $fullname);
$ui->assign('address', $address); $ui->assign('address', $address);
$ui->assign('email', $email); $ui->assign('email', $email);
$ui->assign('phonenumber', $phonenumber); $ui->assign('phone_number', $phone_number);
$ui->assign('notify', 'Wrong Verification code'); $ui->assign('notify', 'Wrong Verification code');
$ui->assign('notify_t', 'd'); $ui->assign('notify_t', 'd');
$ui->assign('_title', Lang::T('Register')); $ui->assign('_title', Lang::T('Register'));
@ -72,10 +75,13 @@ switch ($do) {
r2(U . 'register', 's', 'No Verification code'); r2(U . 'register', 's', 'No Verification code');
} }
} }
// Check if username already exists
$d = ORM::for_table('tbl_customers')->where('username', $username)->find_one(); $d = ORM::for_table('tbl_customers')->where('username', $username)->find_one();
if ($d) { if ($d) {
$msg .= Lang::T('Account already axist') . '<br>'; $msg .= Lang::T('Account already exists') . '<br>';
} }
if ($msg == '') { if ($msg == '') {
run_hook('register_user'); #HOOK run_hook('register_user'); #HOOK
$d = ORM::for_table('tbl_customers')->create(); $d = ORM::for_table('tbl_customers')->create();
@ -84,7 +90,7 @@ switch ($do) {
$d->fullname = $fullname; $d->fullname = $fullname;
$d->address = $address; $d->address = $address;
$d->email = $email; $d->email = $email;
$d->phonenumber = $phonenumber; $d->phonenumber = $phone_number;
if ($d->save()) { if ($d->save()) {
$user = $d->id(); $user = $d->id();
r2(U . 'login', 's', Lang::T('Register Success! You can login now')); r2(U . 'login', 's', Lang::T('Register Success! You can login now'));
@ -93,7 +99,7 @@ switch ($do) {
$ui->assign('fullname', $fullname); $ui->assign('fullname', $fullname);
$ui->assign('address', $address); $ui->assign('address', $address);
$ui->assign('email', $email); $ui->assign('email', $email);
$ui->assign('phonenumber', $phonenumber); $ui->assign('phone_number', $phone_number);
$ui->assign('notify', 'Failed to register'); $ui->assign('notify', 'Failed to register');
$ui->assign('notify_t', 'd'); $ui->assign('notify_t', 'd');
$ui->assign('_title', Lang::T('Register')); $ui->assign('_title', Lang::T('Register'));
@ -105,30 +111,36 @@ switch ($do) {
$ui->assign('fullname', $fullname); $ui->assign('fullname', $fullname);
$ui->assign('address', $address); $ui->assign('address', $address);
$ui->assign('email', $email); $ui->assign('email', $email);
$ui->assign('phonenumber', $phonenumber); $ui->assign('phone_number', $phone_number);
$ui->assign('notify', $msg); $ui->assign('notify', $msg);
$ui->assign('notify_t', 'd'); $ui->assign('notify_t', 'd');
$ui->assign('_title', Lang::T('Register')); $ui->assign('_title', Lang::T('Register'));
$ui->display('customer/register.tpl'); // Check if OTP is enabled
if (!empty($config['sms_url']) && $_c['sms_otp_registration'] == 'yes') {
// Display register-otp.tpl if OTP is enabled
$ui->display('customer/register-otp.tpl');
} else {
// Display register.tpl if OTP is not enabled
$ui->display('customer/register.tpl');
}
} }
break; break;
default: default:
if (!empty($config['sms_url']) && $_c['sms_otp_registration'] == 'yes') { if (!empty($config['sms_url']) && $_c['sms_otp_registration'] == 'yes') {
$username = _post('username'); $phone_number = _post('phone_number');
if (!empty($username)) { if (!empty($phone_number)) {
$d = ORM::for_table('tbl_customers')->where('username', $username)->find_one(); $d = ORM::for_table('tbl_customers')->where('username', $phone_number)->find_one();
if ($d) { if ($d) {
r2(U . 'register', 's', Lang::T('Account already axist')); r2(U . 'register', 's', Lang::T('Account already exists'));
} }
if (!file_exists($otpPath)) { if (!file_exists($otpPath)) {
mkdir($otpPath); mkdir($otpPath);
touch($otpPath . 'index.html'); touch($otpPath . 'index.html');
} }
$otpPath .= sha1($username . $db_pass) . ".txt"; $otpPath .= sha1($phone_number . $db_pass) . ".txt";
//expired 10 minutes
if (file_exists($otpPath) && time() - filemtime($otpPath) < 600) { if (file_exists($otpPath) && time() - filemtime($otpPath) < 600) {
$ui->assign('username', $username); $ui->assign('phone_number', $phone_number);
$ui->assign('notify', 'Please wait ' . (600 - (time() - filemtime($otpPath))) . ' seconds before sending another SMS'); $ui->assign('notify', 'Please wait ' . (600 - (time() - filemtime($otpPath))) . ' seconds before sending another SMS');
$ui->assign('notify_t', 'd'); $ui->assign('notify_t', 'd');
$ui->assign('_title', Lang::T('Register')); $ui->assign('_title', Lang::T('Register'));
@ -137,14 +149,14 @@ switch ($do) {
$otp = rand(100000, 999999); $otp = rand(100000, 999999);
file_put_contents($otpPath, $otp); file_put_contents($otpPath, $otp);
if($config['phone_otp_type'] == 'whatsapp'){ if($config['phone_otp_type'] == 'whatsapp'){
Message::sendWhatsapp($username, $config['CompanyName'] . "\n\n".Lang::T("Registration code")."\n$otp"); Message::sendWhatsapp($phone_number, $config['CompanyName'] . "\n\n".Lang::T("Registration code")."\n$otp");
}else if($config['phone_otp_type'] == 'both'){ }else if($config['phone_otp_type'] == 'both'){
Message::sendWhatsapp($username, $config['CompanyName'] . "\n\n".Lang::T("Registration code")."\n$otp"); Message::sendWhatsapp($phone_number, $config['CompanyName'] . "\n\n".Lang::T("Registration code")."\n$otp");
Message::sendSMS($username, $config['CompanyName'] . "\n\n".Lang::T("Registration code")."\n$otp"); Message::sendSMS($phone_number, $config['CompanyName'] . "\n\n".Lang::T("Registration code")."\n$otp");
}else{ }else{
Message::sendSMS($username, $config['CompanyName'] . "\n\n".Lang::T("Registration code")."\n$otp"); Message::sendSMS($phone_number, $config['CompanyName'] . "\n\n".Lang::T("Registration code")."\n$otp");
} }
$ui->assign('username', $username); $ui->assign('phone_number', $phone_number);
$ui->assign('notify', 'Registration code has been sent to your phone'); $ui->assign('notify', 'Registration code has been sent to your phone');
$ui->assign('notify_t', 's'); $ui->assign('notify_t', 's');
$ui->assign('_title', Lang::T('Register')); $ui->assign('_title', Lang::T('Register'));
@ -167,3 +179,5 @@ switch ($do) {
} }
break; break;
} }
?>

View File

@ -875,5 +875,8 @@
"will_be_replaced_with_Customer_password": "will be replaced with Customer password", "will_be_replaced_with_Customer_password": "will be replaced with Customer password",
"will_be_replaced_with_Customer_Portal_URL": "will be replaced with Customer Portal URL", "will_be_replaced_with_Customer_Portal_URL": "will be replaced with Customer Portal URL",
"will_be_replaced_with_Company_Name": "will be replaced with Company Name", "will_be_replaced_with_Company_Name": "will be replaced with Company Name",
"Token_has_expired__Please_log_in_again_": "Token has expired. Please log in again." "Token_has_expired__Please_log_in_again_": "Token has expired. Please log in again.",
"Minute": "Minute",
"Hour": "Hour",
"Failed_to_connect_to_device": "Failed to connect to device"
} }

View File

@ -79,7 +79,8 @@
}, function(error) {}); }, function(error) {});
} }
}; };
var Tawk_LoadStart = new Date();Tawk_API.visitor = { var Tawk_LoadStart = new Date();
Tawk_API.visitor = {
name : '{$_user['fullname']}', name : '{$_user['fullname']}',
email : '{$_user['email']}', email : '{$_user['email']}',
userId: '{$_user['id']}' userId: '{$_user['id']}'
@ -128,70 +129,69 @@
</script> </script>
{literal} {literal}
<script> <script>
var listAtts = document.querySelectorAll(`[api-get-text]`); var listAtts = document.querySelectorAll(`[api-get-text]`);
listAtts.forEach(function(el) { listAtts.forEach(function(el) {
$.get(el.getAttribute('api-get-text'), function(data) { $.get(el.getAttribute('api-get-text'), function(data) {
el.innerHTML = data; el.innerHTML = data;
});
}); });
$(document).ready(function() { });
var listAtts = document.querySelectorAll(`button[type="submit"]`); $(document).ready(function() {
listAtts.forEach(function(el) { var listAtts = document.querySelectorAll(`button[type="submit"]`);
if (el.addEventListener) { // all browsers except IE before version 9 listAtts.forEach(function(el) {
el.addEventListener("click", function() { if (el.addEventListener) { // all browsers except IE before version 9
el.addEventListener("click", function() {
$(this).html(
`<span class="loading"></span>`
);
setTimeout(() => {
$(this).prop("disabled", true);
}, 100);
}, false);
} else {
if (el.attachEvent) { // IE before version 9
el.attachEvent("click", function() {
$(this).html( $(this).html(
`<span class="loading"></span>` `<span class="loading"></span>`
); );
setTimeout(() => { setTimeout(() => {
$(this).prop("disabled", true); $(this).prop("disabled", true);
}, 100); }, 100);
}, false); });
} else {
if (el.attachEvent) { // IE before version 9
el.attachEvent("click", function() {
$(this).html(
`<span class="loading"></span>`
);
setTimeout(() => {
$(this).prop("disabled", true);
}, 100);
});
}
} }
$(function() { }
$('[data-toggle="tooltip"]').tooltip() $(function() {
}) $('[data-toggle="tooltip"]').tooltip()
}); })
}); });
});
function setCookie(name, value, days) { function setCookie(name, value, days) {
var expires = ""; var expires = "";
if (days) { if (days) {
var date = new Date(); var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString(); expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
} }
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}
function getCookie(name) { function getCookie(name) {
var nameEQ = name + "="; var nameEQ = name + "=";
var ca = document.cookie.split(';'); var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) { for (var i = 0; i < ca.length; i++) {
var c = ca[i]; var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length); while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
} }
setCookie('user_language', ' return null;
{/literal}{$user_language} }
{literal}', 365); </script>
</script> {/literal}
{/literal} <script>
setCookie('user_language', '{$user_language}', 365);
</script>
</body>
</body> </html>
</html>

View File

@ -16,12 +16,13 @@
<div class="panel-heading">1. {Lang::T('Register as Member')}</div> <div class="panel-heading">1. {Lang::T('Register as Member')}</div>
<div class="panel-body"> <div class="panel-body">
<div class="form-container"> <div class="form-container">
<!-- Phone Number Field -->
<div class="form-group"> <div class="form-group">
<label>{Lang::T('Phone Number')}</label> <label>{Lang::T('Phone Number')}</label>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon" id="basic-addon1"><i <span class="input-group-addon" id="basic-addon1"><i
class="glyphicon glyphicon-phone-alt"></i></span> class="glyphicon glyphicon-phone-alt"></i></span>
<input type="text" class="form-control" name="username" value="{$username}" <input type="text" class="form-control" name="phone_number" value="{$phone_number}" readonly
placeholder="{if $_c['country_code_phone']!= '' || $_c['registration_username'] == 'phone'}{$_c['country_code_phone']} {Lang::T('Phone Number')}{else}{Lang::T('Phone Number')}{/if}"> placeholder="{if $_c['country_code_phone']!= '' || $_c['registration_username'] == 'phone'}{$_c['country_code_phone']} {Lang::T('Phone Number')}{else}{Lang::T('Phone Number')}{/if}">
</div> </div>
</div> </div>
@ -50,9 +51,15 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<div class="panel panel-primary"> <div class="panel panel-primary">
<div class="panel-heading">2. {Lang::T('Password')}</div> <div class="panel-heading">2. {Lang::T('Username & Password')}</div>
<div class="panel-body"> <div class="panel-body">
<div class="form-container"> <div class="form-container">
<!-- Username Field -->
<div class="form-group">
<label>{Lang::T('Username')}</label>
<input type="text" required class="form-control" id="username" name="username" placeholder="{Lang::T('Choose a Username')}">
</div>
<!-- Password Fields -->
<div class="form-group"> <div class="form-group">
<label>{Lang::T('Password')}</label> <label>{Lang::T('Password')}</label>
<input type="password" required class="form-control" id="password" name="password"> <input type="password" required class="form-control" id="password" name="password">
@ -114,4 +121,5 @@
</script> </script>
<!--End of Tawk.to Script--> <!--End of Tawk.to Script-->
{/if} {/if}
{include file="customer/footer-public.tpl"} {include file="customer/footer-public.tpl"}

View File

@ -25,8 +25,8 @@
<div class="input-group"> <div class="input-group">
<span class="input-group-addon" id="basic-addon1"><i <span class="input-group-addon" id="basic-addon1"><i
class="glyphicon glyphicon-phone-alt"></i></span> class="glyphicon glyphicon-phone-alt"></i></span>
<input type="text" class="form-control" name="username" <input type="text" class="form-control" name="phone_number"
placeholder="{if $_c['country_code_phone']!= '' || $_c['registration_username'] == 'phone'}{$_c['country_code_phone']} {Lang::T('Phone Number')}{else}{Lang::T('Phone Number')}{/if}"> placeholder="{if $_c['country_code_phone']!= '' || $_c['registration_username'] == 'phone'}{$_c['country_code_phone']} {Lang::T('Phone Number')}{else}{Lang::T('Phone Number')}{/if}"inputmode="numeric" pattern="[0-9]*">
</div> </div>
</div> </div>
<div class="btn-group btn-group-justified mb15"> <div class="btn-group btn-group-justified mb15">