Merge branch 'Development'

This commit is contained in:
Ibnu Maksum
2024-08-19 16:23:28 +07:00
47 changed files with 483 additions and 231 deletions

View File

@ -18,7 +18,7 @@ switch ($action) {
case 'change-password':
run_hook('customer_view_change_password'); #HOOK
$ui->display('user-change-password.tpl');
$ui->display('user-ui/change-password.tpl');
break;
case 'change-password-post':
@ -67,16 +67,9 @@ switch ($action) {
break;
case 'profile':
$d = ORM::for_table('tbl_customers')->find_one($user['id']);
if ($d) {
run_hook('customer_view_edit_profile'); #HOOK
$ui->assign('d', $d);
$ui->display('user-profile.tpl');
} else {
r2(U . 'home', 'e', Lang::T('Account Not Found'));
}
run_hook('customer_view_edit_profile'); #HOOK
$ui->display('user-ui/profile.tpl');
break;
case 'edit-profile-post':
$fullname = _post('fullname');
$address = _post('address');
@ -84,45 +77,32 @@ switch ($action) {
$phonenumber = _post('phonenumber');
run_hook('customer_edit_profile'); #HOOK
$msg = '';
if (Validator::Length($fullname, 31, 2) == false) {
$msg .= 'Full Name should be between 3 to 30 characters' . '<br>';
if (Validator::Length($fullname, 31, 1) == false) {
$msg .= 'Full Name should be between 1 to 30 characters' . '<br>';
}
if (Validator::UnsignedNumber($phonenumber) == false) {
$msg .= 'Phone Number must be a number' . '<br>';
}
$d = ORM::for_table('tbl_customers')->find_one($user['id']);
if ($d) {
} else {
$msg .= Lang::T('Data Not Found') . '<br>';
$user->fullname = $fullname;
$user->address = $address;
if ($_c['allow_phone_otp'] != 'yes') {
$user->phonenumber = $phonenumber;
}
if ($_c['allow_email_otp'] != 'yes') {
$user->email = $email;
}
if ($msg == '') {
$d->fullname = $fullname;
$d->address = $address;
$d->email = $email;
$d->phonenumber = $phonenumber;
$d->save();
$user->save();
_log('[' . $user['username'] . ']: ' . Lang::T('User Updated Successfully'), 'User', $user['id']);
r2(U . 'accounts/profile', 's', Lang::T('User Updated Successfully'));
} else {
r2(U . 'accounts/profile', 'e', $msg);
}
_log('[' . $user['username'] . ']: ' . Lang::T('User Updated Successfully'), 'User', $user['id']);
r2(U . 'accounts/profile', 's', Lang::T('User Updated Successfully'));
break;
case 'phone-update':
$d = ORM::for_table('tbl_customers')->find_one($user['id']);
if ($d) {
//run_hook('customer_view_edit_profile'); #HOOK
$ui->assign('d', $d);
$ui->assign('new_phone', $_SESSION['new_phone']);
$ui->display('user-phone-update.tpl');
} else {
r2(U . 'home', 'e', Lang::T('Account Not Found'));
}
$ui->assign('new_phone', $_SESSION['new_phone']);
$ui->display('user-ui/phone-update.tpl');
break;
case 'phone-update-otp':
@ -131,7 +111,7 @@ switch ($action) {
$otpPath = $CACHE_PATH . '/sms/';
$_SESSION['new_phone'] = $phone;
// Validate the phone number format
if (!preg_match('/^[0-9]{10,}$/', $phone)) {
if (!preg_match('/^[0-9]{10,}$/', $phone) || empty($phone)) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Invalid phone number format'));
}
@ -139,39 +119,35 @@ switch ($action) {
r2(U . 'accounts/phone-update', 'e', Lang::T('SMS server not Available, Please try again later'));
}
if (!empty($config['sms_url'])) {
if (!empty($phone)) {
$d = ORM::for_table('tbl_customers')->where('username', $username)->where('phonenumber', $phone)->find_one();
if ($d) {
r2(U . 'accounts/phone-update', 'e', Lang::T('You cannot use your current phone number'));
}
if (!file_exists($otpPath)) {
mkdir($otpPath);
touch($otpPath . 'index.html');
}
$otpFile = $otpPath . sha1($username . $db_pass) . ".txt";
$phoneFile = $otpPath . sha1($username . $db_pass) . "_phone.txt";
$d = ORM::for_table('tbl_customers')->whereNotEqual('username', $username)->where('phonenumber', $phone)->find_one();
if ($d) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Phone number already registered by another customer'));
}
if (!file_exists($otpPath)) {
mkdir($otpPath);
touch($otpPath . 'index.html');
}
$otpFile = $otpPath . sha1($username . $db_pass) . ".txt";
$phoneFile = $otpPath . sha1($username . $db_pass) . "_phone.txt";
// expired 10 minutes
if (file_exists($otpFile) && time() - filemtime($otpFile) < 600) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Please wait ' . (600 - (time() - filemtime($otpFile))) . ' seconds before sending another SMS'));
} else {
$otp = rand(100000, 999999);
file_put_contents($otpFile, $otp);
file_put_contents($phoneFile, $phone);
// send send OTP to user
if ($config['phone_otp_type'] === 'sms') {
Message::sendSMS($phone, $config['CompanyName'] . "\n Your Verification code is: $otp");
} elseif ($config['phone_otp_type'] === 'whatsapp') {
Message::sendWhatsapp($phone, $config['CompanyName'] . "\n Your Verification code is: $otp");
} elseif ($config['phone_otp_type'] === 'both') {
Message::sendSMS($phone, $config['CompanyName'] . "\n Your Verification code is: $otp");
Message::sendWhatsapp($phone, $config['CompanyName'] . "\n Your Verification code is: $otp");
}
//redirect after sending OTP
r2(U . 'accounts/phone-update', 'e', Lang::T('Verification code has been sent to your phone'));
}
// expired 10 minutes
if (file_exists($otpFile) && time() - filemtime($otpFile) < 600) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Please wait ') . (600 - (time() - filemtime($otpFile))) . Lang::T(' seconds before sending another SMS'));
} else {
$otp = rand(100000, 999999);
file_put_contents($otpFile, $otp);
file_put_contents($phoneFile, $phone);
// send send OTP to user
if ($config['phone_otp_type'] === 'sms') {
Message::sendSMS($phone, $config['CompanyName'] . "\n Your Verification code is: $otp");
} elseif ($config['phone_otp_type'] === 'whatsapp') {
Message::sendWhatsapp($phone, $config['CompanyName'] . "\n Your Verification code is: $otp");
} elseif ($config['phone_otp_type'] === 'both') {
Message::sendSMS($phone, $config['CompanyName'] . "\n Your Verification code is: $otp");
Message::sendWhatsapp($phone, $config['CompanyName'] . "\n Your Verification code is: $otp");
}
//redirect after sending OTP
r2(U . 'accounts/phone-update', 'e', Lang::T('Verification code has been sent to your phone'));
}
break;
@ -185,60 +161,157 @@ switch ($action) {
// Validate the phone number format
if (!preg_match('/^[0-9]{10,}$/', $phone)) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Invalid phone number format'));
}
if (empty($config['sms_url'])) {
r2(U . 'accounts/phone-update', 'e', Lang::T('SMS server not Available, Please try again later'));
}
$otpFile = $otpPath . sha1($username . $db_pass) . ".txt";
$phoneFile = $otpPath . sha1($username . $db_pass) . "_phone.txt";
// Check if OTP file exists
if (!file_exists($otpFile)) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Please request OTP first'));
exit();
}
if (!empty($config['sms_url'])) {
$otpFile = $otpPath . sha1($username . $db_pass) . ".txt";
$phoneFile = $otpPath . sha1($username . $db_pass) . "_phone.txt";
// Check if OTP file exists
if (!file_exists($otpFile)) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Please request OTP first'));
exit();
}
// expired 10 minutes
if (time() - filemtime($otpFile) > 1200) {
unlink($otpFile);
unlink($phoneFile);
r2(U . 'accounts/phone-update', 'e', Lang::T('Verification code expired'));
exit();
} else {
$code = file_get_contents($otpFile);
// Check if OTP code matches
if ($code != $otp_code) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Wrong Verification code'));
exit();
}
// Check if the phone number matches the one that requested the OTP
$savedPhone = file_get_contents($phoneFile);
if ($savedPhone !== $phone) {
r2(U . 'accounts/phone-update', 'e', Lang::T('The phone number does not match the one that requested the OTP'));
exit();
}
// OTP verification successful, delete OTP and phone number files
unlink($otpFile);
unlink($phoneFile);
}
} else {
r2(U . 'accounts/phone-update', 'e', Lang::T('SMS server not available'));
// expired 10 minutes
if (time() - filemtime($otpFile) > 1200) {
unlink($otpFile);
unlink($phoneFile);
r2(U . 'accounts/phone-update', 'e', Lang::T('Verification code expired'));
exit();
} else {
$code = file_get_contents($otpFile);
// Check if OTP code matches
if ($code != $otp_code) {
r2(U . 'accounts/phone-update', 'e', Lang::T('Wrong Verification code'));
exit();
}
// Check if the phone number matches the one that requested the OTP
$savedPhone = file_get_contents($phoneFile);
if ($savedPhone !== $phone) {
r2(U . 'accounts/phone-update', 'e', Lang::T('The phone number does not match the one that requested the OTP'));
exit();
}
// OTP verification successful, delete OTP and phone number files
unlink($otpFile);
unlink($phoneFile);
}
// Update the phone number in the database
$d = ORM::for_table('tbl_customers')->where('username', $username)->find_one();
if ($d) {
$d->phonenumber = Lang::phoneFormat($phone);
$d->save();
}
$user->phonenumber = Lang::phoneFormat($phone);
$user->save();
r2(U . 'accounts/profile', 's', Lang::T('Phone number updated successfully'));
break;
case 'email-update':
$ui->assign('new_email', $_SESSION['new_email']);
$ui->display('user-ui/email-update.tpl');
break;
case 'email-update-otp':
$email = trim(_post('email'));
$username = $user['username'];
$otpPath = $CACHE_PATH . '/email/';
$_SESSION['new_email'] = $email;
// Validate the phone number format
if (!Validator::Email($email)) {
r2(U . 'accounts/email-update', 'e', Lang::T('Invalid Email address format'));
}
if (empty($config['smtp_host'])) {
r2(U . 'accounts/email-update', 'e', Lang::T('Email server not Available, Please ask admin to configure it'));
}
$d = ORM::for_table('tbl_customers')->whereNotEqual('username', $username)->where('email', $email)->find_one();
if ($d) {
r2(U . 'accounts/email-update', 'e', Lang::T('Email already used by another Customer'));
}
if (!file_exists($otpPath)) {
mkdir($otpPath);
touch($otpPath . 'index.html');
}
$otpFile = $otpPath . sha1($username . $db_pass) . ".txt";
$emailFile = $otpPath . sha1($username . $db_pass) . "_email.txt";
// expired 10 minutes
if (file_exists($otpFile) && time() - filemtime($otpFile) < 600) {
r2(U . 'accounts/email-update', 'e', Lang::T('Please wait ') . (600 - (time() - filemtime($otpFile))) . Lang::T(' seconds before sending another Email'));
} else {
$otp = rand(100000, 999999);
file_put_contents($otpFile, $otp);
file_put_contents($emailFile, $email);
// send OTP to user
$body = Lang::T("Hello") . ' ' . $user['fullname'] . ",\n\n" . Lang::T("Your Email Verification Code is:") . " $otp";
Message::sendEmail($email, Lang::T('Change Email Verification Code'), $body);
//redirect after sending OTP
r2(U . 'accounts/email-update', 'e', Lang::T('Verification code has been sent to your email. Check Spam folder if not found.'));
}
break;
case 'email-update-post':
$email = trim(_post('email'));
$otp_code = _post('otp');
$username = $user['username'];
$otpPath = $CACHE_PATH . '/email/';
// Validate the phone number format
if (!Validator::Email($email)) {
r2(U . 'accounts/email-update', 'e', Lang::T('Invalid Email address format'));
exit();
}
if (empty($config['smtp_host'])) {
r2(U . 'accounts/email-update', 'e', Lang::T('Email server not Available, Please ask admin to configure it'));
}
$otpFile = $otpPath . sha1($username . $db_pass) . ".txt";
$emailFile = $otpPath . sha1($username . $db_pass) . "_email.txt";
// Check if OTP file exists
if (!file_exists($otpFile)) {
r2(U . 'accounts/email-update', 'e', Lang::T('Please request OTP first'));
exit();
}
// expired 10 minutes
if (time() - filemtime($otpFile) > 1200) {
unlink($otpFile);
unlink($emailFile);
r2(U . 'accounts/email-update', 'e', Lang::T('Verification code expired'));
exit();
} else {
$code = file_get_contents($otpFile);
// Check if OTP code matches
if ($code != $otp_code) {
r2(U . 'accounts/email-update', 'e', Lang::T('Wrong Verification code'));
exit();
}
// Check if the phone number matches the one that requested the OTP
$savedEmail = file_get_contents($emailFile);
if ($savedEmail !== $email) {
r2(U . 'accounts/email-update', 'e', Lang::T('The Email Address does not match the one that requested the OTP'));
exit();
}
// OTP verification successful, delete OTP and phone number files
unlink($otpFile);
unlink($emailFile);
}
$user->email = $email;
$user->save();
r2(U . 'accounts/profile', 's', Lang::T('Email Address updated successfully'));
break;
case 'language-update-post':
global $root_path;
$selected_language = _req('lang', 'english');
@ -255,7 +328,7 @@ switch ($action) {
$_SESSION['Lang'] = $_L;
file_put_contents($lan_file, json_encode($_L));
}
User::setAttribute("Language", $selected_language);
r2($_SERVER['HTTP_REFERER'], 's', ucwords($selected_language));

View File

@ -440,7 +440,7 @@ switch ($action) {
// Send welcome message
if (isset($_POST['send_welcome_message']) && $_POST['send_welcome_message'] == true) {
$welcomeMessage = Lang::getNotifText('welcome_message');
$welcomeMessage = str_replace('[[company_name]]', $config['CompanyName'], $welcomeMessage);
$welcomeMessage = str_replace('[[company]]', $config['CompanyName'], $welcomeMessage);
$welcomeMessage = str_replace('[[name]]', $d['fullname'], $welcomeMessage);
$welcomeMessage = str_replace('[[username]]', $d['username'], $welcomeMessage);
$welcomeMessage = str_replace('[[password]]', $d['password'], $welcomeMessage);

View File

@ -325,4 +325,4 @@ $abills = User::getAttributes("Bill");
$ui->assign('abills', $abills);
run_hook('view_customer_dashboard'); #HOOK
$ui->display('user-dashboard.tpl');
$ui->display('user-ui/dashboard.tpl');

View File

@ -291,9 +291,9 @@ switch ($do) {
run_hook('customer_view_login'); #HOOK
if ($config['disable_registration'] == 'yes') {
$ui->assign('code', alphanumeric(_get('code'), "-"));
$ui->display('user-login-noreg.tpl');
$ui->display('user-ui/login-noreg.tpl');
} else {
$ui->display('user-login.tpl');
$ui->display('user-ui/login.tpl');
}
break;
}

View File

@ -29,7 +29,7 @@ switch ($action) {
$ui->assign('tipe', 'view');
$ui->assign('_system_menu', 'inbox');
$ui->assign('_title', Lang::T('Inbox'));
$ui->display('user-inbox.tpl');
$ui->display('user-ui/inbox.tpl');
break;
case 'delete':
if($routes['2']){
@ -57,5 +57,5 @@ switch ($action) {
$ui->assign('mails', $mails);
$ui->assign('_system_menu', 'inbox');
$ui->assign('_title', Lang::T('Inbox'));
$ui->display('user-inbox.tpl');
$ui->display('user-ui/inbox.tpl');
}

View File

@ -15,7 +15,7 @@ switch ($action) {
$ui->assign('_system_menu', 'voucher');
$ui->assign('_title', Lang::T('Order Voucher'));
run_hook('customer_view_order'); #HOOK
$ui->display('user-order.tpl');
$ui->display('user-ui/order.tpl');
break;
case 'history':
$ui->assign('_system_menu', 'history');
@ -24,7 +24,7 @@ switch ($action) {
$ui->assign('d', $d);
$ui->assign('_title', Lang::T('Order History'));
run_hook('customer_view_order_history'); #HOOK
$ui->display('user-orderHistory.tpl');
$ui->display('user-ui/orderHistory.tpl');
break;
case 'balance':
if (strpos($user['email'], '@') === false) {
@ -34,7 +34,7 @@ switch ($action) {
$ui->assign('_system_menu', 'balance');
$plans_balance = ORM::for_table('tbl_plans')->where('enabled', '1')->where('type', 'Balance')->where('prepaid', 'yes')->find_many();
$ui->assign('plans_balance', $plans_balance);
$ui->display('user-orderBalance.tpl');
$ui->display('user-ui/orderBalance.tpl');
break;
case 'package':
if (strpos($user['email'], '@') === false) {
@ -48,24 +48,71 @@ switch ($action) {
}
if (!empty($_SESSION['nux-router'])) {
if ($_SESSION['nux-router'] == 'radius') {
$radius_pppoe = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many();
$radius_hotspot = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many();
$radius_pppoe = ORM::for_table('tbl_plans')
->where('plan_type', $account_type)
->where('enabled', '1')
->where('is_radius', 1)
->where('type', 'PPPOE')
->where('prepaid', 'yes')->find_many();
$radius_hotspot = ORM::for_table('tbl_plans')
->where('plan_type', $account_type)
->where('enabled', '1')
->where('is_radius', 1)
->where('type', 'Hotspot')
->where('prepaid', 'yes')->find_many();
} else {
$routers = ORM::for_table('tbl_routers')->where('id', $_SESSION['nux-router'])->find_many();
$rs = [];
foreach ($routers as $r) {
$rs[] = $r['name'];
}
$plans_pppoe = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where_in('routers', $rs)->where('is_radius', 0)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many();
$plans_hotspot = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where_in('routers', $rs)->where('is_radius', 0)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many();
$plans_pppoe = ORM::for_table('tbl_plans')
->where('plan_type', $account_type)
->where('enabled', '1')
->where_in('routers', $rs)
->where('is_radius', 0)
->where('type', 'PPPOE')
->where('prepaid', 'yes')
->find_many();
$plans_hotspot = ORM::for_table('tbl_plans')
->where('plan_type', $account_type)
->where('enabled', '1')
->where_in('routers', $rs)
->where('is_radius', 0)
->where('type', 'Hotspot')
->where('prepaid', 'yes')
->find_many();
}
} else {
$radius_pppoe = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where('is_radius', 1)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many();
$radius_hotspot = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where('is_radius', 1)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many();
$radius_pppoe = ORM::for_table('tbl_plans')
->where('plan_type', $account_type)
->where('enabled', '1')
->where('is_radius', 1)
->where('type', 'PPPOE')
->where('prepaid', 'yes')
->find_many();
$radius_hotspot = ORM::for_table('tbl_plans')
->where('plan_type', $account_type)
->where('enabled', '1')
->where('is_radius', 1)
->where('type', 'Hotspot')
->where('prepaid', 'yes')
->find_many();
$routers = ORM::for_table('tbl_routers')->find_many();
$plans_pppoe = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where('is_radius', 0)->where('type', 'PPPOE')->where('prepaid', 'yes')->find_many();
$plans_hotspot = ORM::for_table('tbl_plans')->where('plan_type', $account_type)->where('enabled', '1')->where('is_radius', 0)->where('type', 'Hotspot')->where('prepaid', 'yes')->find_many();
$plans_pppoe = ORM::for_table('tbl_plans')
->where('plan_type', $account_type)
->where('enabled', '1')
->where('is_radius', 0)
->where('type', 'PPPOE')
->where('prepaid', 'yes')
->find_many();
$plans_hotspot = ORM::for_table('tbl_plans')
->where('plan_type', $account_type)
->where('enabled', '1')->where('is_radius', 0)
->where('type', 'Hotspot')
->where('prepaid', 'yes')
->find_many();
}
$ui->assign('routers', $routers);
$ui->assign('radius_pppoe', $radius_pppoe);
@ -73,7 +120,7 @@ switch ($action) {
$ui->assign('plans_pppoe', $plans_pppoe);
$ui->assign('plans_hotspot', $plans_hotspot);
run_hook('customer_view_order_plan'); #HOOK
$ui->display('user-orderPlan.tpl');
$ui->display('user-ui/orderPlan.tpl');
break;
case 'unpaid':
$d = ORM::for_table('tbl_payment_gateway')
@ -138,7 +185,7 @@ switch ($action) {
$ui->assign('plan', $plan);
$ui->assign('bandw', $bandw);
$ui->assign('_title', 'TRX #' . $trxid);
$ui->display('user-orderView.tpl');
$ui->display('user-ui/orderView.tpl');
break;
case 'pay':
if ($config['enable_balance'] != 'yes') {
@ -328,7 +375,7 @@ switch ($action) {
$ui->assign('router', $router_name);
$ui->assign('plan', $plan);
$ui->assign('tax', $tax);
$ui->display('user-sendPlan.tpl');
$ui->display('user-ui/sendPlan.tpl');
break;
case 'gateway':
$ui->assign('_title', Lang::T('Select Payment Gateway'));
@ -366,7 +413,7 @@ switch ($action) {
$ui->assign('add_cost', $add_cost);
$ui->assign('bills', $bills);
$ui->assign('plan', $plan);
$ui->display('user-selectGateway.tpl');
$ui->display('user-ui/selectGateway.tpl');
break;
} else {
sendTelegram("Payment Gateway not set, please set it in Settings");

View File

@ -16,6 +16,6 @@ if(file_exists(__DIR__."/../../pages/".str_replace(".","",$action).".html")){
$ui->assign("PageFile",$action);
$ui->assign("pageHeader",$action);
run_hook('customer_view_page'); #HOOK
$ui->display('user-pages.tpl');
$ui->display('user-ui/pages.tpl');
}else
$ui->display('404.tpl');
$ui->display('user-ui/404.tpl');

View File

@ -17,7 +17,7 @@ if (strpos($action, "-reset") !== false) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
}
$action = str_replace("-reset", "", $action);
$path = $PAGES_PATH . "/" . str_replace(".", "", $action) . ".html";
$path = "$PAGES_PATH/" . str_replace(".", "", $action) . ".html";
$temp = "pages_template/" . str_replace(".", "", $action) . ".html";
if (file_exists($temp)) {
if (!copy($temp, $path)) {
@ -31,7 +31,7 @@ if (strpos($action, "-reset") !== false) {
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
}
$path = $PAGES_PATH . "/" . str_replace(".", "", $action) . ".html";
$path = "$PAGES_PATH/" . str_replace(".", "", $action) . ".html";
$ui->assign("action", $action);
//echo $path;
run_hook('view_edit_pages'); #HOOK
@ -47,13 +47,13 @@ if (strpos($action, "-reset") !== false) {
}
if (file_exists($path)) {
if ($action == 'Voucher') {
if (!file_exists($PAGES_PATH . "/vouchers/")) {
mkdir($PAGES_PATH . "/vouchers/");
if (!file_exists("$PAGES_PATH/vouchers/")) {
mkdir("$PAGES_PATH/vouchers/");
if (file_exists("pages_template/vouchers/")) {
File::copyFolder("pages_template/vouchers/", $PAGES_PATH . "/vouchers/");
File::copyFolder("pages_template/vouchers/", "$PAGES_PATH/vouchers/");
}
}
$ui->assign("vouchers", scandir($PAGES_PATH . "/vouchers/"));
$ui->assign("vouchers", scandir("$PAGES_PATH/vouchers/"));
}
$html = file_get_contents($path);
$ui->assign("htmls", str_replace(["<div", "</div>"], "", $html));
@ -68,14 +68,14 @@ if (strpos($action, "-reset") !== false) {
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
}
$action = str_replace("-post", "", $action);
$path = $PAGES_PATH . "/" . str_replace(".", "", $action) . ".html";
$path = "$PAGES_PATH/" . str_replace(".", "", $action) . ".html";
if (file_exists($path)) {
$html = _post("html");
run_hook('save_pages'); #HOOK
if (file_put_contents($path, $html)) {
if (_post('template_save') == 'yes') {
if (!empty(_post('template_name'))) {
file_put_contents($PAGES_PATH . "/vouchers/" . _post('template_name') . '.html', $html);
file_put_contents("$PAGES_PATH/vouchers/" . _post('template_name') . '.html', $html);
}
}
r2(U . 'pages/' . $action, 's', Lang::T("Saving page success"));

View File

@ -22,7 +22,7 @@ switch ($do) {
$password = _post('password');
$cpassword = _post('cpassword');
$address = _post('address');
if (!empty($config['sms_url'])) {
if (!empty($config['sms_url']) && $_c['allow_phone_otp'] == 'yes') {
$phonenumber = Lang::phoneFormat($username);
$username = $phonenumber;
} else if (strlen($username) < 21) {
@ -45,7 +45,7 @@ switch ($do) {
$msg .= Lang::T('Passwords does not match') . '<br>';
}
if (!empty($config['sms_url'])) {
if (!empty($config['sms_url']) && $_c['allow_phone_otp'] == 'yes') {
$otpPath .= sha1($username . $db_pass) . ".txt";
run_hook('validate_otp'); #HOOK
//expired 10 minutes
@ -62,7 +62,7 @@ switch ($do) {
$ui->assign('phonenumber', $phonenumber);
$ui->assign('notify', 'Wrong Verification code');
$ui->assign('notify_t', 'd');
$ui->display('register-otp.tpl');
$ui->display('user-ui/register-otp.tpl');
exit();
} else {
unlink($otpPath);
@ -96,7 +96,7 @@ switch ($do) {
$ui->assign('notify', 'Failed to register');
$ui->assign('notify_t', 'd');
run_hook('view_otp_register'); #HOOK
$ui->display('register-rotp.tpl');
$ui->display('user-ui/register-rotp.tpl');
}
} else {
$ui->assign('username', $username);
@ -106,12 +106,12 @@ switch ($do) {
$ui->assign('phonenumber', $phonenumber);
$ui->assign('notify', $msg);
$ui->assign('notify_t', 'd');
$ui->display('register.tpl');
$ui->display('user-ui/register.tpl');
}
break;
default:
if (!empty($config['sms_url'])) {
if (!empty($config['sms_url']) && $_c['allow_phone_otp'] == 'yes') {
$username = _post('username');
if (!empty($username)) {
$d = ORM::for_table('tbl_customers')->where('username', $username)->find_one();
@ -128,7 +128,7 @@ switch ($do) {
$ui->assign('username', $username);
$ui->assign('notify', 'Please wait ' . (600 - (time() - filemtime($otpPath))) . ' seconds before sending another SMS');
$ui->assign('notify_t', 'd');
$ui->display('register-otp.tpl');
$ui->display('user-ui/register-otp.tpl');
} else {
$otp = rand(100000, 999999);
file_put_contents($otpPath, $otp);
@ -136,11 +136,11 @@ switch ($do) {
$ui->assign('username', $username);
$ui->assign('notify', 'Verification code has been sent to your phone');
$ui->assign('notify_t', 's');
$ui->display('register-otp.tpl');
$ui->display('user-ui/register-otp.tpl');
}
} else {
run_hook('view_otp_register'); #HOOK
$ui->display('register-rotp.tpl');
$ui->display('user-ui/register-rotp.tpl');
}
} else {
$ui->assign('username', "");
@ -149,7 +149,7 @@ switch ($do) {
$ui->assign('email', "");
$ui->assign('otp', false);
run_hook('view_register'); #HOOK
$ui->display('register.tpl');
$ui->display('user-ui/register.tpl');
}
break;
}

View File

@ -17,7 +17,7 @@ switch ($action) {
case 'activation':
run_hook('view_activate_voucher'); #HOOK
$ui->assign('code', alphanumeric(_get('code'), "-_.,"));
$ui->display('user-activation.tpl');
$ui->display('user-ui/activation.tpl');
break;
case 'activation-post':
@ -46,7 +46,7 @@ switch ($action) {
$ui->assign('d', $d);
run_hook('customer_view_activation_list'); #HOOK
$ui->display('user-activation-list.tpl');
$ui->display('user-ui/activation-list.tpl');
break;
case 'invoice':
@ -58,7 +58,7 @@ switch ($action) {
}
if ($in) {
Package::createInvoice($in);
$ui->display('invoice-customer.tpl');
$ui->display('user-ui/invoice-customer.tpl');
} else {
r2(U . 'voucher/list-activated', 'e', Lang::T('Not Found'));
}