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 (!$full) $string = array_slice($string, 0, 1); return $string ? implode(', ', $string) . ' ago' : 'just now'; } public static function nl2br($text) { return nl2br($text); } public static function arrayCount($arr) { if (is_array($arr)) { return count($arr); } else if (is_object($arr)) { return count($arr); } else { return 0; } } public static function getNotifText($key) { global $_notifmsg, $_notifmsg_default; if (isset($_notifmsg[$key])) { return $_notifmsg[$key]; } else { return $_notifmsg_default[$key]; } } public static function ucWords($text) { return ucwords(str_replace('_', ' ', $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); } } return $result; } /** * $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']; } $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); } } 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); } 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_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_close($ch); $temp = explode('
', $hasil); if (count($temp) > 0) { $temp = explode("