$text"; } public static function iconfa($icon, $text = "") { return " $text"; } public static function in($stack, $needle) { return strpos ( $stack, $needle ) !== false; } public static function isAdm() { return ! Yii::$app->user->isGuest && Yii::$app->user->identity->can ( "admin" ); } public static function isAdmin() { return ! Yii::$app->user->isGuest && Yii::$app->user->identity->can ( "admin" ); } public static function isGuest() { return Yii::$app->user->isGuest; } public static function print_d($arr) { echo "
";
		print_r ( $arr );
		echo "
"; } public static function numberAbbr($number) { $abbrevs = [ 12 => 'T', 9 => 'B', 6 => 'M', 3 => 'K', 0 => '' ]; foreach ( $abbrevs as $exponent => $abbrev ) { if (abs ( $number ) >= pow ( 10, $exponent )) { $display = $number / pow ( 10, $exponent ); $decimals = ($exponent >= 3 && round ( $display ) < 100) ? 1 : 0; $number = number_format ( $display, $decimals ) . $abbrev; break; } } return $number; } public static function now() { return date ( "Y-m-d H:i:s" ); } public static function today() { return date ( "Y-m-d" ); } public static function time($secondsAgo = 0) { return date ( "Y-m-d H:i:s", time () - $secondsAgo ); } public static function isBefore($day) { return date ( "Y-m-d" ) <= $day; } public static function isAfter($day) { return date ( "Y-m-d" ) >= $day; } public static function formatTime($time, $en = false) { $time = strtotime ( $time ); $limit = time () - $time; if ($limit < 60) { return $en ? "Just now" : "刚才"; } elseif ($limit < 3600) { return floor ( $limit / 60 ) . ($en ? " min ago" : '分钟前'); } elseif ($limit < 86400) { return floor ( $limit / 3600 ) . ($en ? " hour ago" : '小时前'); } elseif ($limit < 86400 * 365) { return floor ( $limit / 86400 ) . ($en ? " day ago" : '天前'); } elseif ($limit >= 86400) { return date ( 'Y-m-d', $time ); } } public static function formatByte($num, $precision = 0) { return str_replace ( "B", "G", self::formatInt ( $num, $precision ) ); } public static function formatInt($num, $precision = 0) { $units = explode ( ",", ",K,M,B,T" ); foreach ( range ( 0, 4 ) as $i ) { if ($num < 1000) { return round ( $num, $precision ) . $units [$i]; } $num = $num / 1000; } } public static function formatIntCN($num, $precision = 0) { $units = explode ( ",", ",万,亿,兆" ); foreach ( range ( 0, 4 ) as $i ) { if ($num < 10000) { return round ( $num, $precision ) . $units [$i]; } $num = $num / 10000; } } public static function similar($str1, $str2) { similar_text ( $str1, $str2, $percent ); return $percent; } public static function ipLink($ip) { return Html::a ( $ip, "https://www.iplocation.net/?query=$ip" ); } public static function flagImage($key, $options = [ ]) { $key = trim ( strtolower ( $key ) ); return Html::tag ( "span", null, array_merge ( [ 'class' => "flag-icon flag-icon-$key", 'style' => "font-size:2em" ], $options ) ); } public static function lessThan($num) { return rand ( 0, 99 ) < $num; } public static function array_template($array, $template) { foreach ( $array as $k => $v ) { $array [$k] = str_replace ( "{value}", $v, $template ); } return $array; } public static function cacheGet($url, $duration = 3600) { $resp = Yii::$app->cache->get ( $url ); if (empty ( $resp )) { $resp = @file_get_contents ( $url ); Yii::$app->cache->set ( $url, $resp, $duration ); } return $resp; } public static function randomSelect($arr) { return $arr [rand ( 0, count ( $arr ) - 1 )]; } public static function isRunning($key) { $fp = fopen ( Yii::getAlias ( "@app/runtime/$key" ), 'w+' ); return ! flock ( $fp, LOCK_EX | LOCK_NB ); } public static function validateDate($date, $format = 'Y-m-d') { $date = str_replace ( "/", "-", $date ); $d = DateTime::createFromFormat ( $format, $date ); return $d && $d->format ( $format ) === $date; } public static function isSpider($regex = 'bot|spider|crawl|facebook') { $agent = Utils::choose ( $_SERVER ["HTTP_USER_AGENT"] ); return isset ( $_GET ['spider'] ) || preg_match ( "/$regex/i", $agent ); } public static function emailUrl($subject = null, $body = null) { $email = Yii::$app->params ['adminEmail']; return "mailto:$email?" . http_build_query ( [ 'subject' => "", "body" => $body ?: Yii::$app->request->absoluteUrl ] ); } } ?>
Fatal error: Uncaught Error: Class "chief725\libs\Utils" not found in /www/gongzuo.sg/web/index.php:18 Stack trace: #0 {main} thrown in /www/gongzuo.sg/web/index.php on line 18