just added self Registration,

customer must have voucher before register
This commit is contained in:
Ibnu Maksum 2017-03-14 05:15:08 +07:00
parent 2e34fa46e5
commit b6c55ff5a9
10 changed files with 370 additions and 19 deletions

View File

@ -3,11 +3,11 @@
@ibnux notes:
----
> The project maybe has been abandoned
> maybe the dev busy
> and nobody donate to him
> i will try to update as far as i can
> any Modification will be update in here
> The project maybe has been abandoned,
> maybe the dev busy,
> and nobody donate to him,
> i will try to update as far as i can,
> any Modification will be update in here.
### iBNuX Todos

View File

@ -113,11 +113,19 @@ switch ($action) {
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
}
$d->delete();
$c->delete();
try{
$d->delete();
}catch(Exception $e){}
try{
$c->delete();
}catch(Exception $e){}
}else{
$d->delete();
$c->delete();
try{
$d->delete();
}catch(Exception $e){}
try{
$c->delete();
}catch(Exception $e){}
}
r2(U . 'customers/list', 's', $_L['User_Delete_Ok']);

View File

@ -95,6 +95,7 @@ switch ($action) {
} catch (Exception $e) {
die('Unable to connect to the router.');
}
$printRequest = new RouterOS\Request(
'/ip hotspot user print .proplist=name',
RouterOS\Query::where('name', $c['username'])

View File

@ -0,0 +1,235 @@
<?php
/**
* PHP Mikrotik Billing (www.phpmixbill.com)
* @copyright Copyright (C) 2014-2015 PHP Mikrotik Billing
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* created by iBNuX
**/
if (isset($routes['1'])) {
$do = $routes['1'];
} else {
$do = 'register-display';
}
use PEAR2\Net\RouterOS;
require_once 'system/autoload/PEAR2/Autoload.php';
switch($do){
case 'post':
$username = _post('username');
$fullname = _post('fullname');
$password = _post('password');
$cpassword = _post('cpassword');
$address = _post('address');
$phonenumber = _post('phonenumber');
$code = _post('kodevoucher');
$v1 = ORM::for_table('tbl_voucher')->where('code',$code)->where('status',0)->find_one();
if ($v1){
$msg = '';
if(Validator::Length($username,35,2) == false){
$msg .= 'Username should be between 3 to 55 characters'. '<br>';
}
if(Validator::Length($fullname,36,2) == false){
$msg .= 'Full Name should be between 3 to 25 characters'. '<br>';
}
if(!Validator::Length($password,35,2)){
$msg .= 'Password should be between 3 to 35 characters'. '<br>';
}
if($password != $cpassword){
$msg .= $_L['PasswordsNotMatch']. '<br>';
}
$d = ORM::for_table('tbl_customers')->where('username',$username)->find_one();
if($d){
$msg .= $_L['account_already_exist']. '<br>';
}
if($msg == ''){
$d = ORM::for_table('tbl_customers')->create();
$d->username = $username;
$d->password = $password;
$d->fullname = $fullname;
$d->address = $address;
$d->phonenumber = $phonenumber;
if($d->save()){
$user = $d->id();
//check voucher plan
$p = ORM::for_table('tbl_plans')->find_one($v1['id_plan']);
$c = ORM::for_table('tbl_customers')->find_one($user);
$p = ORM::for_table('tbl_plans')->find_one($v1['id_plan']);
$date_now = date("Y-m-d H:i:s");
$date_only = date("Y-m-d");
$time = date("H:i:s");
$mikrotik = Router::_info($v1['routers']);
$date_exp = date("Y-m-d", mktime(0,0,0,date("m"),date("d") + $p['validity'],date("Y")));
if($v1['type'] == 'Hotspot'){
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
} catch (Exception $e) {
die('Unable to connect to the router.');
}
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
$client->sendSync($addRequest
->setArgument('name', $c['username'])
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
);
$d = ORM::for_table('tbl_user_recharges')->create();
$d->customer_id = $user;
$d->username = $c['username'];
$d->plan_id = $v1['id_plan'];
$d->namebp = $p['name_plan'];
$d->recharged_on = $date_only;
$d->expiration = $date_exp;
$d->time = $time;
$d->status = "on";
$d->method = "voucher";
$d->routers = $v1['routers'];
$d->type = "Hotspot";
$d->save();
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-"._raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
$t->recharged_on = $date_only;
$t->expiration = $date_exp;
$t->time = $time;
$t->method = "voucher";
$t->routers = $v1['routers'];
$t->type = "Hotspot";
$t->save();
$v1->status = "1";
$v1->user = $c['username'];
$v1->save();
}else{
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
} catch (Exception $e) {
die('Unable to connect to the router.');
}
$addRequest = new RouterOS\Request('/ppp/secret/add');
$client->sendSync($addRequest
->setArgument('name', $c['username'])
->setArgument('service', 'pppoe')
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
);
$d = ORM::for_table('tbl_user_recharges')->create();
$d->customer_id = $user;
$d->username = $c['username'];
$d->plan_id = $v1['id_plan'];
$d->namebp = $p['name_plan'];
$d->recharged_on = $date_only;
$d->expiration = $date_exp;
$d->time = $time;
$d->status = "on";
$d->method = "voucher";
$d->routers = $v1['routers'];
$d->type = "PPPOE";
$d->save();
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-"._raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
$t->recharged_on = $date_only;
$t->expiration = $date_exp;
$t->time = $time;
$t->method = "voucher";
$t->routers = $v1['routers'];
$t->type = "PPPOE";
$t->save();
$v1->status = "1";
$v1->user = $c['username'];
$v1->save();
}
r2(U . 'login', 's', $_L['Register_Success']);
}else{
$ui->assign('username', $username);
$ui->assign('fullname', $fullname);
$ui->assign('address', $address);
$ui->assign('phonenumber', $phonenumber);
$ui->assign('notify','<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">×</span>
</button>
<div>Failed to register</div></div>');
$ui->display('register.tpl');
}
//r2(U . 'register', 's', $_L['account_created_successfully']);
}else{
$ui->assign('username', $username);
$ui->assign('fullname', $fullname);
$ui->assign('address', $address);
$ui->assign('phonenumber', $phonenumber);
$ui->assign('notify','<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">×</span>
</button>
<div>'.$msg.'</div></div>');
$ui->display('register.tpl');
}
}else{
$ui->assign('username', $username);
$ui->assign('fullname', $fullname);
$ui->assign('address', $address);
$ui->assign('phonenumber', $phonenumber);
$ui->assign('notify','<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">×</span>
</button>
<div>'.$_L['Voucher_Not_Valid'].'</div></div>');
$ui->display('register.tpl');
//r2(U . 'register', 'e', $_L['Voucher_Not_Valid']);
}
/*$password = _post('password');
if($username != '' AND $password != ''){
$d = ORM::for_table('tbl_customers')->where('username',$username)->find_one();
if($d){
$d_pass = $d['password'];
if(Password::_uverify($password,$d_pass) == true){
$_SESSION['uid'] = $d['id'];
$d->last_login = date('Y-m-d H:i:s');
$d->save();
_log($username .' '. $_L['Login_Successful'],'User',$d['id']);
r2(U.'home');
}else{
_msglog('e',$_L['Invalid_Username_or_Password']);
_log($username .' '. $_L['Failed_Login'],'User');
r2(U.'login');
}
}else{
_msglog('e',$_L['Invalid_Username_or_Password']);
r2(U.'login');
}
}else{
_msglog('e',$_L['Invalid_Username_or_Password']);
r2(U.'login');
}*/
break;
case 'register-display':
$ui->display('register.tpl');
break;
default:
$ui->display('register.tpl');
break;
}

View File

@ -44,6 +44,7 @@ foreach ($d as $ds){
} catch (Exception $e) {
die('Unable to connect to the router.');
}
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
$printRequest->setArgument('.proplist', '.id');
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));

