diff --git a/system/controllers/default.php b/system/controllers/default.php new file mode 100644 index 0000000..d32f8ce --- /dev/null +++ b/system/controllers/default.php @@ -0,0 +1,13 @@ +assign('_title', Lang::T('Reports')); +$ui->assign('_sysfrm_menu', 'reports'); + +$action = $routes['1']; +$ui->assign('_admin', $admin); + +$mdate = date('Y-m-d'); +$tdate = date('Y-m-d', strtotime('today - 30 days')); + +//first day of month +$first_day_month = date('Y-m-01'); +// +$this_week_start = date('Y-m-d', strtotime('previous sunday')); +// 30 days before +$before_30_days = date('Y-m-d', strtotime('today - 30 days')); +//this month +$month_n = date('n'); + +switch ($action) { + + case 'print-by-date': + $mdate = date('Y-m-d'); + $d = ORM::for_table('tbl_transactions'); + $d->where('recharged_on', $mdate); + $d->order_by_desc('id'); + $x = $d->find_many(); + + $dr = ORM::for_table('tbl_transactions'); + $dr->where('recharged_on', $mdate); + $dr->order_by_desc('id'); + $xy = $dr->sum('price'); + + $ui->assign('d', $x); + $ui->assign('dr', $xy); + $ui->assign('mdate', $mdate); + $ui->assign('recharged_on', $mdate); + run_hook('print_by_date'); #HOOK + $ui->display('print-by-date.tpl'); + break; + + case 'pdf-by-date': + $mdate = date('Y-m-d'); + + $d = ORM::for_table('tbl_transactions'); + $d->where('recharged_on', $mdate); + $d->order_by_desc('id'); + $x = $d->find_many(); + + $dr = ORM::for_table('tbl_transactions'); + $dr->where('recharged_on', $mdate); + $dr->order_by_desc('id'); + $xy = $dr->sum('price'); + + $title = ' Reports [' . $mdate . ']'; + $title = str_replace('-', ' ', $title); + + $UPLOAD_URL_PATH = str_replace($root_path, '', $UPLOAD_PATH); + if (file_exists($UPLOAD_PATH . '/logo.png')) { + $logo = $UPLOAD_URL_PATH . '/logo.png'; + } else { + $logo = $UPLOAD_URL_PATH . '/logo.default.png'; + } + + if ($x) { + $html = ' +
+
+

' . $config['CompanyName'] . '

+ ' . $config['address'] . '
+ ' . Lang::T('Phone Number') . ': ' . $config['phone'] . '
+
+ +
+ + + + + + + + + + + + '; + $c = true; + foreach ($x as $value) { + + $username = $value['username']; + $plan_name = $value['plan_name']; + $type = $value['type']; + $price = $config['currency_code'] . ' ' . number_format($value['price'], 0, $config['dec_point'], $config['thousands_sep']); + $recharged_on = date($config['date_format'], strtotime($value['recharged_on'])); + $expiration = date($config['date_format'], strtotime($value['expiration'])); + $time = $value['time']; + $method = $value['method']; + $routers = $value['routers']; + + $html .= "" . " + + + + + + + + + "; + } + $html .= '
' . Lang::T('Username') . '' . Lang::T('Plan Name') . '' . Lang::T('Type') . '' . Lang::T('Plan Price') . '' . Lang::T('Created On') . '' . Lang::T('Expires On') . '' . Lang::T('Method') . '' . Lang::T('Routers') . '
$username$plan_name$type$price$recharged_on$expiration $time $method$routers
+

' . Lang::T('Total Income') . ':

+

' . $config['currency_code'] . ' ' . number_format($xy, 2, $config['dec_point'], $config['thousands_sep']) . '

