2022-09-10 17:08:10 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2023-10-12 16:55:42 +08:00
|
|
|
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
|
|
|
* by https://t.me/ibnux
|
2022-09-10 17:08:10 +08:00
|
|
|
**/
|
|
|
|
|
2023-10-12 16:55:42 +08:00
|
|
|
|
2023-08-09 11:49:29 +08:00
|
|
|
class Lang
|
|
|
|
{
|
|
|
|
public static function T($var)
|
|
|
|
{
|
2022-09-10 17:08:10 +08:00
|
|
|
return Lang($var);
|
|
|
|
}
|
2023-03-06 15:51:05 +08:00
|
|
|
|
2023-08-09 11:49:29 +08:00
|
|
|
public static function htmlspecialchars($var)
|
|
|
|
{
|
2023-03-06 15:51:05 +08:00
|
|
|
return htmlspecialchars($var);
|
|
|
|
}
|
2023-08-09 11:49:29 +08:00
|
|
|
|
|
|
|
public static function moneyFormat($var)
|
|
|
|
{
|
|
|
|
global $config;
|
2023-10-04 18:07:13 +08:00
|
|
|
return $config['currency_code'] . ' ' . number_format($var, 0, $config['dec_point'], $config['thousands_sep']);
|
2023-08-09 11:49:29 +08:00
|
|
|
}
|
2023-08-09 15:54:38 +08:00
|
|
|
|
|
|
|
public static function phoneFormat($phone)
|
|
|
|
{
|
|
|
|
global $config;
|
2023-10-04 18:07:13 +08:00
|
|
|
if (Validator::UnsignedNumber($phone) && !empty($config['country_code_phone'])) {
|
2023-08-09 15:54:38 +08:00
|
|
|
return preg_replace('/^0/', $config['country_code_phone'], $phone);
|
2023-10-04 18:07:13 +08:00
|
|
|
} else {
|
2023-08-09 15:54:38 +08:00
|
|
|
return $phone;
|
|
|
|
}
|
|
|
|
}
|
2023-08-21 18:09:44 +08:00
|
|
|
|
2023-10-04 18:07:13 +08:00
|
|
|
public static function dateFormat($date)
|
|
|
|
{
|
2023-08-21 18:09:44 +08:00
|
|
|
global $config;
|
|
|
|
return date($config['date_format'], strtotime($date));
|
|
|
|
}
|
|
|
|
|
2023-10-04 18:07:13 +08:00
|
|
|
public static function dateTimeFormat($date)
|
|
|
|
{
|
2023-08-21 18:09:44 +08:00
|
|
|
global $config;
|
2023-10-04 18:07:13 +08:00
|
|
|
if (strtotime($date) < strtotime("2000-01-01 00:00:00")) {
|
2023-09-01 10:16:40 +08:00
|
|
|
return "";
|
2023-10-04 18:07:13 +08:00
|
|
|
} else {
|
|
|
|
return date($config['date_format'] . ' H:i', strtotime($date));
|
2023-09-01 10:16:40 +08:00
|
|
|
}
|
2023-08-21 18:09:44 +08:00
|
|
|
}
|
|
|
|
|
2023-10-04 18:07:13 +08:00
|
|
|
public static function dateAndTimeFormat($date, $time)
|
|
|
|
{
|
2023-08-24 16:12:31 +08:00
|
|
|
global $config;
|
2023-10-04 18:07:13 +08:00
|
|
|
return date($config['date_format'] . ' H:i', strtotime("$date $time"));
|
2023-08-24 16:12:31 +08:00
|
|
|
}
|
|
|
|
|
2023-10-04 18:07:13 +08:00
|
|
|
public static function nl2br($text)
|
|
|
|
{
|
2023-08-21 18:09:44 +08:00
|
|
|
return nl2br($text);
|
|
|
|
}
|
|
|
|
|
2023-10-04 18:07:13 +08:00
|
|
|
public static function arrayCount($arr)
|
|
|
|
{
|
|
|
|
if (is_array($arr)) {
|
|
|
|
return count($arr);
|
|
|
|
} else if (is_object($arr)) {
|
2023-09-26 14:50:02 +08:00
|
|
|
return count($arr);
|
2023-10-04 18:07:13 +08:00
|
|
|
} else {
|
2023-09-26 14:50:02 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2023-08-21 18:09:44 +08:00
|
|
|
}
|
2023-08-24 12:35:23 +08:00
|
|
|
|
2023-10-04 18:07:13 +08:00
|
|
|
public static function getNotifText($key)
|
|
|
|
{
|
2023-08-24 12:35:23 +08:00
|
|
|
global $_notifmsg, $_notifmsg_default;
|
2023-10-04 18:07:13 +08:00
|
|
|
if (isset($_notifmsg[$key])) {
|
2023-08-24 12:35:23 +08:00
|
|
|
return $_notifmsg[$key];
|
2023-10-04 18:07:13 +08:00
|
|
|
} else {
|
2023-08-24 12:35:23 +08:00
|
|
|
return $_notifmsg_default[$key];
|
|
|
|
}
|
|
|
|
}
|
2023-10-12 17:15:50 +08:00
|
|
|
|
|
|
|
public static function ucWords($text)
|
|
|
|
{
|
|
|
|
return ucwords(str_replace('_', ' ', $text));
|
|
|
|
}
|
2023-10-18 18:23:47 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
2024-01-16 11:32:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* $pad_type
|
|
|
|
* 0 Left
|
|
|
|
* 1 right
|
|
|
|
* 2 center
|
|
|
|
* */
|
|
|
|
public static function pad($text, $pad_string = ' ', $pad_type = 0){
|
|
|
|
global $config;
|
|
|
|
$cols = 37;
|
|
|
|
if($config['printer_cols']){
|
|
|
|
$cols = $config['printer_cols'];
|
|
|
|
}
|
2024-01-16 12:41:12 +08:00
|
|
|
$text = trim($text);
|
|
|
|
$texts = explode("\n", $text);
|
|
|
|
if(count($texts)>1){
|
|
|
|
$text = '';
|
|
|
|
foreach($texts as $t){
|
|
|
|
$text.= self::pad(trim($t), $pad_string, $pad_type)."\n";
|
|
|
|
}
|
|
|
|
return $text;
|
|
|
|
}else{
|
|
|
|
return str_pad(trim($text), $cols, $pad_string, $pad_type);
|
|
|
|
}
|
2024-01-16 11:32:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function pads($textLeft, $textRight, $pad_string = ' '){
|
|
|
|
global $config;
|
|
|
|
$cols = 37;
|
|
|
|
if($config['printer_cols']){
|
|
|
|
$cols = $config['printer_cols'];
|
|
|
|
}
|
|
|
|
return $textLeft.str_pad($textRight, $cols-strlen($textLeft), $pad_string, 0);
|
|
|
|
}
|
2022-09-10 17:08:10 +08:00
|
|
|
}
|