View File

@ -32,12 +32,11 @@ if ($cn == '1') {
$db_password = \'' . $db_password . '\';
$db_name = \'' . $db_name . '\';
define(\'APP_URL\', \'' . $appurl . '\');
$_app_stage = \'Live\';
';
$_app_stage = \'Live\';';
$wConfig = "../config.php";
$fh = fopen($wConfig, 'w') or die("Can't create config file, your server does not support 'fopen' function,
please create a file named - config.php with following contents- <br/>$input");
fwrite($fh, $input);
fclose($fh);

View File

@ -5,15 +5,25 @@ Language Name: English
Contributor: Ismail Marzuqi
Web: www.phpmixbill.com
Email: iesien22@yahoo.com
2017
Contributor: Ibnu Maksum (@ibnux)
------------------------------------
*/
$_L['Login'] = 'Login';
$_L['Sign_In_Member'] = 'Sign In to Member Panel';
$_L['Sign_In_Admin'] = 'Sign In to Admin Panel';
$_L['Login'] = 'Log-in';
$_L['Register'] = 'Register';
$_L['Register_Voucher_Failed'] = 'Voucher not found, please buy voucher befor register';
$_L['Register_Success'] = 'Register Success! You can login now';
$_L['Sign_In_Member'] = 'Log in to Member Panel';
$_L['Register_Member'] = 'Register as Member';
$_L['Sign_In_Admin'] = 'Masuk ke Admin Panel';
$_L['Logo'] = 'PHPMixBill';
$_L['Username'] = 'Username';
$_L['Password'] = 'Password';
$_L['PasswordsNotMatch'] = 'Passwords does not match';
$_L['account_already_exist'] = 'Account already axist';
$_L['Manage'] = 'Manage';
$_L['Submit'] = 'Submit';
$_L['Save'] = 'Save Changes';

View File

@ -5,15 +5,25 @@ Language Name: Indonesia
Contributor: Ismail Marzuqi
Web: www.phpmixbill.com
Email: iesien22@yahoo.com
2017
Contributor: Ibnu Maksum (@ibnux)
------------------------------------
*/
$_L['Login'] = 'Masuk';
$_L['Register'] = 'Daftar';
$_L['Register_Voucher_Failed'] = 'Voucher tidak ditemukan, mohon beli dulu Voucher sebelum mendaftar';
$_L['Register_Success'] = 'Pendaftaran sukses!<br>silahkan masuk';
$_L['Sign_In_Member'] = 'Masuk ke Member Panel';
$_L['Register_Member'] = 'Mendaftar sebagai pelanggan<br>pastikan anda sudah membeli voucher';
$_L['Sign_In_Admin'] = 'Masuk ke Admin Panel';
$_L['Logo'] = 'PHPMixBill';
$_L['Username'] = 'Username';
$_L['Password'] = 'Password';
$_L['PasswordsNotMatch'] = 'Sandi tidak sama';
$_L['account_already_exist'] = 'Username sudah ada yang menggunakan';
$_L['Manage'] = 'Proses';
$_L['Submit'] = 'Kirim';
$_L['Save'] = 'Simpan Perubahan';

View File

@ -29,7 +29,7 @@
<div class="page page-auth">
<div class="auth-container">
<div class="form-head mb20">
<h1 class="site-logo h2 mb5 mt5 text-center text-uppercase text-bold"><a href="./">{$_L['Logo']}</a></h1>
<h1 class="site-logo h2 mb5 mt5 text-center text-uppercase text-bold"><a href="./">{$_c['CompanyName']}</a></h1>
<h5 class="text-normal h5 text-center">{$_L['Sign_In_Member']}</h5>
</div>
{if isset($notify)}
@ -38,7 +38,7 @@
<div class="form-container">
<form class="form-horizontal" action="{$_url}login/post" method="post">
<div class="md-input-container md-float-label">
<input type="text" name="username" class="md-input">
<input type="text" name="username" placeholder="{$_L['Phone_Number']}" class="md-input">
<label>{$_L['Username']}</label>
</div>
@ -57,12 +57,14 @@
</div>
<div class="btn-group btn-group-justified mb15">
<div class="btn-group">
<button type="submit" class="btn btn-success">{$_L['Login']}</button>
<button type="submit" class="btn btn-primary">{$_L['Login']}</button>
</div>
<div class="btn-group">
<a href="{$_url}register" class="btn btn-success">{$_L['Register']}</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,85 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>{$_title} - {$_L['Register']}</title>
<link rel="shortcut icon" href="{$_theme}/images/logo.png" type="image/x-icon" />
<!-- Icons -->
<link rel="stylesheet" href="{$_theme}/fonts/ionicons/css/ionicons.min.css">
<link rel="stylesheet" href="{$_theme}/fonts/font-awesome/css/font-awesome.min.css">
<!-- Plugins -->
<link rel="stylesheet" href="{$_theme}/styles/plugins/waves.css">
<link rel="stylesheet" href="{$_theme}/styles/plugins/perfect-scrollbar.css">
<!-- Css/Less Stylesheets -->
<link rel="stylesheet" href="{$_theme}/styles/bootstrap.min.css">
<link rel="stylesheet" href="{$_theme}/styles/main.min.css">
<!-- <link href='http://fonts.googleapis.com/css?family=Roboto:400,500,700,300' rel='stylesheet' type='text/css'> -->
<!-- Match Media polyfill for IE9 -->
<!--[if IE 9]> <script src="{$_theme}/scripts/ie/matchMedia.js"></script> <![endif]-->
</head>
<body id="app" class="app off-canvas body-full">
<div class="main-container clearfix">
<div class="content-container" id="content">
<div class="page page-auth" style="margin-top:180px">
<div class="auth-container">
<div class="form-head mb20">
<h1 class="site-logo h2 mb5 mt5 text-center text-uppercase text-bold"><a href="./">{$_c['CompanyName']}</a></h1>
<h5 class="text-normal h5 text-center">{$_L['Register_Member']}</h5>
</div>
{if isset($notify)}
{$notify}
{/if}
<div class="form-container">
<form class="form-horizontal" action="{$_url}register/post" method="post">
<div class="md-input-container md-float-label">
<input type="text" required class="md-input" id="username" value="{$username}" placeholder="{$_L['Phone_Number']}" name="username">
<label>{$_L['Username']}</label>
</div>
<div class="md-input-container md-float-label">
<input type="text" required class="md-input" id="fullname" value="{$fullname}" name="fullname">
<label>{$_L['Full_Name']}</label>
</div>
<div class="md-input-container md-float-label">
<input type="password" required class="md-input" id="password" name="password">
<label>{$_L['Password']}</label>
</div>
<div class="md-input-container md-float-label">
<input type="password" required class="md-input" id="cpassword" name="cpassword">
<label>{$_L['Confirm_Password']}</label>
</div>
<div class="md-input-container md-float-label">
<input type="text" name="address" id="address" value="{$address}" class="md-input">
<label>{$_L['Address']}</label>
</div>
<div class="md-input-container md-float-label">
<input type="text" required class="md-input" value="{$phonenumber}" id="phonenumber" name="phonenumber">
<label>{$_L['Phone_Number']}</label>
</div>
<div class="md-input-container md-float-label">
<input type="text" required class="md-input" id="kodevoucher" name="kodevoucher">
<label>{$_L['Code_Voucher']}</label>
</div>
<div class="btn-group btn-group-justified mb15">
<div class="btn-group">
<button class="btn btn-primary waves-effect waves-light" type="submit">{$_L['Register']}</button>
</div>
<div class="btn-group">
<a href="{$_url}login" class="btn btn-success">{$_L['Cancel']}</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script src="scripts/vendors.js"></script>
</body>
</html>