'; + run_hook('print_pdf_by_date'); #HOOK + + $mpdf = new \Mpdf\Mpdf(); + $mpdf->SetProtection(array('print')); + $mpdf->SetTitle($config['CompanyName'] . ' Reports'); + $mpdf->SetAuthor($config['CompanyName']); + $mpdf->SetWatermarkText($d['price']); + $mpdf->showWatermarkText = true; + $mpdf->watermark_font = 'Helvetica'; + $mpdf->watermarkTextAlpha = 0.1; + $mpdf->SetDisplayMode('fullpage'); + + $style = ''; + + $nhtml = <<WriteHTML($nhtml); + $mpdf->Output(date('Ymd_His') . '.pdf', 'D'); + } else { + echo 'No Data'; + } + + break; + + case 'print-by-period': + $fdate = _post('fdate'); + $tdate = _post('tdate'); + $stype = _post('stype'); + + $d = ORM::for_table('tbl_transactions'); + if ($stype != '') { + $d->where('type', $stype); + } + $d->where_gte('recharged_on', $fdate); + $d->where_lte('recharged_on', $tdate); + $d->order_by_desc('id'); + $x = $d->find_many(); + + $dr = ORM::for_table('tbl_transactions'); + if ($stype != '') { + $dr->where('type', $stype); + } + + $dr->where_gte('recharged_on', $fdate); + $dr->where_lte('recharged_on', $tdate); + $xy = $dr->sum('price'); + + $ui->assign('d', $x); + $ui->assign('dr', $xy); + $ui->assign('fdate', $fdate); + $ui->assign('tdate', $tdate); + $ui->assign('stype', $stype); + run_hook('print_by_period'); #HOOK + $ui->display('print-by-period.tpl'); + break; + + + case 'pdf-by-period': + $fdate = _post('fdate'); + $tdate = _post('tdate'); + $stype = _post('stype'); + $d = ORM::for_table('tbl_transactions'); + if ($stype != '') { + $d->where('type', $stype); + } + + $d->where_gte('recharged_on', $fdate); + $d->where_lte('recharged_on', $tdate); + $d->order_by_desc('id'); + $x = $d->find_many(); + + $dr = ORM::for_table('tbl_transactions'); + if ($stype != '') { + $dr->where('type', $stype); + } + + $dr->where_gte('recharged_on', $fdate); + $dr->where_lte('recharged_on', $tdate); + $xy = $dr->sum('price'); + + $title = ' Reports [' . $mdate . ']'; + $title = str_replace('-', ' ', $title); + + $UPLOAD_URL_PATH = str_replace($root_path, '', $UPLOAD_PATH); + if (file_exists($UPLOAD_PATH . '/logo.png')) { + $logo = $UPLOAD_URL_PATH . '/logo.png'; + } else { + $logo = $UPLOAD_URL_PATH . '/logo.default.png'; + } + + if ($x) { + $html = ' +
+
+

' . $config['CompanyName'] . '

+ ' . $config['address'] . '
+ ' . Lang::T('Phone Number') . ': ' . $config['phone'] . '
+
+ +
+ + + + + + + + + + + + '; + $c = true; + foreach ($x as $value) { + + $username = $value['username']; + $plan_name = $value['plan_name']; + $type = $value['type']; + $price = $config['currency_code'] . ' ' . number_format($value['price'], 0, $config['dec_point'], $config['thousands_sep']); + $recharged_on = date($config['date_format'], strtotime($value['recharged_on'])); + $expiration = date($config['date_format'], strtotime($value['expiration'])); + $time = $value['time']; + $method = $value['method']; + $routers = $value['routers']; + + $html .= "" . " + + + + + + + + + "; + } + $html .= '
' . Lang::T('Username') . '' . Lang::T('Plan Name') . '' . Lang::T('Type') . '' . Lang::T('Plan Price') . '' . Lang::T('Created On') . '' . Lang::T('Expires On') . '' . Lang::T('Method') . '' . Lang::T('Routers') . '
$username$plan_name$type$price$recharged_on $expiration $time $method$routers
+

' . Lang::T('Total Income') . ':

+

' . $config['currency_code'] . ' ' . number_format($xy, 2, $config['dec_point'], $config['thousands_sep']) . '

