Disable Registration

This commit is contained in:
Ibnu Maksum 2023-12-19 11:35:49 +07:00
parent 017518b308
commit 13b448da69
No known key found for this signature in database
GPG key ID: 7FC82848810579E5
5 changed files with 223 additions and 253 deletions

View file

@ -42,8 +42,97 @@ switch ($do) {
break; break;
case 'activation':
$voucher = _post('voucher');
$username = _post('username');
$v1 = ORM::for_table('tbl_voucher')->where('code', $voucher)->find_one();
if ($v1) {
// coucher exists, check customer exists or not
$user = ORM::for_table('tbl_customers')->where('username', $username)->find_one();
if (!$user) {
$d = ORM::for_table('tbl_customers')->create();
$d->username = alphanumeric($username, "+_.");
$d->password = $voucher;
$d->fullname = '';
$d->address = '';
$d->email = '';
$d->phonenumber = (strlen($username) < 21) ? $username : '';
if ($d->save()) {
$user = ORM::for_table('tbl_customers')->where('username', $username)->find_one($d->id());
if (!$user) {
r2(U . 'login', 'e', Lang::T('Voucher activation failed'));
}
} else {
r2(U . 'login', 'e', Lang::T('Voucher activation failed').'.');
}
}
if ($v1['status'] == 0) {
$oldPass = $user['password'];
// change customer password to voucher code
$user->password = $voucher;
$user->save();
// voucher activation
if (Package::rechargeUser($user['id'], $v1['routers'], $v1['id_plan'], "Activation", "Voucher")) {
$v1->status = "1";
$v1->user = $user['username'];
$v1->save();
// add customer to mikrotik
if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) {
$m = Mikrotik::info($v1['routers']);
$c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
Mikrotik::logMeIn($c, $user['username'], $user['password'], $_SESSION['nux-ip'], $_SESSION['nux-mac']);
if(!empty($config['voucher_redirect'])){
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, you are connected to internet"));
}else{
r2(U . "login", 's', Lang::T("Voucher activation success, you are connected to internet"));
}
}
if(!empty($config['voucher_redirect'])){
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login"));
}else{
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login"));
}
} else {
// if failed to recharge, restore old password
$user->password = $oldPass;
$user->save();
r2(U . 'login', 'e', Lang::T("Failed to activate voucher"));
}
} else {
// used voucher
// check if voucher used by this username
if ($v1['user'] == $user['username']) {
if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) {
$m = Mikrotik::info($v1['routers']);
$c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
Mikrotik::logMeIn($c, $user['username'], $user['password'], $_SESSION['nux-ip'], $_SESSION['nux-mac']);
if(!empty($config['voucher_redirect'])){
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, you are connected to internet"));
}else{
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login"));
}
}else{
if(!empty($config['voucher_redirect'])){
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, you are connected to internet"));
}else{
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login"));
}
}
} else {
// voucher used by other customer
r2(U . 'login', 'e', $_L['Voucher_Not_Valid']);
}
}
} else {
// voucher not found
r2(U . 'login', 'e', $_L['Voucher_Not_Valid']);
}
default: default:
run_hook('customer_view_login'); #HOOK run_hook('customer_view_login'); #HOOK
$ui->display('user-login.tpl'); if($config['disable_registration']=='yes'){
$ui->display('user-login-noreg.tpl');
}else{
$ui->display('user-login.tpl');
}
break; break;
} }

View file

