View Admin and Init script

This commit is contained in:
Ibnu Maksum 2024-02-19 14:24:34 +07:00
parent ce649220f5
commit ade714e2ae
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
15 changed files with 377 additions and 378 deletions

154
init.php Normal file
View File

@ -0,0 +1,154 @@
<?php
/**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux
**/
if (realpath(__FILE__) == realpath($_SERVER['SCRIPT_FILENAME'])) {
header('HTTP/1.0 403 Forbidden', TRUE, 403);
header('location: ../');
die();
}
$root_path = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
$isApi = false;
// on some server, it getting error because of slash is backwards
function _autoloader($class)
{
global $root_path;
if (strpos($class, '_') !== false) {
$class = str_replace('_', DIRECTORY_SEPARATOR, $class);
if (file_exists($root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
include $root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
} else {
$class = str_replace("\\", DIRECTORY_SEPARATOR, $class);
if (file_exists($root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'))
include $root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
}
} else {
if (file_exists($root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
include $root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
} else {
$class = str_replace("\\", DIRECTORY_SEPARATOR, $class);
if (file_exists($root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'))
include $root_path . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
}
}
}
spl_autoload_register('_autoloader');
if (!file_exists($root_path . 'config.php')) {
$root_path .= '..' . DIRECTORY_SEPARATOR;
if (!file_exists($root_path . 'config.php')) {
die("config.php file not found");
}
}
if (!file_exists($root_path . File::pathFixer('system/orm.php'))) {
die($root_path . "orm.php file not found");
}
if (!file_exists($root_path . File::pathFixer('system/uploads/notifications.default.json'))) {
die($root_path . File::pathFixer("system/uploads/notifications.default.json file not found"));
}
require_once $root_path . 'config.php';
require_once $root_path . File::pathFixer('system/orm.php');
require_once $root_path . File::pathFixer('system/autoload/PEAR2/Autoload.php');
include $root_path . File::pathFixer('system/autoload/Hookers.php');
ORM::configure("mysql:host=$db_host;dbname=$db_name");
ORM::configure('username', $db_user);
ORM::configure('password', $db_password);
ORM::configure('return_result_sets', true);
if ($_app_stage != 'Live') {
ORM::configure('logging', true);
}
// notification message
if (file_exists($root_path . File::pathFixer("system/uploads/notifications.json"))) {
$_notifmsg = json_decode(file_get_contents($root_path . File::pathFixer('system/uploads/notifications.json')), true);
}
$_notifmsg_default = json_decode(file_get_contents($root_path . File::pathFixer('system/uploads/notifications.default.json')), true);
//register all plugin
foreach (glob(File::pathFixer($root_path . File::pathFixer("system/plugin/*.php"))) as $filename) {
try {
include $filename;
} catch (Throwable $e) {
//ignore plugin error
} catch (Exception $e) {
//ignore plugin error
}
}
$result = ORM::for_table('tbl_appconfig')->find_many();
foreach ($result as $value) {
$config[$value['setting']] = $value['value'];
}
if (empty($http_proxy) && !empty($config['http_proxy'])) {
$http_proxy = $config['http_proxy'];
if (empty($http_proxyauth) && !empty($config['http_proxyauth'])) {
$http_proxyauth = $config['http_proxyauth'];
}
}
date_default_timezone_set($config['timezone']);
if ((!empty($radius_user) && $config['radius_enable']) || _post('radius_enable')) {
ORM::configure("mysql:host=$radius_host;dbname=$radius_name", null, 'radius');
ORM::configure('username', $radius_user, 'radius');
ORM::configure('password', $radius_pass, 'radius');
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'), 'radius');
ORM::configure('return_result_sets', true, 'radius');
}
if (empty($config['language'])) {
$config['language'] = 'english';
}
$lan_file = $root_path .File::pathFixer('system/lan/' . $config['language'] . '.json');
if (file_exists($lan_file)) {
$_L = json_decode(file_get_contents($lan_file), true);
$_SESSION['Lang'] = $_L;
} else {
$_L['author'] = 'Auto Generated by iBNuX Script';
$_SESSION['Lang'] = $_L;
file_put_contents($lan_file, json_encode($_L));
}
function safedata($value)
{
$value = trim($value);
return $value;
}
function _post($param, $defvalue = '')
{
if (!isset($_POST[$param])) {
return $defvalue;
} else {
return safedata($_POST[$param]);
}
}
function _get($param, $defvalue = '')
{
if (!isset($_GET[$param])) {
return $defvalue;
} else {
return safedata($_GET[$param]);
}
}
function _req($param, $defvalue = '')
{
if (!isset($_REQUEST[$param])) {
return $defvalue;
} else {
return safedata($_REQUEST[$param]);
}
}

View File

@ -19,16 +19,16 @@ class Lang
$key = Lang::sanitize($key);
if (isset($_L[$key])) {
return $_L[$key];
}else if (isset($_L[$key])) {
} else if (isset($_L[$key])) {
return $_L[$key];
} else {
$iso = Lang::getIsoLang()[$config['language']];
if(empty($iso)){
if (empty($iso)) {
return $val;
}
if(!empty($iso) && !empty($val)){
if (!empty($iso) && !empty($val)) {
$temp = Lang::translate($val, $iso);
if(!empty($temp)){
if (!empty($temp)) {
$val = $temp;
}
}
@ -39,14 +39,16 @@ class Lang
}
}
public static function sanitize($str){
public static function sanitize($str)
{
return preg_replace("/[^A-Za-z0-9]/", '_', $str);;
}
public static function getIsoLang(){
public static function getIsoLang()
{
global $isolang;
if(empty($isolang) || count($isolang)==0){
$isolang = json_decode(file_get_contents(File::pathFixer("system/lan/country.json")),true);
if (empty($isolang) || count($isolang) == 0) {
$isolang = json_decode(file_get_contents(File::pathFixer("system/lan/country.json")), true);
}
return $isolang;
}
@ -94,22 +96,35 @@ class Lang
return date($config['date_format'] . ' H:i', strtotime("$date $time"));
}
public static function timeElapsed($time){
$s = $time%60;
$m = floor(($time%3600)/60);
$h = floor(($time%86400)/3600);
$d = floor(($time%2592000)/86400);
$M = floor($time/2592000);
$result = '';
if($M>0){
$result = $M.'m ';
public static function timeElapsed($datetime, $full = false)
{
$now = new DateTime;
$ago = new DateTime($datetime);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = array(
'y' => Lang::T('year'),
'm' => Lang::T('month'),
'w' => Lang::T('week'),
'd' => Lang::T('day'),
'h' => Lang::T('hour'),
'i' => Lang::T('minute'),
's' => Lang::T('second'),
);
foreach ($string as $k => &$v) {
if ($diff->$k) {
$v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');
} else {
unset($string[$k]);
}
if($d>0){
$result .= $d.'d ';
}else if($M>0){
$result .= '0d ';
}
return "$result$h:$m:$s";
}
if (!$full)
$string = array_slice($string, 0, 1);
return $string ? implode(', ', $string) . ' ago' : 'just now';
}
public static function nl2br($text)
@ -143,14 +158,15 @@ class Lang
return ucwords(str_replace('_', ' ', $text));
}
public static function randomUpLowCase($text){
public static function randomUpLowCase($text)
{
$jml = strlen($text);
$result = '';
for($i = 0; $i < $jml;$i++){
if(rand(0,99)%2){
$result .= strtolower(substr($text,$i,1));
}else{
$result .= substr($text,$i,1);
for ($i = 0; $i < $jml; $i++) {
if (rand(0, 99) % 2) {
$result .= strtolower(substr($text, $i, 1));
} else {
$result .= substr($text, $i, 1);
}
}
return $result;
@ -162,52 +178,68 @@ class Lang
* 1 right
* 2 center
* */
public static function pad($text, $pad_string = ' ', $pad_type = 0){
public static function pad($text, $pad_string = ' ', $pad_type = 0)
{
global $config;
$cols = 37;
if($config['printer_cols']){
if ($config['printer_cols']) {
$cols = $config['printer_cols'];
}
$text = trim($text);
$texts = explode("\n", $text);
if(count($texts)>1){
if (count($texts) > 1) {
$text = '';
foreach($texts as $t){
$text.= self::pad(trim($t), $pad_string, $pad_type)."\n";
foreach ($texts as $t) {
$text .= self::pad(trim($t), $pad_string, $pad_type) . "\n";
}
return $text;
}else{
} else {
return str_pad(trim($text), $cols, $pad_string, $pad_type);
}
}
public static function pads($textLeft, $textRight, $pad_string = ' '){
public static function pads($textLeft, $textRight, $pad_string = ' ')
{
global $config;
$cols = 37;
if($config['printer_cols']){
if ($config['printer_cols']) {
$cols = $config['printer_cols'];
}
return $textLeft.str_pad($textRight, $cols-strlen($textLeft), $pad_string, 0);
return $textLeft . str_pad($textRight, $cols - strlen($textLeft), $pad_string, 0);
}
public static function translate($txt, $to='id'){
public static function translate($txt, $to = 'id')
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://translate.google.com/m?hl=en&sl=en&tl=$to&ie=UTF-8&prev=_m&q=".urlencode($txt));
curl_setopt($ch, CURLOPT_URL, "https://translate.google.com/m?hl=en&sl=en&tl=$to&ie=UTF-8&prev=_m&q=" . urlencode($txt));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; CPU OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/28.1 Mobile/15E148 Safari/605.1.15");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt ($ch, CURLOPT_HEADER, 0);
$hasil = curl_exec ($ch);
curl_setopt($ch, CURLOPT_HEADER, 0);
$hasil = curl_exec($ch);
curl_close($ch);
$temp = explode('<div class="result-container">', $hasil);
if(count($temp)>0){
if (count($temp) > 0) {
$temp = explode("</div", $temp[1]);
if(!empty($temp[0])){
if (!empty($temp[0])) {
return $temp[0];
}
}
return $txt;
}
public static function maskText($text){
$len = strlen($text);
if($len < 3){
return "***";
}else if($len<5){
return substr($text,0,1)."***".substr($text,-1,1);
}else if($len<8){
return substr($text,0,2)."***".substr($text,-2,2);
}else{
return substr($text,0,4)."******".substr($text,-3,3);
}
}
}

View File

@ -1,35 +1,10 @@
<?php
/**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
**/
// on some server, it getting error because of slash is backwards
function _autoloader($class)
{
if (strpos($class, '_') !== false) {
$class = str_replace('_', DIRECTORY_SEPARATOR, $class);
if (file_exists('autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
include 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
} else {
$class = str_replace("\\", DIRECTORY_SEPARATOR, $class);
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'))
include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
}
} else {
if (file_exists('autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
include 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
} else {
$class = str_replace("\\", DIRECTORY_SEPARATOR, $class);
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'))
include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
}
}
}
spl_autoload_register('_autoloader');
function r2($to, $ntype = 'e', $msg = '')
{
if ($msg == '') {
@ -48,75 +23,8 @@ if (file_exists('config.php')) {
r2('install');
}
function safedata($value)
{
$value = trim($value);
return $value;
}
function _post($param, $defvalue = '')
{
if (!isset($_POST[$param])) {
return $defvalue;
} else {
return safedata($_POST[$param]);
}
}
function _get($param, $defvalue = '')
{
if (!isset($_GET[$param])) {
return $defvalue;
} else {
return safedata($_GET[$param]);
}
}
function _req($param, $defvalue = '')
{
if (!isset($_REQUEST[$param])) {
return $defvalue;
} else {
return safedata($_REQUEST[$param]);
}
}
try {
require_once File::pathFixer('system/orm.php');
ORM::configure("mysql:host=$db_host;dbname=$db_name");
ORM::configure('username', $db_user);
ORM::configure('password', $db_password);
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
ORM::configure('return_result_sets', true);
if ($_app_stage != 'Live') {
ORM::configure('logging', true);
}
$result = ORM::for_table('tbl_appconfig')->find_many();
foreach ($result as $value) {
$config[$value['setting']] = $value['value'];
}
date_default_timezone_set($config['timezone']);
$_c = $config;
// check if proxy setup in database
if (empty($http_proxy) && !empty($config['http_proxy'])) {
$http_proxy = $config['http_proxy'];
if (empty($http_proxyauth) && !empty($config['http_proxyauth'])) {
$http_proxyauth = $config['http_proxyauth'];
}
}
if ((!empty($radius_user) && $config['radius_enable']) || _post('radius_enable')) {
ORM::configure("mysql:host=$radius_host;dbname=$radius_name", null, 'radius');
ORM::configure('username', $radius_user, 'radius');
ORM::configure('password', $radius_pass, 'radius');
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'), 'radius');
ORM::configure('return_result_sets', true, 'radius');
}
require_once 'init.php';
} catch (Throwable $e) {
$ui = new Smarty();
$ui->setTemplateDir(['custom' => File::pathFixer('ui/ui_custom/'), 'default' => File::pathFixer('ui/ui/')]);
@ -154,18 +62,6 @@ function _notify($msg, $type = 'e')
$_SESSION['ntype'] = $type;
$_SESSION['notify'] = $msg;
}
if (empty($config['language'])) {
$config['language'] = 'english';
}
$lan_file = File::pathFixer('system/lan/' . $config['language'] . '.json');
if (file_exists($lan_file)) {
$_L = json_decode(file_get_contents($lan_file), true);
$_SESSION['Lang'] = $_L;
} else {
$_L['author'] = 'Auto Generated by iBNuX Script';
$_SESSION['Lang'] = $_L;
file_put_contents($lan_file, json_encode($_L));
}
$ui = new Smarty();
$ui->assign('_kolaps', $_COOKIE['kolaps']);
@ -190,7 +86,6 @@ $ui->assign('_path', __DIR__);
$ui->assign('_c', $config);
$ui->assign('_L', $_L);
$ui->assign('_system_menu', 'dashboard');
$ui->assign('_title', $config['CompanyName']);
function _msglog($type, $msg)
{
@ -207,24 +102,6 @@ if (isset($_SESSION['notify'])) {
unset($_SESSION['ntype']);
}
include "autoload/Hookers.php";
// notification message
if (file_exists(File::pathFixer("system/uploads/notifications.json"))) {
$_notifmsg = json_decode(file_get_contents(File::pathFixer('system/uploads/notifications.json')), true);
}
$_notifmsg_default = json_decode(file_get_contents(File::pathFixer('system/uploads/notifications.default.json')), true);
//register all plugin
foreach (glob(File::pathFixer("system/plugin/*.php")) as $filename) {
try {
include $filename;
} catch (Throwable $e) {
} catch (Exception $e) {
}
}
function _auth($login = true)
{
if (User::getID()) {
@ -290,37 +167,6 @@ function sendWhatsapp($phone, $txt)
}
function time_elapsed_string($datetime, $full = false)
{
$now = new DateTime;
$ago = new DateTime($datetime);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = array(
'y' => 'year',
'm' => 'month',
'w' => 'week',
'd' => 'day',
'h' => 'hour',
'i' => 'minute',
's' => 'second',
);
foreach ($string as $k => &$v) {
if ($diff->$k) {
$v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');
} else {
unset($string[$k]);
}
}
if (!$full)
$string = array_slice($string, 0, 1);
return $string ? implode(', ', $string) . ' ago' : 'just now';
}
// Routing Engine
$req = _get('_route');
$routes = explode('/', $req);

View File

@ -158,14 +158,14 @@ switch ($action) {
}
$admins = [];
foreach ($d as $k) {
if(!empty($k['root'])){
if (!empty($k['root'])) {
$admins[] = $k['root'];
}
}
if(count($admins) > 0){
if (count($admins) > 0) {
$adms = ORM::for_table('tbl_users')->where_in('id', $admins)->find_many();
unset($admins);
foreach($adms as $adm){
foreach ($adms as $adm) {
$admins[$adm['id']] = $adm['fullname'];
}
}
@ -185,13 +185,45 @@ switch ($action) {
$ui->assign('agents', ORM::for_table('tbl_users')->where('user_type', 'Agent')->find_many());
$ui->display('users-add.tpl');
break;
case 'users-view':
$ui->assign('_title', Lang::T('Edit User'));
$id = $routes['2'];
if (empty($id)) {
$id = $admin['id'];
}
//allow see himself
if ($admin['id'] == $id) {
$d = ORM::for_table('tbl_users')->find_one($id);
} else {
if (in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
// Super Admin can see anyone
$d = ORM::for_table('tbl_users')->find_one($id);
} else if ($admin['user_type'] == 'Agent') {
// Agent can see Sales
$d = ORM::for_table('tbl_users')->where('root', $admin['id'])->find_one($id);
}
}
if ($d) {
if ($d['user_type'] == 'Sales') {
$ui->assign('agent', ORM::for_table('tbl_users')->find_one($d['root']));
}
$ui->assign('d', $d);
run_hook('view_edit_admin'); #HOOK
$ui->assign('_title', $d['username']);
$ui->display('users-view.tpl');
} else {
r2(U . 'settings/users', 'e', $_L['Account_Not_Found']);
}
break;
case 'users-edit':
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin', 'Agent'])) {
r2(U . "dashboard", 'e', Lang::T('You do not have permission to access this page'));
}
$ui->assign('_title', Lang::T('Edit User'));
$id = $routes['2'];
if (empty($id)) {
$id = $admin['id'];
}
if ($admin['id'] == $id) {
$d = ORM::for_table('tbl_users')->find_one($id);
} else {
@ -286,7 +318,7 @@ switch ($action) {
if ($admin['user_type'] == 'Agent') {
// Prevent hacking from form
$d->root = $admin['id'];
}else if($user_type == 'Sales'){
} else if ($user_type == 'Sales') {
$d->root = $root;
}
$d->save();
@ -382,7 +414,7 @@ switch ($action) {
if ($admin['user_type'] == 'Agent') {
// Prevent hacking from form
$d->root = $admin['id'];
}else if($user_type == 'Sales'){
} else if ($user_type == 'Sales') {
$d->root = $root;
}

View File

@ -1,96 +1,11 @@
<?php
/**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux
**/
// on some server, it getting error because of slash is backwards
function _autoloader($class)
{
if (strpos($class, '_') !== false) {
$class = str_replace('_', DIRECTORY_SEPARATOR, $class);
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
} else {
$class = str_replace("\\", DIRECTORY_SEPARATOR, $class);
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'))
include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
}
} else {
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
} else {
$class = str_replace("\\", DIRECTORY_SEPARATOR, $class);
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'))
include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
}
}
}
spl_autoload_register('_autoloader');
include "../init.php";
$isCli = true;
if (php_sapi_name() !== 'cli') {
$isCli = false;
echo "<pre>";
}
if (!file_exists('../config.php')) {
die("config.php file not found");
}
if (!file_exists('orm.php')) {
die("orm.php file not found");
}
if (!file_exists('uploads/notifications.default.json')) {
die("uploads/notifications.default.json file not found");
}
require_once '../config.php';
require_once 'orm.php';
require_once 'autoload/PEAR2/Autoload.php';
include "autoload/Hookers.php";
ORM::configure("mysql:host=$db_host;dbname=$db_name");
ORM::configure('username', $db_user);
ORM::configure('password', $db_password);
ORM::configure('return_result_sets', true);
ORM::configure('logging', true);
// notification message
if (file_exists("uploads/notifications.json")) {
$_notifmsg = json_decode(file_get_contents('uploads/notifications.json'), true);
}
$_notifmsg_default = json_decode(file_get_contents('uploads/notifications.default.json'), true);
//register all plugin
foreach (glob(File::pathFixer("plugin/*.php")) as $filename) {
try{
include $filename;
} catch(Throwable $e){
//ignore plugin error
}catch(Exception $e){
//ignore plugin error
}
}
$result = ORM::for_table('tbl_appconfig')->find_many();
foreach ($result as $value) {
$config[$value['setting']] = $value['value'];
}
date_default_timezone_set($config['timezone']);
if (!empty($radius_user) && $config['radius_enable']) {
ORM::configure("mysql:host=$radius_host;dbname=$radius_name", null, 'radius');
ORM::configure('username', $radius_user, 'radius');
ORM::configure('password', $radius_pass, 'radius');
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'), 'radius');
ORM::configure('return_result_sets', true, 'radius');
}
echo "PHP Time\t" . date('Y-m-d H:i:s') . "\n";
$res = ORM::raw_execute('SELECT NOW() AS WAKTU;');
$statement = ORM::get_last_statement();
@ -112,7 +27,7 @@ foreach ($d as $ds) {
if ($ds['type'] == 'Hotspot') {
$date_now = strtotime(date("Y-m-d H:i:s"));
$expiration = strtotime($ds['expiration'] . ' ' . $ds['time']);
echo $ds['expiration'] . " : " . $ds['username'];
echo $ds['expiration'] . " : " . (($isCli) ? $ds['username'] : Lang::maskText($ds['username']));
if ($date_now >= $expiration) {
echo " : EXPIRED \r\n";
$u = ORM::for_table('tbl_user_recharges')->where('id', $ds['id'])->find_one();
@ -167,7 +82,7 @@ foreach ($d as $ds) {
} else {
$date_now = strtotime(date("Y-m-d H:i:s"));
$expiration = strtotime($ds['expiration'] . ' ' . $ds['time']);
echo $ds['expiration'] . " : " . $ds['username'];
echo $ds['expiration'] . " : " . (($isCli) ? $ds['username'] : Lang::maskText($ds['username']));
if ($date_now >= $expiration) {
echo " : EXPIRED \r\n";
$u = ORM::for_table('tbl_user_recharges')->where('id', $ds['id'])->find_one();

View File

@ -7,82 +7,14 @@
* 0 7 * * * /usr/bin/php /var/www/system/cron_reminder.php
**/
// on some server, it getting error because of slash is backwards
function _autoloader($class)
{
if (strpos($class, '_') !== false) {
$class = str_replace('_', DIRECTORY_SEPARATOR, $class);
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
} else {
$class = str_replace("\\", DIRECTORY_SEPARATOR, $class);
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'))
include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
}
} else {
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php')) {
include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
} else {
$class = str_replace("\\", DIRECTORY_SEPARATOR, $class);
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php'))
include __DIR__ . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . $class . '.php';
}
}
}
spl_autoload_register('_autoloader');
include "../init.php";
if(php_sapi_name() !== 'cli'){
$isCli = true;
if (php_sapi_name() !== 'cli') {
$isCli = false;
echo "<pre>";
}
if(!file_exists('../config.php')){
die("config.php file not found");
}
if(!file_exists('orm.php')){
die("orm.php file not found");
}
if(!file_exists('uploads/notifications.default.json')){
die("uploads/notifications.default.json file not found");
}
require_once '../config.php';
require_once 'orm.php';
require_once 'autoload/PEAR2/Autoload.php';
include "autoload/Hookers.php";
ORM::configure("mysql:host=$db_host;dbname=$db_name");
ORM::configure('username', $db_user);
ORM::configure('password', $db_password);
ORM::configure('return_result_sets', true);
ORM::configure('logging', true);
// notification message
if (file_exists("uploads/notifications.json")) {
$_notifmsg = json_decode(file_get_contents('uploads/notifications.json'), true);
}
$_notifmsg_default = json_decode(file_get_contents('uploads/notifications.default.json'), true);
//register all plugin
foreach (glob(File::pathFixer("plugin/*.php")) as $filename) {
try{
include $filename;
} catch(Throwable $e){
//ignore plugin error
}catch(Exception $e){
//ignore plugin error
}
}
$result = ORM::for_table('tbl_appconfig')->find_many();
foreach ($result as $value) {
$config[$value['setting']] = $value['value'];
}
date_default_timezone_set($config['timezone']);
$d = ORM::for_table('tbl_user_recharges')->where('status', 'on')->find_many();
run_hook('cronjob_reminder'); #HOOK

View File

@ -397,5 +397,20 @@
"Radius_NAS": "Radius NAS",
"Translation": "Translation",
"Translation_saved_Successfully": "Translation saved Successfully",
"Language_Editor": "Language Editor"
"Language_Editor": "Language Editor",
"year": "year",
"month": "month",
"week": "week",
"day": "day",
"hour": "hour",
"minute": "minute",
"second": "second",
"Attributes": "Attributes",
"Profile": "Profile",
"Phone": "Phone",
"City": "City",
"Sub_District": "Sub District",
"Ward": "Ward",
"Credentials": "Credentials",
"Agent": "Agent"
}

View File

@ -86,7 +86,7 @@
</div>
<!-- Customers Attributes add start -->
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Customers Attributes')}</label>
<label class="col-md-2 control-label">{Lang::T('Attributes')}</label>
<div id="custom-fields-container" class="col-md-6">
<button class="btn btn-success btn-sm waves-effect waves-light" type="button"
id="add-custom-field">+</button>

View File

@ -106,7 +106,7 @@
<!--Customers Attributes edit end -->
<!--Customers Attributes add start -->
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Customers Attributes')}</label>
<label class="col-md-2 control-label">{Lang::T('Attributes')}</label>
<div id="custom-fields-container" class="col-md-6">
<button class="btn btn-success btn-sm waves-effect waves-light" type="button"
id="add-custom-field">+</button>

View File

@ -191,7 +191,7 @@
{foreach $dlog as $dlogs}
<li class="primary">
<span class="point"></span>
<span class="time small text-muted">{time_elapsed_string($dlogs['date'],true)}</span>
<span class="time small text-muted">{Lang::timeElapsed($dlogs['date'],true)}</span>
<p>{$dlogs['description']}</p>
</li>
{/foreach}

View File

@ -4,7 +4,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>{$_title}</title>
<title>{$_title} - {$_c['CompanyName']}</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">
@ -94,7 +94,7 @@
{Lang::T('Change Password')}</a>
</div>
<div class="col-xs-5 text-center text-sm">
<a href="{$_url}settings/users-edit/{$_admin['id']}">
<a href="{$_url}settings/users-view/{$_admin['id']}">
<i class="ion ion-person"></i> {Lang::T('My Account')}</a>
</div>
</div>

View File

@ -12,10 +12,10 @@
<link rel="stylesheet" href="ui/ui/fonts/ionicons/css/ionicons.min.css">
<link rel="stylesheet" href="ui/ui/fonts/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="ui/ui/fonts/MaterialDesign/css/materialdesignicons.min.css">
<link rel="stylesheet" href="ui/ui/styles/modern-AdminLTE.min.css">
<link rel="stylesheet" href="ui/ui/styles/modern-AdminLTE.min.css">
<link rel="stylesheet" href="ui/ui/styles/sweetalert2.min.css" />
<script src="ui/ui/scripts/sweetalert2.all.min.js"></script>
<style>
::-moz-selection {

71
ui/ui/users-view.tpl Normal file
View File

@ -0,0 +1,71 @@
{include file="sections/header.tpl"}
<!-- user-edit -->
<form class="form-horizontal">
<div class="row">
{if $d['user_type'] == "Sales"}<div class="col-sm-6 col-md-6">{else}<div class="col-md-6 col-md-offset-3">{/if}
<div
class="panel panel-{if $d['status'] != 'Active'}danger{else}primary{/if} panel-hovered panel-stacked mb30">
<div class="panel-heading">{$d['fullname']}</div>
<div class="panel-body">
<ul class="list-group list-group-unbordered">
<li class="list-group-item">
<b>{Lang::T('Username')}</b> <span class="pull-right">{$d['username']}</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Phone Number')}</b> <span class="pull-right">{$d['phone']}</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Email')}</b> <span class="pull-right">{$d['email']}</span>
</li>
<li class="list-group-item">
<b>{Lang::T('City')}</b> <span class="pull-right">{$d['city']}</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Sub District')}</b> <span class="pull-right">{$d['subdistrict']}</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Ward')}</b> <span class="pull-right">{$d['ward']}</span>
</li>
<li class="list-group-item">
<b>{Lang::T('User Type')}</b> <span class="pull-right">{$d['user_type']}</span>
</li>
</ul>
</div>
<div class="panel-footer">
<center><a href="{$_url}settings/users-edit/{$d['id']}"
class="btn btn-info btn-block">{Lang::T('Edit')}</a>
<a href="{$_url}settings/users" class="btn btn-link btn-block">{Lang::T('Cancel')}</a>
</center>
</div>
</div>
</div>
{if $d['user_type'] == "Sales" && $d['root'] neq ''}
<div class="col-sm-6 col-md-6">
<div class="panel panel-success">
<div class="panel-heading">Agent - {$agent['fullname']}</div>
<div class="panel-body">
<ul class="list-group list-group-unbordered">
<li class="list-group-item">
<b>{Lang::T('Phone Number')}</b> <span class="pull-right"><a href="tel:{$agent['phone']}">{$agent['phone']}</a></span>
</li>
<li class="list-group-item">
<b>{Lang::T('Email')}</b> <span class="pull-right"><a href="mailto:{$agent['email']}">{$agent['email']}</a></span>
</li>
<li class="list-group-item">
<b>{Lang::T('City')}</b> <span class="pull-right">{$agent['city']}</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Sub District')}</b> <span class="pull-right">{$agent['subdistrict']}</span>
</li>
<li class="list-group-item">
<b>{Lang::T('Ward')}</b> <span class="pull-right">{$agent['ward']}</span>
</li>
</ul>
</div>
</div>
</div>
{/if}
</div>
</form>
{include file="sections/footer.tpl"}

View File

@ -53,10 +53,12 @@
<td>{$ds['user_type']}</td>
<td>{$ds['city']}, {$ds['subdistrict']}, {$ds['ward']}</td>
<td>{if $ds['root']}
<a href="{$_url}settings/users-edit/{$ds['root']}">
<a href="{$_url}settings/users-view/{$ds['root']}">
{$admins[$ds['root']]}</a>{/if}</td>
<td>{Lang::dateTimeFormat($ds['last_login'])}</td>
<td>
<a href="{$_url}settings/users-view/{$ds['id']}"
class="btn btn-success btn-xs">{Lang::T('View')}</a>
<a href="{$_url}settings/users-edit/{$ds['id']}"
class="btn btn-info btn-xs">{Lang::T('Edit')}</a>
{if ($_admin['id']) neq ($ds['id'])}

View File

@ -76,7 +76,7 @@
{/if}</td>
<td align="center">{if $ds['generated_by']}
<a
href="{$_url}settings/users-edit/{$ds['generated_by']}">{$admins[$ds['generated_by']]}</a>
href="{$_url}settings/users-view/{$ds['generated_by']}">{$admins[$ds['generated_by']]}</a>
{else} -
{/if}
</td>