'; + + run_hook('pdf_by_period'); #HOOK + $mpdf = new \Mpdf\Mpdf(); + $mpdf->SetProtection(array('print')); + $mpdf->SetTitle($config['CompanyName'] . ' Reports'); + $mpdf->SetAuthor($config['CompanyName']); + $mpdf->SetWatermarkText($d['price']); + $mpdf->showWatermarkText = true; + $mpdf->watermark_font = 'Helvetica'; + $mpdf->watermarkTextAlpha = 0.1; + $mpdf->SetDisplayMode('fullpage'); + + $style = ''; + + $nhtml = <<WriteHTML($nhtml); + $mpdf->Output(date('Ymd_His') . '.pdf', 'D'); + } else { + echo 'No Data'; + } + + break; + + default: + $ui->display('a404.tpl'); +} diff --git a/system/controllers/home.php b/system/controllers/home.php new file mode 100644 index 0000000..7640d05 --- /dev/null +++ b/system/controllers/home.php @@ -0,0 +1,252 @@ +assign('_title', Lang::T('Dashboard')); + +$user = User::_info(); +$ui->assign('_user', $user); + +if (isset($_GET['renewal'])) { + $user->auto_renewal = $_GET['renewal']; + $user->save(); +} + +if (_post('send') == 'balance') { + if ($config['enable_balance'] == 'yes' && $config['allow_balance_transfer'] == 'yes') { + if ($user['status'] != 'Active') { + _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); + } + $target = ORM::for_table('tbl_customers')->where('username', _post('username'))->find_one(); + if (!$target) { + r2(U . 'home', 'd', Lang::T('Username not found')); + } + $username = _post('username'); + $balance = _post('balance'); + if ($user['balance'] < $balance) { + r2(U . 'home', 'd', Lang::T('insufficient balance')); + } + if (!empty($config['minimum_transfer']) && intval($balance) < intval($config['minimum_transfer'])) { + r2(U . 'home', 'd', Lang::T('Minimum Transfer') . ' ' . Lang::moneyFormat($config['minimum_transfer'])); + } + if ($user['username'] == $target['username']) { + r2(U . 'home', 'd', Lang::T('Cannot send to yourself')); + } + if (Balance::transfer($user['id'], $username, $balance)) { + //sender + $d = ORM::for_table('tbl_payment_gateway')->create(); + $d->username = $user['username']; + $d->gateway = $target['username']; + $d->plan_id = 0; + $d->plan_name = 'Send Balance'; + $d->routers_id = 0; + $d->routers = 'balance'; + $d->price = $balance; + $d->payment_method = "Customer"; + $d->payment_channel = "Balance"; + $d->created_date = date('Y-m-d H:i:s'); + $d->paid_date = date('Y-m-d H:i:s'); + $d->expired_date = date('Y-m-d H:i:s'); + $d->pg_url_payment = 'balance'; + $d->status = 2; + $d->save(); + //receiver + $d = ORM::for_table('tbl_payment_gateway')->create(); + $d->username = $target['username']; + $d->gateway = $user['username']; + $d->plan_id = 0; + $d->plan_name = 'Receive Balance'; + $d->routers_id = 0; + $d->routers = 'balance'; + $d->payment_method = "Customer"; + $d->payment_channel = "Balance"; + $d->price = $balance; + $d->created_date = date('Y-m-d H:i:s'); + $d->paid_date = date('Y-m-d H:i:s'); + $d->expired_date = date('Y-m-d H:i:s'); + $d->pg_url_payment = 'balance'; + $d->status = 2; + $d->save(); + Message::sendBalanceNotification($user['phonenumber'], $target['fullname'] . ' (' . $target['username'] . ')', $balance, ($user['balance'] - $balance), Lang::getNotifText('balance_send'), $config['user_notification_payment']); + Message::sendBalanceNotification($target['phonenumber'], $user['fullname'] . ' (' . $user['username'] . ')', $balance, ($target['balance'] + $balance), Lang::getNotifText('balance_received'), $config['user_notification_payment']); + Message::sendTelegram("#u$user[username] send balance to #u$target[username] \n" . Lang::moneyFormat($balance)); + r2(U . 'home', 's', Lang::T('Sending balance success')); + } + } else { + r2(U . 'home', 'd', Lang::T('Failed, balance is not available')); + } +} else if (_post('send') == 'plan') { + if ($user['status'] != 'Active') { + _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); + } + $actives = ORM::for_table('tbl_user_recharges') + ->where('username', _post('username')) + ->find_many(); + foreach ($actives as $active) { + $router = ORM::for_table('tbl_routers')->where('name', $active['routers'])->find_one(); + if ($router) { + r2(U . "order/send/$router[id]/$active[plan_id]&u=" . trim(_post('username')), 's', Lang::T('Review package before recharge')); + } + } + r2(U . 'home', 'w', Lang::T('Your friend do not have active package')); +} + +$ui->assign('_bills', User::_billing()); + +if (isset($_GET['recharge']) && !empty($_GET['recharge'])) { + if ($user['status'] != 'Active') { + _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); + } + if (!empty(App::getTokenValue(_get('stoken')))) { + r2(U . "voucher/invoice/"); + die(); + } + $bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['recharge'])->where('username', $user['username'])->findOne(); + if ($bill) { + if ($bill['routers'] == 'radius') { + $router = 'radius'; + } else { + $routers = ORM::for_table('tbl_routers')->where('name', $bill['routers'])->find_one(); + $router = $routers['id']; + } + if ($config['enable_balance'] == 'yes') { + $plan = ORM::for_table('tbl_plans')->find_one($bill['plan_id']); + if (!$plan['enabled']) { + r2(U . "home", 'e', 'Plan is not exists'); + } + if ($user['balance'] > $plan['price']) { + r2(U . "order/pay/$router/$bill[plan_id]&stoken=" . _get('stoken'), 'e', 'Order Plan'); + } else { + r2(U . "order/buy/$router/$bill[plan_id]", 'e', 'Order Plan'); + } + } else { + r2(U . "order/buy/$router/$bill[plan_id]", 'e', 'Order Plan'); + } + } +} else if (!empty(_get('extend'))) { + if ($user['status'] != 'Active') { + _alert(Lang::T('This account status') . ' : ' . Lang::T($user['status']), 'danger', ""); + } + if (!$config['extend_expired']) { + r2(U . 'home', 'e', "cannot extend"); + } + if (!empty(App::getTokenValue(_get('stoken')))) { + r2(U . 'home', 'e', "You already extend"); + } + $id = _get('extend'); + $tur = ORM::for_table('tbl_user_recharges')->where('customer_id', $user['id'])->where('id', $id)->find_one(); + if ($tur) { + $m = date("m"); + $path = $CACHE_PATH . DIRECTORY_SEPARATOR . "extends" . DIRECTORY_SEPARATOR; + if (!file_exists($path)) { + mkdir($path); + } + $path .= $user['id'] . ".txt"; + if (file_exists($path)) { + // is already extend + $last = file_get_contents($path); + if ($last == $m) { + r2(U . 'home', 'e', "You already extend for this month"); + } + } + if ($tur['status'] != 'on') { + if ($tur['routers'] != 'radius') { + $mikrotik = Mikrotik::info($tur['routers']); + $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + $router = $tur['routers']; + } + $p = ORM::for_table('tbl_plans')->findOne($tur['plan_id']); + if (!$p) { + r2(U . 'home', '3', "Plan Not Found"); + } + if ($tur['routers'] == 'radius') { + Radius::customerAddPlan($user, $p, $tur['expiration'] . ' ' . $tur['time']); + } else { + if ($tur['type'] == 'Hotspot') { + Mikrotik::removeHotspotUser($client, $user['username']); + Mikrotik::addHotspotUser($client, $p, $user); + } else if ($tur['type'] == 'PPPOE') { + Mikrotik::removePpoeUser($client, $user['username']); + Mikrotik::addPpoeUser($client, $p, $user); + } + } + // make customer cannot extend again + $days = $config['extend_days']; + $expiration = date('Y-m-d', strtotime(" +$days day")); + $tur->expiration = $expiration; + $tur->status = "on"; + $tur->save(); + App::setToken(_get('stoken'), $id); + file_put_contents($path, $m); + _log("Customer $tur[customer_id] $tur[username] extend for $days days", "Customer", $user['id']); + Message::sendTelegram("#u$user[username] #extend #" . $p['type'] . " \n" . $p['name_plan'] . + "\nLocation: " . $p['routers'] . + "\nCustomer: " . $user['fullname'] . + "\nNew Expired: " . Lang::dateAndTimeFormat($expiration, $tur['time'])); + r2(U . 'home', 's', "Extend until $expiration"); + } else { + r2(U . 'home', 'e', "Plan is not expired"); + } + } else { + r2(U . 'home', 'e', "Plan Not Found or Not Active"); + } +} else if (isset($_GET['deactivate']) && !empty($_GET['deactivate'])) { + $bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['deactivate'])->where('username', $user['username'])->findOne(); + if ($bill) { + $p = ORM::for_table('tbl_plans')->where('id', $bill['plan_id'])->find_one(); + if ($p['is_radius']) { + Radius::customerDeactivate($user['username']); + } else { + try { + $mikrotik = Mikrotik::info($bill['routers']); + $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + if ($bill['type'] == 'Hotspot') { + Mikrotik::removeHotspotUser($client, $bill['username']); + Mikrotik::removeHotspotActiveUser($client, $bill['username']); + } else if ($bill['type'] == 'PPPOE') { + Mikrotik::removePpoeUser($client, $bill['username']); + Mikrotik::removePpoeActive($client, $bill['username']); + } + } catch (Exception $e) { + //ignore it maybe mikrotik has been deleted + } + } + $bill->status = 'off'; + $bill->expiration = date('Y-m-d'); + $bill->time = date('H:i:s'); + $bill->save(); + _log('User ' . $bill['username'] . ' Deactivate ' . $bill['namebp'], 'Customer', $bill['customer_id']); + Message::sendTelegram('User u' . $bill['username'] . ' Deactivate ' . $bill['namebp']); + r2(U . 'home', 's', 'Success deactivate ' . $bill['namebp']); + } else { + r2(U . 'home', 'e', 'No Active Plan'); + } +} + +if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) { + $ui->assign('nux_mac', $_SESSION['nux-mac']); + $ui->assign('nux_ip', $_SESSION['nux-ip']); + $bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['id'])->where('username', $user['username'])->findOne(); + if ($_GET['mikrotik'] == 'login') { + $m = Mikrotik::info($bill['routers']); + $c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); + Mikrotik::logMeIn($c, $user['username'], $user['password'], $_SESSION['nux-ip'], $_SESSION['nux-mac']); + r2(U . 'home', 's', Lang::T('Login Request successfully')); + } else if ($_GET['mikrotik'] == 'logout') { + $m = Mikrotik::info($bill['routers']); + $c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); + Mikrotik::logMeOut($c, $user['username']); + r2(U . 'home', 's', Lang::T('Logout Request successfully')); + } +} + +$ui->assign('unpaid', ORM::for_table('tbl_payment_gateway') + ->where('username', $user['username']) + ->where('status', 1) + ->find_one()); +run_hook('view_customer_dashboard'); #HOOK +$ui->display('user-dashboard.tpl'); diff --git a/system/controllers/index.html b/system/controllers/index.html new file mode 100644 index 0000000..9757970 --- /dev/null +++ b/system/controllers/index.html @@ -0,0 +1,8 @@ + + + 403 Forbidden + + +

