diff --git a/init.php b/init.php new file mode 100644 index 00000000..490da094 --- /dev/null +++ b/init.php @@ -0,0 +1,154 @@ +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]); + } +} \ No newline at end of file diff --git a/system/autoload/Lang.php b/system/autoload/Lang.php index d0d8f452..f2becec3 100644 --- a/system/autoload/Lang.php +++ b/system/autoload/Lang.php @@ -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('
"; } -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 diff --git a/system/lan/english.json b/system/lan/english.json index c1b5c4c8..2d17bf6e 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -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" } \ No newline at end of file diff --git a/ui/ui/customers-add.tpl b/ui/ui/customers-add.tpl index 26080561..547faf0c 100644 --- a/ui/ui/customers-add.tpl +++ b/ui/ui/customers-add.tpl @@ -86,7 +86,7 @@- +diff --git a/ui/ui/customers-edit.tpl b/ui/ui/customers-edit.tpl index 3b55a3d8..ea834069 100644 --- a/ui/ui/customers-edit.tpl +++ b/ui/ui/customers-edit.tpl @@ -106,7 +106,7 @@- +diff --git a/ui/ui/sections/user-header.tpl b/ui/ui/sections/user-header.tpl index 1bd2057b..7f7a49a6 100644 --- a/ui/ui/sections/user-header.tpl +++ b/ui/ui/sections/user-header.tpl @@ -12,10 +12,10 @@ - + - +diff --git a/ui/ui/dashboard.tpl b/ui/ui/dashboard.tpl index b16e1ad0..b1ba26c9 100644 --- a/ui/ui/dashboard.tpl +++ b/ui/ui/dashboard.tpl @@ -191,7 +191,7 @@ {foreach $dlog as $dlogs}- {time_elapsed_string($dlogs['date'],true)} + {Lang::timeElapsed($dlogs['date'],true)} {/foreach} diff --git a/ui/ui/sections/header.tpl b/ui/ui/sections/header.tpl index 50c3a604..deb7694e 100644 --- a/ui/ui/sections/header.tpl +++ b/ui/ui/sections/header.tpl @@ -4,7 +4,7 @@ -{$dlogs['description']}
{$_title} +{$_title} - {$_c['CompanyName']} @@ -94,7 +94,7 @@ {Lang::T('Change Password')}