@ -243,27 +243,7 @@ switch ($action) {
break; break;
case 'app-post': case 'app-post':
$company = _post('company'); $company = _post('CompanyName');
$footer = _post('footer');
$enable_balance = _post('enable_balance');
$allow_balance_transfer = _post('allow_balance_transfer');
$disable_voucher = _post('disable_voucher');
$telegram_bot = _post('telegram_bot');
$telegram_target_id = _post('telegram_target_id');
$sms_url = _post('sms_url');
$wa_url = _post('wa_url');
$minimum_transfer = _post('minimum_transfer');
$user_notification_expired = _post('user_notification_expired');
$user_notification_reminder = _post('user_notification_reminder');
$user_notification_payment = _post('user_notification_payment');
$address = _post('address');
$tawkto = _post('tawkto');
$http_proxy = _post('http_proxy');
$http_proxyauth = _post('http_proxyauth');
$radius_enable = _post('radius_enable');
$radius_client = _post('radius_client');
$theme = _post('theme');
$voucher_format = _post('voucher_format');
run_hook('save_settings'); #HOOK run_hook('save_settings'); #HOOK
@ -279,206 +259,6 @@ switch ($action) {
if ($company == '') { if ($company == '') {
r2(U . 'settings/app', 'e', $_L['All_field_is_required']); r2(U . 'settings/app', 'e', $_L['All_field_is_required']);
} else { } else {
$d = ORM::for_table('tbl_appconfig')->where('setting', 'CompanyName')->find_one();
$d->value = $company;
$d->save();
$d = ORM::for_table('tbl_appconfig')->where('setting', 'address')->find_one();
$d->value = $address;
$d->save();
$phone = _post('phone');
$d = ORM::for_table('tbl_appconfig')->where('setting', 'phone')->find_one();
$d->value = $phone;
$d->save();
$d = ORM::for_table('tbl_appconfig')->where('setting', 'http_proxy')->find_one();
if ($d) {
$d->value = $http_proxy;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'http_proxy';
$d->value = $http_proxy;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'http_proxyauth')->find_one();
if ($d) {
$d->value = $http_proxyauth;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'http_proxyauth';
$d->value = $http_proxyauth;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'theme')->find_one();
if ($d) {
$d->value = $theme;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'theme';
$d->value = $theme;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'CompanyFooter')->find_one();
if ($d) {
$d->value = $footer;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'CompanyFooter';
$d->value = $footer;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'voucher_format')->find_one();
if ($d) {
$d->value = $voucher_format;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'voucher_format';
$d->value = $voucher_format;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'disable_voucher')->find_one();
if ($d) {
$d->value = $disable_voucher;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'disable_voucher';
$d->value = $disable_voucher;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'enable_balance')->find_one();
if ($d) {
$d->value = $enable_balance;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'enable_balance';
$d->value = $enable_balance;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'allow_balance_transfer')->find_one();
if ($d) {
$d->value = $allow_balance_transfer;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'allow_balance_transfer';
$d->value = $allow_balance_transfer;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'minimum_transfer')->find_one();
if ($d) {
$d->value = $minimum_transfer;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'minimum_transfer';
$d->value = $minimum_transfer;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'telegram_bot')->find_one();
if ($d) {
$d->value = $telegram_bot;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'telegram_bot';
$d->value = $telegram_bot;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'telegram_target_id')->find_one();
if ($d) {
$d->value = $telegram_target_id;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'telegram_target_id';
$d->value = $telegram_target_id;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'sms_url')->find_one();
if ($d) {
$d->value = $sms_url;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'sms_url';
$d->value = $sms_url;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'wa_url')->find_one();
if ($d) {
$d->value = $wa_url;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'wa_url';
$d->value = $wa_url;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'user_notification_expired')->find_one();
if ($d) {
$d->value = $user_notification_expired;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'user_notification_expired';
$d->value = $user_notification_expired;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'user_notification_reminder')->find_one();
if ($d) {
$d->value = $user_notification_reminder;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'user_notification_reminder';
$d->value = $user_notification_reminder;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'user_notification_payment')->find_one();
if ($d) {
$d->value = $user_notification_payment;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'user_notification_payment';
$d->value = $user_notification_payment;
$d->save();
}
$d = ORM::for_table('tbl_appconfig')->where('setting', 'tawkto')->find_one();
if ($d) {
$d->value = $tawkto;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'tawkto';
$d->value = $tawkto;
$d->save();
}
if ($radius_enable) { if ($radius_enable) {
try { try {
Radius::getTableNas()->find_many(); Radius::getTableNas()->find_many();
@ -491,34 +271,20 @@ switch ($action) {
die(); die();
} }
} }
// save all settings
$d = ORM::for_table('tbl_appconfig')->where('setting', 'radius_enable')->find_one(); foreach($_POST as $key => $value) {
if ($d) { $d = ORM::for_table('tbl_appconfig')->where('setting', $key)->find_one();
$d->value = $radius_enable; if ($d) {
$d->save(); $d->value = $value;
} else { $d->save();
$d = ORM::for_table('tbl_appconfig')->create(); } else {
$d->setting = 'radius_enable'; $d = ORM::for_table('tbl_appconfig')->create();
$d->value = $radius_enable; $d->setting = $key;
$d->save(); $d->value = $value;
$d->save();
}
} }
$d = ORM::for_table('tbl_appconfig')->where('setting', 'radius_client')->find_one();
if ($d) {
$d->value = $radius_client;
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'radius_client';
$d->value = $radius_client;
$d->save();
}
$note = _post('note');
$d = ORM::for_table('tbl_appconfig')->where('setting', 'note')->find_one();
$d->value = $note;
$d->save();
_log('[' . $admin['username'] . ']: ' . $_L['Settings_Saved_Successfully'], 'Admin', $admin['id']); _log('[' . $admin['username'] . ']: ' . $_L['Settings_Saved_Successfully'], 'Admin', $admin['id']);
r2(U . 'settings/app', 's', $_L['Settings_Saved_Successfully']); r2(U . 'settings/app', 's', $_L['Settings_Saved_Successfully']);

View file

@ -413,3 +413,7 @@ $_L['Service_Type'] = 'Service Type';
$_L['Others'] = 'Others'; $_L['Others'] = 'Others';
$_L['PPPoE'] = 'PPPoE'; $_L['PPPoE'] = 'PPPoE';
$_L['Hotspot'] = 'Hotspot'; $_L['Hotspot'] = 'Hotspot';
$_L['Disable_Registration'] = 'Disable Registration';
$_L['Customer_just_Login_with_Phone_number_and_Voucher_Code_Voucher_will_be_password'] = 'Customer just Login with Phone number and Voucher Code, Voucher will be password';
$_L['Login__Activate_Voucher'] = 'Login / Activate Voucher';
$_L['After_Customer_activate_voucher_or_login_customer_will_be_redirected_to_this_url'] = 'After Customer activate voucher or login, customer will be redirected to this url';

View file

@ -15,7 +15,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{$_L['App_Name']}</label> <label class="col-md-2 control-label">{$_L['App_Name']}</label>
<div class="col-md-6"> <div class="col-md-6">
<input type="text" required class="form-control" id="company" name="company" <input type="text" required class="form-control" id="CompanyName" name="CompanyName"
value="{$_c['CompanyName']}"> value="{$_c['CompanyName']}">
</div> </div>
<span class="help-block col-md-4">{$_L['App_Name_Help_Text']}</span> <span class="help-block col-md-4">{$_L['App_Name_Help_Text']}</span>
@ -34,7 +34,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Company Footer')}</label> <label class="col-md-2 control-label">{Lang::T('Company Footer')}</label>
<div class="col-md-6"> <div class="col-md-6">
<input type="text" required class="form-control" id="footer" name="footer" <input type="text" required class="form-control" id="CompanyFooter" name="CompanyFooter"
value="{$_c['CompanyFooter']}"> value="{$_c['CompanyFooter']}">
</div> </div>
<span class="help-block col-md-4">{Lang::T('Will show below user pages')}</span> <span class="help-block col-md-4">{Lang::T('Will show below user pages')}</span>
@ -113,6 +113,33 @@
</div> </div>
<p class="help-block col-md-4">UPPERCASE lowercase RaNdoM</p> <p class="help-block col-md-4">UPPERCASE lowercase RaNdoM</p>
</div> </div>
{if $_c['disable_voucher'] != 'yes'}
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Disable Registration')}</label>
<div class="col-md-6">
<select name="disable_registration" id="disable_registration" class="form-control">
<option value="no" {if $_c['disable_registration'] == 'no'}selected="selected" {/if}>No
</option>
<option value="yes" {if $_c['disable_registration'] == 'yes'}selected="selected" {/if}>
Yes
</option>
</select>
</div>
<p class="help-block col-md-4">
{Lang::T('Customer just Login with Phone number and Voucher Code, Voucher will be password')}
</p>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Redirect after Activation</label>
<div class="col-md-6">
<input type="text" class="form-control" id="voucher_redirect" name="voucher_redirect"
placeholder="https://192.168.88.1/status" value="{$voucher_redirect}">
</div>
<p class="help-block col-md-4">
{Lang::T('After Customer activate voucher or login, customer will be redirected to this url')}
</p>
</div>
{/if}
</div> </div>
<div class="panel-heading"> <div class="panel-heading">
<div class="btn-group pull-right"> <div class="btn-group pull-right">
@ -198,7 +225,7 @@
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">Telegram Target ID</label> <label class="col-md-2 control-label">Telegram User/Channel/Group ID</label>
<div class="col-md-6"> <div class="col-md-6">
<input type="text" class="form-control" id="telegram_target_id" name="telegram_target_id" <input type="text" class="form-control" id="telegram_target_id" name="telegram_target_id"
value="{$_c['telegram_target_id']}" placeholder="12345678"> value="{$_c['telegram_target_id']}" placeholder="12345678">
@ -228,10 +255,12 @@
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">Or use Mikrotik SMS</label> <label class="col-md-2 control-label">Or use Mikrotik SMS</label>
<div class="col-md-6"> <div class="col-md-6">
<select class="form-control" onchange="document.getElementById('sms_url').value = this.value"> <select class="form-control"
onchange="document.getElementById('sms_url').value = this.value">
<option value="">Select Router</option> <option value="">Select Router</option>
{foreach $r as $rs} {foreach $r as $rs}
<option value="{$rs['name']}" {if $rs['name']==$_c['sms_url']}selected{/if}>{$rs['name']}</option> <option value="{$rs['name']}" {if $rs['name']==$_c['sms_url']}selected{/if}>
{$rs['name']}</option>
{/foreach} {/foreach}
</select> </select>
</div> </div>

View file

@ -0,0 +1,82 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>{$_title} - {$_L['Login']}</title>
<link rel="shortcut icon" href="ui/ui/images/logo.png" type="image/x-icon" />
<link rel="stylesheet" href="ui/ui/styles/bootstrap.min.css">
<link rel="stylesheet" href="ui/ui/styles/adminlte.min.css">
</head>
<body>
<div class="container">
<div class="hidden-xs" style="height:150px"></div>
<div class="form-head mb20">
<h1 class="site-logo h2 mb5 mt5 text-center text-uppercase text-bold"
style="text-shadow: 2px 2px 4px #757575;">{$_c['CompanyName']}</h1>
<hr>
</div>
{if isset($notify)}
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
{$notify}
</div>
</div>
{/if}
<div class="row">
<div class="col-sm-8">
<div class="panel panel-info">
<div class="panel-heading">{$_L['Announcement']}</div>
<div class="panel-body">
{include file="$_path/../pages/Announcement.html"}
</div>
</div>
</div>
<div class="col-sm-4">
<div class="panel panel-primary">
<div class="panel-heading">{Lang::T('Login / Activate Voucher')}</div>
<div class="panel-body">
<form action="{$_url}login/activation" method="post">
<div class="form-group">
<label>{$_L['Phone_Number']}</label>
<div class="input-group">
{if $_c['country_code_phone']!= ''}
<span class="input-group-addon" id="basic-addon1">+</span>
{else}
<span class="input-group-addon" id="basic-addon1"><i
class="glyphicon glyphicon-phone-alt"></i></span>
{/if}
<input type="text" class="form-control" name="username" required
placeholder="08xxxxxxx">
</div>
</div>
<div class="form-group">
<label>{$_L['Enter_Voucher_Code']}</label>
<input type="text" class="form-control" name="voucher" required autocomplete="off"
placeholder="{$_L['Code_Voucher']}">
</div>
<div class="btn-group btn-group-justified mb15">
<div class="btn-group">
<button type="submit" class="btn btn-primary">{Lang::T('Login / Activate Voucher')}</button>
</div>
</div>
<br>
<center>
<a href="./pages/Privacy_Policy.html" target="_blank">Privacy</a>
&bull;
<a href="./pages/Terms_of_Conditions.html" target="_blank">ToC</a>
</center>
</form>
</div>
</div>
</div>
</div>
</div>
<script src="ui/ui/scripts/vendors.js"></script>
</body>
</html>