Directory access is forbidden.

+ + \ No newline at end of file diff --git a/system/controllers/login.php b/system/controllers/login.php new file mode 100644 index 0000000..449b6cc --- /dev/null +++ b/system/controllers/login.php @@ -0,0 +1,195 @@ +where('username', $username)->find_one(); + if ($d) { + $d_pass = $d['password']; + if ($d['status'] == 'Banned') { + echo '
' . Lang::T('This account status') . ': ' . Lang::T($d['status']) . '
'; + } + if (Password::_uverify($password, $d_pass) == true) { + $_SESSION['uid'] = $d['id']; + User::setCookie($d['id']); + $d->last_login = date('Y-m-d H:i:s'); + $d->save(); + _log($username . ' ' . Lang::T('Login Successful'), 'User', $d['id']); + echo '
' . Lang::T('Login Successful') . '
'; + r2(U . 'home'); + } else { + echo '
' . Lang::T('Invalid Username or Password') . '
'; + _log($username . ' ' . Lang::T('Failed Login'), 'User'); + r2(U . 'login'); + } + } else { + $d = ORM::for_table('tbl_users')->where('username', $username)->find_one(); + if ($d) { + $d_pass = $d['password']; + if (Password::_verify($password, $d_pass) == true) { + $_SESSION['aid'] = $d['id']; + $token = Admin::setCookie($d['id']); + $d->last_login = date('Y-m-d H:i:s'); + $d->save(); + _log($username . ' ' . Lang::T('Login Successful'), $d['user_type'], $d['id']); + echo '
' . Lang::T('Login Successful') . '
'; + r2(U . 'dashboard'); + } else { + echo '
' . Lang::T('Invalid Username or Password') . '
'; + _log($username . ' ' . Lang::T('Failed Login'), $d['user_type']); + r2(U . 'login'); + } + } else { + echo '
' . Lang::T('Invalid Username or Password') . '
'; + r2(U . 'login'); + } + } + } else { + echo '
' . Lang::T('Invalid Username or Password') . '
'; + r2(U . 'login'); + } + + break; + + case 'activation': + $voucher = _post('voucher'); + $username = _post('username'); + $v1 = ORM::for_table('tbl_voucher')->where('code', $voucher)->find_one(); + if ($v1) { + // voucher 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 { + _alert(Lang::T('Login Successful'), 'success', "dashboard"); + 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'], "Voucher", $voucher)) { + $v1->status = "1"; + $v1->user = $user['username']; + $v1->save(); + $user->last_login = date('Y-m-d H:i:s'); + $user->save(); + // add customer to mikrotik + if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) { + try { + $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")); + } + } catch (Exception $e) { + 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")); + } + } + } + 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']) { + $user->last_login = date('Y-m-d H:i:s'); + $user->save(); + if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) { + try { + $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")); + } + } catch (Exception $e) { + 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 (!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', Lang::T('Voucher Not Valid')); + } + } + } else { + _msglog('e', Lang::T('Invalid Username or Password')); + r2(U . 'login'); + } + default: + run_hook('customer_view_login'); #HOOK + if ($config['disable_registration'] == 'yes') { + $ui->display('user-login-noreg.tpl'); + } else { + $ui->display('user-login.tpl'); + } + break; +}