diff --git a/system/controllers/forgot.php b/system/controllers/forgot.php
new file mode 100644
index 00000000..4b711dfe
--- /dev/null
+++ b/system/controllers/forgot.php
@@ -0,0 +1,114 @@
+';
+ }
+ if (Validator::Length($fullname, 36, 2) == false) {
+ $msg .= 'Full Name should be between 3 to 25 characters' . '
';
+ }
+ if (!Validator::Length($password, 35, 2)) {
+ $msg .= 'Password should be between 3 to 35 characters' . '
';
+ }
+ if (!Validator::Email($email)) {
+ $msg .= 'Email is not Valid
';
+ }
+ if ($password != $cpassword) {
+ $msg .= Lang::T('Passwords does not match') . '
';
+ }
+
+ if (!empty($config['sms_url']) && $_c['allow_phone_otp'] == 'yes') {
+ $otpPath .= sha1($username . $db_pass) . ".txt";
+ run_hook('validate_otp'); #HOOK
+ //expired 10 minutes
+ if (file_exists($otpPath) && time() - filemtime($otpPath) > 1200) {
+ unlink($otpPath);
+ r2(U . 'register', 's', 'Verification code expired');
+ } else if (file_exists($otpPath)) {
+ $code = file_get_contents($otpPath);
+ if ($code != $otp_code) {
+ $ui->assign('username', $username);
+ $ui->assign('fullname', $fullname);
+ $ui->assign('address', $address);
+ $ui->assign('email', $email);
+ $ui->assign('phonenumber', $phonenumber);
+ $ui->assign('notify', 'Wrong Verification code');
+ $ui->assign('notify_t', 'd');
+ $ui->display('user-ui/register-otp.tpl');
+ exit();
+ } else {
+ unlink($otpPath);
+ }
+ } else {
+ r2(U . 'register', 's', 'No Verification code');
+ }
+ }
+ $d = ORM::for_table('tbl_customers')->where('username', $username)->find_one();
+ if ($d) {
+ $msg .= Lang::T('Account already axist') . '
';
+ }
+ if ($msg == '') {
+ run_hook('register_user'); #HOOK
+ $d = ORM::for_table('tbl_customers')->create();
+ $d->username = alphanumeric($username, "+_.@-");
+ $d->password = $password;
+ $d->fullname = $fullname;
+ $d->address = $address;
+ $d->email = $email;
+ $d->phonenumber = $phonenumber;
+ if ($d->save()) {
+ $user = $d->id();
+ r2(U . 'login', 's', Lang::T('Register Success! You can login now'));
+ } else {
+ $ui->assign('username', $username);
+ $ui->assign('fullname', $fullname);
+ $ui->assign('address', $address);
+ $ui->assign('email', $email);
+ $ui->assign('phonenumber', $phonenumber);
+ $ui->assign('notify', 'Failed to register');
+ $ui->assign('notify_t', 'd');
+ run_hook('view_otp_register'); #HOOK
+ $ui->display('user-ui/register-rotp.tpl');
+ }
+ } else {
+ $ui->assign('username', $username);
+ $ui->assign('fullname', $fullname);
+ $ui->assign('address', $address);
+ $ui->assign('email', $email);
+ $ui->assign('phonenumber', $phonenumber);
+ $ui->assign('notify', $msg);
+ $ui->assign('notify_t', 'd');
+ $ui->display('user-ui/register.tpl');
+ }
+ break;
+
+ default:
+ $ui->display('user-ui/forgot.tpl');
+ break;
+}
diff --git a/system/controllers/login.php b/system/controllers/login.php
index 75bf4a35..94b74f01 100644
--- a/system/controllers/login.php
+++ b/system/controllers/login.php
@@ -290,9 +290,11 @@ switch ($do) {
default:
run_hook('customer_view_login'); #HOOK
if ($config['disable_registration'] == 'yes') {
+ $ui->assign('_title', Lang::T('Activation'));
$ui->assign('code', alphanumeric(_get('code'), "-"));
$ui->display('user-ui/login-noreg.tpl');
} else {
+ $ui->assign('_title', Lang::T('Login'));
$ui->display('user-ui/login.tpl');
}
break;
diff --git a/system/controllers/register.php b/system/controllers/register.php
index 3ccedf26..daa0d55e 100644
--- a/system/controllers/register.php
+++ b/system/controllers/register.php
@@ -62,6 +62,7 @@ switch ($do) {
$ui->assign('phonenumber', $phonenumber);
$ui->assign('notify', 'Wrong Verification code');
$ui->assign('notify_t', 'd');
+ $ui->assign('_title', Lang::T('Register'));
$ui->display('user-ui/register-otp.tpl');
exit();
} else {
@@ -95,6 +96,7 @@ switch ($do) {
$ui->assign('phonenumber', $phonenumber);
$ui->assign('notify', 'Failed to register');
$ui->assign('notify_t', 'd');
+ $ui->assign('_title', Lang::T('Register'));
run_hook('view_otp_register'); #HOOK
$ui->display('user-ui/register-rotp.tpl');
}
@@ -106,6 +108,7 @@ switch ($do) {
$ui->assign('phonenumber', $phonenumber);
$ui->assign('notify', $msg);
$ui->assign('notify_t', 'd');
+ $ui->assign('_title', Lang::T('Register'));
$ui->display('user-ui/register.tpl');
}
break;
@@ -128,6 +131,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->assign('_title', Lang::T('Register'));
$ui->display('user-ui/register-otp.tpl');
} else {
$otp = rand(100000, 999999);
@@ -136,9 +140,11 @@ switch ($do) {
$ui->assign('username', $username);
$ui->assign('notify', 'Registration code has been sent to your phone');
$ui->assign('notify_t', 's');
+ $ui->assign('_title', Lang::T('Register'));
$ui->display('user-ui/register-otp.tpl');
}
} else {
+ $ui->assign('_title', Lang::T('Register'));
run_hook('view_otp_register'); #HOOK
$ui->display('user-ui/register-rotp.tpl');
}
@@ -148,6 +154,7 @@ switch ($do) {
$ui->assign('address', "");
$ui->assign('email', "");
$ui->assign('otp', false);
+ $ui->assign('_title', Lang::T('Register'));
run_hook('view_register'); #HOOK
$ui->display('user-ui/register.tpl');
}
diff --git a/system/devices/MikrotikVpn.php b/system/devices/MikrotikVpn.php
index a8f41fec..502cd594 100644
--- a/system/devices/MikrotikVpn.php
+++ b/system/devices/MikrotikVpn.php
@@ -28,7 +28,7 @@ class MikrotikVpn
$cid = self::getIdByCustomer($customer, $client);
if (empty($cid)) {
$this->addVpnUser($client, $plan, $customer);
- }else{
+ } else {
$setRequest = new RouterOS\Request('/ppp/secret/set');
$setRequest->setArgument('numbers', $cid);
if (!empty($customer['pppoe_password'])) {
@@ -43,13 +43,13 @@ class MikrotikVpn
}
if (!empty($customer['pppoe_ip'])) {
$setRequest->setArgument('remote-address', $customer['pppoe_ip']);
- }else{
+ } else {
$setRequest->setArgument('remote-address', '0.0.0.0');
}
$setRequest->setArgument('profile', $plan['name_plan']);
$setRequest->setArgument('comment', $customer['fullname'] . ' | ' . $customer['email'] . ' | ' . implode(', ', User::getBillNames($customer['id'])));
$client->sendSync($setRequest);
- if(isset($isChangePlan) && $isChangePlan){
+ if (isset($isChangePlan) && $isChangePlan) {
$this->removeVpnActive($client, $customer['username']);
if (!empty($customer['pppoe_username'])) {
$this->removeVpnActive($client, $customer['pppoe_username']);
@@ -64,7 +64,7 @@ class MikrotikVpn
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
if (!empty($plan['plan_expired'])) {
$p = ORM::for_table("tbl_plans")->find_one($plan['plan_expired']);
- if($p){
+ if ($p) {
$this->add_customer($customer, $p);
$this->removeVpnActive($client, $customer['username']);
if (!empty($customer['pppoe_username'])) {
@@ -117,26 +117,27 @@ class MikrotikVpn
$unitup = 'M';
}
$rate = $bw['rate_up'] . $unitup . "/" . $bw['rate_down'] . $unitdown;
- if(!empty(trim($bw['burst']))){
- $rate .= ' '.$bw['burst'];
+ if (!empty(trim($bw['burst']))) {
+ $rate .= ' ' . $bw['burst'];
}
$pool = ORM::for_table("tbl_pool")->where("pool_name", $plan['pool'])->find_one();
$addRequest = new RouterOS\Request('/ppp/profile/add');
$client->sendSync(
$addRequest
->setArgument('name', $plan['name_plan'])
- ->setArgument('local-address', (!empty($pool['local_ip'])) ? $pool['local_ip']: $pool['pool_name'])
+ ->setArgument('local-address', (!empty($pool['local_ip'])) ? $pool['local_ip'] : $pool['pool_name'])
->setArgument('remote-address', $pool['pool_name'])
->setArgument('rate-limit', $rate)
);
}
- function getIdByCustomer($customer, $client){
+ function getIdByCustomer($customer, $client)
+ {
$printRequest = new RouterOS\Request('/ppp/secret/print');
$printRequest->setQuery(RouterOS\Query::where('name', $customer['username']));
$id = $client->sendSync($printRequest)->getProperty('.id');
- if(empty($id)){
+ if (empty($id)) {
if (!empty($customer['pppoe_username'])) {
$printRequest = new RouterOS\Request('/ppp/secret/print');
$printRequest->setQuery(RouterOS\Query::where('name', $customer['pppoe_username']));
@@ -171,15 +172,15 @@ class MikrotikVpn
$unitup = 'M';
}
$rate = $bw['rate_up'] . $unitup . "/" . $bw['rate_down'] . $unitdown;
- if(!empty(trim($bw['burst']))){
- $rate .= ' '.$bw['burst'];
+ if (!empty(trim($bw['burst']))) {
+ $rate .= ' ' . $bw['burst'];
}
$pool = ORM::for_table("tbl_pool")->where("pool_name", $new_plan['pool'])->find_one();
$setRequest = new RouterOS\Request('/ppp/profile/set');
$client->sendSync(
$setRequest
->setArgument('numbers', $profileID)
- ->setArgument('local-address', (!empty($pool['local_ip'])) ? $pool['local_ip']: $pool['pool_name'])
+ ->setArgument('local-address', (!empty($pool['local_ip'])) ? $pool['local_ip'] : $pool['pool_name'])
->setArgument('remote-address', $pool['pool_name'])
->setArgument('rate-limit', $rate)
->setArgument('on-up', $new_plan['on_login'])
@@ -205,7 +206,8 @@ class MikrotikVpn
);
}
- function add_pool($pool){
+ function add_pool($pool)
+ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
@@ -220,7 +222,8 @@ class MikrotikVpn
);
}
- function update_pool($old_pool, $new_pool){
+ function update_pool($old_pool, $new_pool)
+ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
@@ -245,7 +248,8 @@ class MikrotikVpn
}
}
- function remove_pool($pool){
+ function remove_pool($pool)
+ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
@@ -304,7 +308,7 @@ class MikrotikVpn
$removeRequest = new RouterOS\Request('/ppp/secret/remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
- $this->rmNat($client, $cstid);
+ $this->rmNat($client, $cstid);
}
function addVpnUser($client, $plan, $customer)
@@ -324,18 +328,17 @@ class MikrotikVpn
$setRequest->setArgument('name', $customer['username']);
}
if (!empty($customer['pppoe_ip'])) {
- $ips = $customer['pppoe_ip'];
+ $ips = $customer['pppoe_ip'];
$setRequest->setArgument('remote-address', $customer['pppoe_ip']);
} else {
- $ips = $this->checkIpAddr($plan['pool'], $customer['id']);
- $setRequest->setArgument('remote-address', $ips);
-
- }
- $this->addNat($client, $plan, $customer, $ips);
+ $ips = $this->checkIpAddr($plan['pool'], $customer['id']);
+ $setRequest->setArgument('remote-address', $ips);
+ }
+ $this->addNat($client, $plan, $customer, $ips);
$client->sendSync($setRequest);
- $customer->service_type = 'VPN';
- $customer->pppoe_ip = $ips;
- $customer->save();
+ $customer->service_type = 'VPN';
+ $customer->pppoe_ip = $ips;
+ $customer->save();
}
function removeVpnActive($client, $username)
@@ -368,7 +371,6 @@ class MikrotikVpn
->setArgument('comment', $comment)
->setArgument('list', $listName)
);
-
}
function removeIpFromAddressList($client, $ip)
@@ -395,110 +397,111 @@ class MikrotikVpn
if ($_app_stage == 'demo') {
return null;
}
- $this->checkPort($cust['id'], 'Winbox', $plan['routers']);
- $this->checkPort($cust['id'], 'Api', $plan['routers']);
- $this->checkPort($cust['id'], 'Web', $plan['routers']);
- $tcf = ORM::for_table('tbl_customers_fields')
- ->where('customer_id', $cust['id'])
- ->find_many();
- $ip = ORM::for_table('tbl_port_pool')
- ->where('routers', $plan['routers'])
- ->find_one();
- foreach ($tcf as $cf) {
- $dst = $cf['field_value'];
- $cmnt = $cf['field_name'];
- if ($cmnt == 'Winbox') {
- $tp = '8291'; }
- if ($cmnt == 'Web') {
- $tp = '80'; }
- if ($cmnt == 'Api') {
- $tp = '8728'; }
- if ($cmnt == 'Winbox' || $cmnt == 'Web' || $cmnt == 'Api') {
- $addRequest = new RouterOS\Request('/ip/firewall/nat/add');
- $client->sendSync(
- $addRequest
- ->setArgument('chain', 'dstnat')
- ->setArgument('protocol', 'tcp')
- ->setArgument('dst-port', $dst)
- ->setArgument('action', 'dst-nat')
- ->setArgument('to-addresses', $ips)
- ->setArgument('to-ports', $tp)
- ->setArgument('dst-address', $ip['public_ip'])
- ->setArgument('comment', $cmnt.' || '.$cust['username'])
- );
- }
- }
+ $this->checkPort($cust['id'], 'Winbox', $plan['routers']);
+ $this->checkPort($cust['id'], 'Api', $plan['routers']);
+ $this->checkPort($cust['id'], 'Web', $plan['routers']);
+ $tcf = ORM::for_table('tbl_customers_fields')
+ ->where('customer_id', $cust['id'])
+ ->find_many();
+ $ip = ORM::for_table('tbl_port_pool')
+ ->where('routers', $plan['routers'])
+ ->find_one();
+ foreach ($tcf as $cf) {
+ $dst = $cf['field_value'];
+ $cmnt = $cf['field_name'];
+ if ($cmnt == 'Winbox') {
+ $tp = '8291';
+ }
+ if ($cmnt == 'Web') {
+ $tp = '80';
+ }
+ if ($cmnt == 'Api') {
+ $tp = '8728';
+ }
+ if ($cmnt == 'Winbox' || $cmnt == 'Web' || $cmnt == 'Api') {
+ $addRequest = new RouterOS\Request('/ip/firewall/nat/add');
+ $client->sendSync(
+ $addRequest
+ ->setArgument('chain', 'dstnat')
+ ->setArgument('protocol', 'tcp')
+ ->setArgument('dst-port', $dst)
+ ->setArgument('action', 'dst-nat')
+ ->setArgument('to-addresses', $ips)
+ ->setArgument('to-ports', $tp)
+ ->setArgument('dst-address', $ip['public_ip'])
+ ->setArgument('comment', $cmnt . ' || ' . $cust['username'])
+ );
+ }
+ }
}
-
+
function rmNat($client, $cstid)
{
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
-
- $cst = ORM::for_table('tbl_customers')->find_one($cstid);
+
+ $cst = ORM::for_table('tbl_customers')->find_one($cstid);
$printRequest = new RouterOS\Request('/ip/firewall/nat/print');
$printRequest->setQuery(RouterOS\Query::where('to-addresses', $cst['pppoe_ip']));
$nats = $client->sendSync($printRequest);
- foreach ($nats as $nat) {
- $id = $client->sendSync($printRequest)->getProperty('.id');
- $removeRequest = new RouterOS\Request('/ip/firewall/nat/remove');
- $removeRequest->setArgument('numbers', $id);
- $client->sendSync($removeRequest);
- }
- }
-
-
- function checkPort($id, $portn, $router)
- {
- $tcf = ORM::for_table('tbl_customers_fields')
- ->where('customer_id', $id)
- ->where('field_name', $portn)
- ->find_one();
- $ports = ORM::for_table('tbl_port_pool')
- ->where('routers', $router)
- ->find_one();
- $port = explode('-',$ports['range_port']);
- if (empty($tcf) && !empty($ports)) {
- repeat:
- $portr = rand($port['0'], $port['1']);
- if (ORM::for_table('tbl_customers_fields')->where('field_value', $portr)->find_one()) {
- if($portr == $port['1'])
- {
- return;
- }
- goto repeat;
- }
- $cf = ORM::for_table('tbl_customers_fields')->create();
- $cf->customer_id = $id;
- $cf->field_name = $portn;
- $cf->field_value = $portr;
- $cf->save();
- }
- }
-
- function checkIpAddr($pname, $id) {
- $c = ORM::for_table('tbl_customers')->find_one($id);
- $ipp = ORM::for_table('tbl_pool')
- ->where('pool_name', $pname)
- ->find_one();
- $ip_r = explode('-',$ipp['range_ip']);
- $ip_1 = explode('.',$ip_r['0']);
- $ip_2 = explode('.',$ip_r['1']);
- repeat:
- $ipt = rand($ip_1['3'], $ip_2['3']);
- $ips = $ip_1['0'].'.'.$ip_1['1'].'.'.$ip_1['2'].'.'.$ipt;
- if (empty($c['pppoe_ip'])) {
- if (ORM::for_table('tbl_customers')->where('pppoe_ip' ,$ips)->find_one()) {
- if ($ip_2['3'] == $ipt)
- {
- return;
- }
- goto repeat;
- }
- return $ips;
- }
- }
-
+ foreach ($nats as $nat) {
+ $id = $client->sendSync($printRequest)->getProperty('.id');
+ $removeRequest = new RouterOS\Request('/ip/firewall/nat/remove');
+ $removeRequest->setArgument('numbers', $id);
+ $client->sendSync($removeRequest);
+ }
+ }
+
+
+ function checkPort($id, $portn, $router)
+ {
+ $tcf = ORM::for_table('tbl_customers_fields')
+ ->where('customer_id', $id)
+ ->where('field_name', $portn)
+ ->find_one();
+ $ports = ORM::for_table('tbl_port_pool')
+ ->where('routers', $router)
+ ->find_one();
+ $port = explode('-', $ports['range_port']);
+ if (empty($tcf) && !empty($ports)) {
+ repeat:
+ $portr = rand($port['0'], $port['1']);
+ if (ORM::for_table('tbl_customers_fields')->where('field_value', $portr)->find_one()) {
+ if ($portr == $port['1']) {
+ return;
+ }
+ goto repeat;
+ }
+ $cf = ORM::for_table('tbl_customers_fields')->create();
+ $cf->customer_id = $id;
+ $cf->field_name = $portn;
+ $cf->field_value = $portr;
+ $cf->save();
+ }
+ }
+
+ function checkIpAddr($pname, $id)
+ {
+ $c = ORM::for_table('tbl_customers')->find_one($id);
+ $ipp = ORM::for_table('tbl_pool')
+ ->where('pool_name', $pname)
+ ->find_one();
+ $ip_r = explode('-', $ipp['range_ip']);
+ $ip_1 = explode('.', $ip_r['0']);
+ $ip_2 = explode('.', $ip_r['1']);
+ repeat:
+ $ipt = rand($ip_1['3'], $ip_2['3']);
+ $ips = $ip_1['0'] . '.' . $ip_1['1'] . '.' . $ip_1['2'] . '.' . $ipt;
+ if (empty($c['pppoe_ip'])) {
+ if (ORM::for_table('tbl_customers')->where('pppoe_ip', $ips)->find_one()) {
+ if ($ip_2['3'] == $ipt) {
+ return;
+ }
+ goto repeat;
+ }
+ return $ips;
+ }
+ }
}
diff --git a/ui/ui/user-ui/404.tpl b/ui/ui/user-ui/404.tpl
index 4d975e4c..eaf0b977 100644
--- a/ui/ui/user-ui/404.tpl
+++ b/ui/ui/user-ui/404.tpl
@@ -1,4 +1,5 @@
-{include file="user-ui/header.tpl"}
+{include file="user-ui/header-public.tpl"}
+
{Lang::T('Coming Soon! Next Version...')}